Skip to content

Commit 2f842d3

Browse files
committed
Track haddock dead-link CI failures in a rolling issue
When the haddock-links check fails on master, open (or comment on) a single tracking issue identified by the marker label 'haddock-ci-failure', @-mentioning the breaker — sourced from the master commit's associated PR via listPullRequestsAssociatedWithCommit, which handles squash merges. The issue body documents the fix recipe (add the package's doc base URL to IOG_DOC_BASES, or add the package to KNOWN_UNDOCUMENTED). Each failure appends a comment with the run URL so the audit trail of consecutive breakages is visible in one place. Add an id to the haddock-links step so the new tag-breaker step can gate on its specific outcome (failure() && steps.<id>.outcome == 'failure'), avoiding spurious issue creation on unrelated failures (cabal build, nix shell, network glitch in haddock-project, etc.).
1 parent 2f86a4a commit 2f842d3

1 file changed

Lines changed: 102 additions & 0 deletions

File tree

.github/workflows/github-page.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ jobs:
4040
cabal haddock-project --output=./website --internal --foreign-libraries
4141
4242
- name: Fix cross-package Haddock links
43+
id: fix-haddock-links
4344
run: |
4445
./scripts/fix-haddock-links.sh ./website
4546
@@ -69,3 +70,104 @@ jobs:
6970
publish_dir: website
7071
cname: cardano-api.cardano.intersectmbo.org
7172
force_orphan: true
73+
74+
# On post-merge dead-link failure, append the latest breakage to a
75+
# rolling tracking issue (one issue total, comment per failure).
76+
# Identified by the marker label `haddock-ci-failure`. The breaker
77+
# gets @-mentioned in the comment and added as an assignee.
78+
- name: Open / update dead-link tracking issue
79+
if: failure() && steps.fix-haddock-links.outcome == 'failure' && github.ref == 'refs/heads/master'
80+
uses: actions/github-script@v7
81+
with:
82+
script: |
83+
const labelName = 'haddock-ci-failure';
84+
const titleText = 'Haddock dead-link CI failures on master';
85+
86+
// Ensure the marker label exists (idempotent — 422 means
87+
// already there).
88+
try {
89+
await github.rest.issues.createLabel({
90+
owner: context.repo.owner,
91+
repo: context.repo.repo,
92+
name: labelName,
93+
color: 'd93f0b',
94+
description: 'Post-merge haddock-links CI failures (rolling tracking issue)',
95+
});
96+
} catch (e) {
97+
if (e.status !== 422) throw e;
98+
}
99+
100+
// Identify the breaker via the master commit's associated PR
101+
// (works for squash merges, which is what cardano-api uses).
102+
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
103+
owner: context.repo.owner,
104+
repo: context.repo.repo,
105+
commit_sha: context.sha,
106+
});
107+
const pr = prs[0];
108+
const author = pr ? pr.user.login : context.actor;
109+
const prRef = pr ? `#${pr.number}` : `commit ${context.sha.slice(0, 7)}`;
110+
const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`;
111+
112+
const commentBody = [
113+
`### New failure`,
114+
``,
115+
`On master after ${prRef} (committed by @${author}).`,
116+
``,
117+
`**Run:** ${runUrl}`,
118+
``,
119+
`Open the run log and look for \`=== Actionable — fix these ===\` to see which package(s) the probe couldn't resolve.`,
120+
].join('\n');
121+
122+
// Look for an existing open issue with the marker label.
123+
const { data: issues } = await github.rest.issues.listForRepo({
124+
owner: context.repo.owner,
125+
repo: context.repo.repo,
126+
state: 'open',
127+
labels: labelName,
128+
per_page: 1,
129+
});
130+
131+
if (issues.length > 0) {
132+
const existing = issues[0];
133+
await github.rest.issues.createComment({
134+
owner: context.repo.owner,
135+
repo: context.repo.repo,
136+
issue_number: existing.number,
137+
body: commentBody,
138+
});
139+
await github.rest.issues.addAssignees({
140+
owner: context.repo.owner,
141+
repo: context.repo.repo,
142+
issue_number: existing.number,
143+
assignees: [author],
144+
});
145+
console.log(`Appended to existing issue #${existing.number}: ${existing.html_url}`);
146+
} else {
147+
const issueBody = [
148+
`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.`,
149+
``,
150+
`## How to fix`,
151+
``,
152+
`For each package listed under \`=== Actionable — fix these ===\` in the failing run:`,
153+
``,
154+
`1. Check the package's source repo for a published Haddocks site (gh-pages, CloudFront, etc.).`,
155+
`2. If found: append the base URL to \`IOG_DOC_BASES\` in \`scripts/fix-haddock-links.sh\`.`,
156+
`3. If genuinely unpublished: add the package name to \`KNOWN_UNDOCUMENTED\`.`,
157+
``,
158+
`Then re-run the workflow from the Actions tab. Close this issue once the workflow goes green again.`,
159+
``,
160+
`---`,
161+
``,
162+
commentBody,
163+
].join('\n');
164+
const created = await github.rest.issues.create({
165+
owner: context.repo.owner,
166+
repo: context.repo.repo,
167+
title: titleText,
168+
body: issueBody,
169+
labels: [labelName],
170+
assignees: [author],
171+
});
172+
console.log(`Opened tracking issue #${created.data.number}: ${created.data.html_url}`);
173+
}

0 commit comments

Comments
 (0)