-
Notifications
You must be signed in to change notification settings - Fork 29
246 lines (226 loc) Β· 11.3 KB
/
github-page.yml
File metadata and controls
246 lines (226 loc) Β· 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
name: "Update github pages"
on:
push:
branches:
- master
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
accept-flake-config = true
- uses: rrbutani/use-nix-shell-action@v1
with:
devShell: .#ghc914
- name: Update cabal indices
run: |
cabal update
- name: Build whole project
run: |
cabal build all
- name: Build haddock documentation
run: |
mkdir website
cabal haddock-project --output=./website --internal --foreign-libraries
- name: Fix cross-package Haddock links
id: fix-haddock-links
run: |
./scripts/fix-haddock-links.sh ./website
- name: Build typedoc documentation
run: |
nix build .#wasm-typedoc
mkdir -p website/cardano-wasm/typedoc
cp -r result/. website/cardano-wasm/typedoc/
- name: Compress website
run: |
tar -czf website.tgz -C website .
- name: Upload website artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
continue-on-error: true
with:
name: website
path: ./website.tgz
- name: Deploy documentation to gh-pages π
if: github.ref == 'refs/heads/master'
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN || github.token }}
publish_dir: website
cname: cardano-api.cardano.intersectmbo.org
force_orphan: true
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# Tracking-issue logic for post-merge dead-link failures.
#
# Why: when fix-haddock-links.sh exits 1 on master (because some
# newly-introduced CHaP package has no entry in IOG_DOC_BASES /
# KNOWN_UNDOCUMENTED), the Deploy step further down skips and the
# docs site stays at its last good revision. Without this step, the
# only signal that something is broken is a red Actions run that
# nobody is necessarily watching. This step opens a GitHub issue
# tagging whoever introduced the breakage, so it lands on someone's
# board instead of going unnoticed.
#
# Behaviour summary: one rolling issue per outage period. First
# failure opens a new issue. Subsequent failures (while the issue
# is still open) append a comment instead of opening a duplicate.
# Once a maintainer fixes the root cause and closes the issue, the
# next failure opens a fresh one.
#
# The fire conditions on the `if:` line below β all three required:
# - failure() β the job overall is failing
# - steps.fix-haddock-links.outcome β specifically the haddock-links
# == 'failure' step failed (not e.g. cabal,
# nix-shell, or the typedoc build)
# - github.ref == 'refs/heads/master' β only on master pushes; not
# on workflow_dispatch from
# feature branches
- name: Open / update dead-link tracking issue
if: failure() && steps.fix-haddock-links.outcome == 'failure' && github.ref == 'refs/heads/master'
uses: actions/github-script@v7
with:
script: |
// Marker label used to identify the rolling tracking issue.
// Looking up issues by label is more robust than by title (a
// title match would break the moment someone edits the title).
const labelName = 'haddock-ci-failure';
const titleText = 'Haddock dead-link CI failures on master';
// βββ 1. Ensure the marker label exists ββββββββββββββββββββββ
// First time this step ever fires, the label doesn't exist
// yet and createLabel returns 201. Every subsequent run, the
// API returns 422 ("name has already been taken") which we
// swallow so the step continues. Any other error (403 = no
// permission, 5xx = GitHub outage, etc.) re-throws and fails
// the step, leaving a stack trace for debugging.
try {
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: labelName,
color: 'd93f0b',
description: 'Post-merge haddock-links CI failures (rolling tracking issue)',
});
} catch (e) {
if (e.status !== 422) throw e;
}
// βββ 2. Identify the breaker ββββββββββββββββββββββββββββββββ
// We want to @-mention the *PR opener* (the author who wrote
// the change), not the merger (who clicked the merge button)
// or the committer (whose name might be set to a bot identity).
// listPullRequestsAssociatedWithCommit takes the new master
// HEAD's SHA and returns the PR(s) that produced it. Works for
// merge-commit, rebase, and squash-merge styles β GitHub
// records the commitβPR association regardless. We read
// pr.user.login from the result to get the PR opener.
//
// Fallback: in the unlikely case a master commit has no
// associated PR (direct push by a maintainer), use
// context.actor β the user who triggered the workflow run.
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
});
const pr = prs[0];
const author = pr ? pr.user.login : context.actor;
const prRef = pr ? `#${pr.number}` : `commit ${context.sha.slice(0, 7)}`;
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
// Body fragment used both as the comment body (when an issue
// already exists) and appended to the issue body (when we
// create a new one). Same content, two contexts.
const commentBody = [
`### New failure`,
``,
`On master after ${prRef} (committed by @${author}).`,
``,
`**Run:** ${runUrl}`,
``,
`Open the run log and look for \`=== Actionable β fix these ===\` to see which package(s) the probe couldn't resolve.`,
].join('\n');
// βββ 3. Look up the existing tracking issue βββββββββββββββββ
// Filter by `state: open` so a closed (i.e. already-fixed)
// tracking issue doesn't get reused β we want a fresh issue
// for the next outage period, not to reopen a stale one.
// per_page: 1 because we only need to know whether ANY exists.
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: labelName,
per_page: 1,
});
// βββ 4. Branch on whether one was found βββββββββββββββββββββ
if (issues.length > 0) {
// Existing open issue β comment on it; don't open a duplicate.
// Also add the new breaker as an assignee (idempotent β if
// they're already assigned the API silently no-ops).
const existing = issues[0];
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existing.number,
body: commentBody,
});
try {
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existing.number,
assignees: [author],
});
} catch (e) {
// External contributors aren't repo collaborators, so the API
// returns 422 here. Log and continue rather than crashing the
// step β the comment was posted, which is the important part.
console.log(`Could not assign @${author} to #${existing.number} (likely not a repo collaborator): ${e.message}`);
}
console.log(`Appended to existing issue #${existing.number}: ${existing.html_url}`);
} else {
// No open issue β create one. The body documents the fix
// recipe so the assignee doesn't need to find it elsewhere.
const issueBody = [
`Tracking issue for post-merge \`Update github pages\` workflow failures on the haddock-links check. The Deploy step skips on failure, so the published docs site stays at its last good revision until this issue is resolved.`,
``,
`## How to fix`,
``,
`For each package listed under \`=== Actionable β fix these ===\` in the failing run:`,
``,
`1. Check the package's source repo for a published Haddocks site (gh-pages, CloudFront, etc.).`,
`2. If found: append the base URL to \`IOG_DOC_BASES\` in \`scripts/fix-haddock-links.sh\`.`,
`3. If genuinely unpublished: add the package name to \`KNOWN_UNDOCUMENTED\`.`,
``,
`Then re-run the workflow from the Actions tab. Close this issue once the workflow goes green again.`,
``,
`---`,
``,
commentBody,
].join('\n');
// Create the issue without assignees first β passing assignees
// to issues.create makes the whole call 422 for non-collaborator
// authors. We assign separately so the issue always lands.
const created = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: titleText,
body: issueBody,
labels: [labelName],
});
try {
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: created.data.number,
assignees: [author],
});
} catch (e) {
console.log(`Could not assign @${author} to #${created.data.number} (likely not a repo collaborator): ${e.message}`);
}
console.log(`Opened tracking issue #${created.data.number}: ${created.data.html_url}`);
}