Share the AUR notifier and the Nix hash classifier between their callers - #609
Conversation
Two workflow paths each carried their own copy of logic that had to agree, and in both cases only one copy would have been fixed. Dedup by label, not title. #607 was opened by release.yml — its body is release.yml's wording — while the canonical #602 sat open under a title I had edited. Both files searched `in:title`, so both would have missed; fixing only the recovery workflow would have left the automatic release path opening a duplicate on the next failure. notify-issue.sh now looks up open issues by the `aur-publish` label, which survives retitling, and both workflows call it. It also fails closed. The old lookup wrapped `gh issue list` in `2>/dev/null || true`, which makes a rate limit, a permissions gap and a GitHub outage indistinguishable from "no open issue" — and the next line files one. A lookup that errors now files nothing and exits nonzero; more than one labelled issue is also refused rather than resolved by guessing. Both workflows still emit their `::error::` annotation whatever the notifier does, so the underlying failure stays visible. Extract the Nix classifier so it can be tested. The nix-build job from #606 triggers on go.mod/go.sum, so every weekly dependabot Go bump fails it: a dependency change invalidates vendorHash and dependabot does not update it. The job *should* fail there. What was wrong is that it failed as a raw nix dump with no remedy, and being inline in the workflow, no test could reach it. nix-build-check.sh now runs the build, replays nix's diagnostics either way, propagates the real exit status, and emits the corrected `sha256-…` with `make update-nix-hash` — but only when the classifier confirms both a fixed-output mismatch diagnostic and an SRI-shaped value. That classifier is extract-nix-vendor-hash.sh, shared with update-nix-flake.sh rather than copied into it. Two production parsers that can drift is one too many when the one that drifts is the one that writes to nix/package.nix. The nix path filter picks up test.yml, the two scripts, and keeps go.sum. Narrowing it to drop go.sum would still have caught v0.8.0's Go-toolchain drift but would stop catching a stale vendorHash — the second v0.8.0 defect. Refs #602, #607
Sensitive Change Detection (shadow mode)This PR modifies control-plane files:
|
2de10d1 to
7a5f278
Compare
Annotation rendering, demonstrated and removedThe temporary wrong- The hash named in the annotation is exactly the one that was removed, nix's own Path filter, demonstratedThe first push ( https://github.com/basecamp/basecamp-cli/actions/runs/30864176279 Under the old filter a PR that changed only this job would have skipped the job |
Two pieces of logic each existed twice, and in both cases only one copy would
have been fixed. Both are consequences of my own earlier changes.
Label-based dedup, in both AUR paths
#607 was opened by
release.yml, not the manual recovery workflow — its body("Publishing [v0.8.1]…") is release.yml's wording, not aur-publish.yml's
("Recovery publish of…"). The canonical #602 was already open; I had retitled it,
and both files dedupe with
--search "in:title $TITLE", so the lookup missedand filed a duplicate. Fixing only the manual workflow leaves the automatic
release path opening another one on the next failure.
scripts/notify-issue.shnow searches open issues by theaur-publishlabel — which survives retitling, reassignment and rewording — comments on the
match, or creates with the label. Both workflows call it.
It fails closed
The old lookup was
... 2>/dev/null || true. That makes a rate limit, apermissions gap and a GitHub outage indistinguishable from "no open issue", and
the very next line files one. Four branches, each pinned by a test:
Both workflows emit their
::error::annotation regardless of what the notifierdid, so when it fails closed the failure is still visible on the run.
Extract the Nix classifier so tests can reach it
The
nix-buildjob from #606 triggers ongo.mod/go.sum, so every weeklydependabot Go bump will fail it — a dependency change invalidates
vendorHashand dependabot will not update it. The job should fail. The defect is that it
failed as a raw nix dump with no remedy, and being an inline
run:block, notest could reach it. Its path filter also omitted
.github/workflows/test.yml,so a PR editing the job would skip the job it edited.
scripts/nix-build-check.shruns the build, replays nix's diagnostics eitherway, propagates the build's real exit status (no
|| true), and emits thecorrected
sha256-…plusmake update-nix-hash— but only when both thefixed-output diagnostic and an SRI-shaped value are present.
That guard is
scripts/extract-nix-vendor-hash.sh, shared withupdate-nix-flake.shrather than copied into it. Two production classifiersthat can drift is one too many when the one that drifts is the one that writes
into
nix/package.nix. Fixture tests pin the helper; separate wrapper tests pinexit propagation, diagnostic replay, annotation rendering, and that a successful
build is not trusted until the binary it produced actually runs.
Considered and rejected: narrowing the filter to drop
go.sum. It would stillhave caught v0.8.0's Go-toolchain drift (go.mod's
godirective plusflake.lock) but would stop catching a stalevendorHash— the second v0.8.0defect.
Verification
bin/ciexit 0;make lint-actionsclean (actionlint + zizmor).update_nix_flake.bats, which now routes through the shared classifier.|| truefailsexactly the fail-closed test, and loosening the SRI pattern to
[^[:space:]]+fails exactly the two shape tests. Nothing else moved.
resolves to labelled Publish v0.8.1 to the AUR once Arch re-enables pushes #602 and takes the comment branch, so it will not open
a third issue.
test.yml, so thenix-buildjob running here is itself theproof that the widened path filter works.
vendorHashcommit will demonstrate the::error::rendering once, then be removed before review.
The
aur-publishlabel has been created and applied to #602, so the label pathis live before this merges.
Refs #602, #607
Summary by cubic
Share the AUR failure notifier and the Nix vendorHash classifier across workflows to remove duplicate logic, prevent duplicate issues, and make CI failures actionable with the correct hash and remedy.
Bug Fixes
aur-publishlabel viascripts/notify-issue.sh.::error::annotation and propagate the notifier’s status.Refactors
scripts/extract-nix-vendor-hash.shand wired it intoscripts/nix-build-check.shandscripts/update-nix-flake.sh.nix-buildjob now runsscripts/nix-build-check.sh: replays nix logs, preserves real exit status, annotates with the correctedsha256-…andmake update-nix-hashonly on a fixed‑output mismatch with an SRI hash, verifies the built binary runs, and errors if nix prints no store path.test.ymlpath filter to include Nix and script paths (incl. this file). Added BATS tests for the notifier, classifier, and build wrapper.Written for commit 7a5f278. Summary will update on new commits.