Skip to content

Commit e2cafbe

Browse files
ci: a failing drift run reports to the issue tracker, not the Actions tab
The job as first written had the flaw it was built to fix, one level up: it would detect upstream breakage and then tell nobody. A scheduled run has no pull request to turn red and no author to notify, and this repository has already paid for exactly that -- `pages.yml` failed on two consecutive pushes and sat unnoticed for the better part of two months, while the published site served a version six releases behind. A weekly job in a repository that goes quiet for weeks is the same shape. So a failure now opens an issue, or comments on the open one if there is already one. Reused rather than re-opened: an unattended weekly job that files a fresh issue every Monday is a second way of being ignored. Matched on title rather than a label, so it needs no label to exist first. The body says what a reader needs and not more: that this is not any branch's fault, that every other job resolves against `uv.lock` while this one does not, that the remedy is an upstream fix or a narrower range in pyproject.toml (#103), and that the run log's lockfile diff names what moved. `issues: write` is added at the job level, which replaces rather than extends the workflow's permissions, so `contents: read` is repeated there. Verified by extracting the step's script from the parsed YAML and running it against a stubbed `gh`: the heredoc dedents correctly out of the block scalar, the escaped backticks survive as literals, `$RUN_URL` expands, and the two paths do what they claim -- create when no issue is open, comment when one is, with no duplicate. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 39a9083 commit e2cafbe

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,12 @@ jobs:
190190
name: upstream drift (unlocked deps)
191191
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
192192
runs-on: ubuntu-latest
193+
# `issues: write` is for the reporting step below; a job's permissions
194+
# replace the workflow's rather than adding to them, so `contents: read`
195+
# is repeated here.
196+
permissions:
197+
contents: read
198+
issues: write
193199
steps:
194200
- uses: actions/checkout@v4
195201
- uses: astral-sh/setup-uv@v5
@@ -207,6 +213,45 @@ jobs:
207213
run: |
208214
uv sync --all-extras --group dev
209215
uv run pytest
216+
- name: Say so where someone will see it
217+
# A scheduled run reports to nobody. This repository has already paid
218+
# for that: `pages.yml` failed on two consecutive pushes and the
219+
# failures sat unnoticed for the better part of two months, while the
220+
# published site served a version six releases behind. A weekly job in
221+
# a repository that goes quiet for weeks at a time is the same shape,
222+
# so the failure comes to the issue tracker instead of the Actions tab.
223+
#
224+
# One issue, reused: an unattended weekly job that opens a fresh issue
225+
# every Monday is a second way of being ignored. Matched on title
226+
# rather than a label, so this needs no label to exist first.
227+
if: failure()
228+
env:
229+
GH_TOKEN: ${{ github.token }}
230+
TITLE: "upstream drift: the suite fails against re-resolved dependencies"
231+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
232+
run: |
233+
body=$(cat <<EOF
234+
The weekly \`upstream-drift\` job failed: the suite does not pass against the
235+
newest dependency versions \`pyproject.toml\` allows.
236+
237+
Run: $RUN_URL
238+
239+
**This is not a failure of any branch.** Every other job resolves against
240+
\`uv.lock\`; this one re-resolves from scratch. So either an upstream release
241+
broke something, or a range in \`pyproject.toml\` needs narrowing — which is
242+
what #103 asks for. The job prints the re-resolved lockfile diff, so the run
243+
log says which dependencies moved.
244+
EOF
245+
)
246+
existing=$(gh issue list --state open --search "$TITLE in:title" \
247+
--json number --jq '.[0].number // empty')
248+
if [ -n "$existing" ]; then
249+
echo "commenting on existing issue #$existing"
250+
gh issue comment "$existing" --body "$body"
251+
else
252+
echo "opening a new issue"
253+
gh issue create --title "$TITLE" --body "$body"
254+
fi
210255
211256
build:
212257
name: build and check the distribution

0 commit comments

Comments
 (0)