Skip to content

Commit f75a271

Browse files
authored
feat: share the scheduled-failure report as a reusable workflow (#127)
1 parent 959958b commit f75a271

3 files changed

Lines changed: 50 additions & 3 deletions

File tree

‎.github/workflows/links.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
fail: false
3636
# create-issue-from-file does not deduplicate — it calls issues.create
3737
# unconditionally, so six weeks of one dead link is six identical issues. This is
38-
# the same find-or-comment shape every repo's report-scheduled-failure.sh uses.
38+
# the same find-or-comment shape as the shared report-scheduled-failure.yml.
3939
- name: Open or update the tracking issue
4040
if: steps.lychee.outputs.exit_code != 0
4141
env:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: report-scheduled-failure
2+
3+
# Called by every repo's scheduled.yml when its scheduled checks fail (standard CI2).
4+
on:
5+
workflow_call: {}
6+
7+
jobs:
8+
report:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Open or update the tracking issue
12+
env:
13+
GH_TOKEN: ${{ github.token }}
14+
GH_REPO: ${{ github.repository }}
15+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
16+
run: |
17+
set -euo pipefail
18+
LABEL="scheduled-failure"
19+
# --force makes this idempotent: it creates the label, or updates it in place.
20+
gh label create "$LABEL" \
21+
--color "FBCA04" \
22+
--description "Scheduled dependency check failures" \
23+
--force
24+
existing=$(gh issue list --label "$LABEL" --state open --json number --jq '.[0].number // empty')
25+
if [ -z "$existing" ]; then
26+
gh issue create --title "Scheduled dependency check failed" --label "$LABEL" --body "$(printf '%s\n\n%s\n\n%s\n\n%s' \
27+
"The scheduled dependency check failed." \
28+
"First failing run: ${RUN_URL}" \
29+
"Likely cause: a new release of a dependency or of Python broke the build; the failing job in the run shows where. Reproduce locally with \`just install\`, then \`just lint\` and \`just test\`." \
30+
"Close this issue once fixed. The next scheduled failure will open a fresh issue.")"
31+
else
32+
gh issue comment "$existing" --body "Failed again: ${RUN_URL}"
33+
fi

‎docs/standard.md‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,24 @@ superseded runs.
181181

182182
`scheduled.yml` MUST run daily and on `workflow_dispatch`, running the same checks as `ci.yml`
183183
except `floors` ([CI6](#CI6)). On a scheduled failure it MUST open or update a tracking issue in the
184-
repo.
184+
repo with this job, byte for byte, and a repo MUST NOT keep its own report script:
185+
186+
```yaml
187+
report-failure:
188+
needs: checks
189+
if: failure() && github.event_name == 'schedule'
190+
permissions:
191+
issues: write
192+
uses: modern-python/.github/.github/workflows/report-scheduled-failure.yml@main
193+
```
185194
186195
*Why:* a dependency release or a new Python that breaks the build becomes a ticket without anyone
187-
watching.
196+
watching. The report is shared because the per-repo copies drifted: each named its own list of
197+
likely culprits, and several listed a dependency the repo does not have. The issue links the failing
198+
run, which shows the failing job, so the shared text stays generic. It takes no inputs,
199+
so it does not hit what sank a shared `_checks.yml` ([CI3](#CI3)). Like the ADR check
200+
([CI9](#CI9)), it tracks `main` unpinned, so a change reaches every repo's next scheduled failure at
201+
once.
188202

189203
### CI3 · Per-repo `_checks.yml` { #CI3 }
190204

0 commit comments

Comments
 (0)