From c00c6440b26159b9f1de42425c49ad02f6dbae54 Mon Sep 17 00:00:00 2001 From: Lily Shen <115414357+lilyshen0722@users.noreply.github.com> Date: Wed, 2 Sep 2026 07:12:16 -0700 Subject: [PATCH] ci(adr): resolve the checker from the effective tree, not the PR head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PR arm checks out the PR HEAD by design (the merge ref is stale), but GitHub takes the WORKFLOW from the merge ref. So a PR branched before #1481 gets the workflow file and not scripts/verify-adr-numbering.js, and the step dies with MODULE_NOT_FOUND before printing a single ADR line — red, with nothing an author can act on. Hit #1504 first; it would have hit most open PRs on their next event. Resolve the checker the same way the ADRs are resolved: the PR's version if it changed the script, main's otherwise. Verified against #1504's head (script absent): green, 29 ADRs. Same head with a synthetic second ADR-025 added: red, naming both files. Against main (script present): resolves from HEAD, green. Co-Authored-By: Claude Opus 5 --- .github/workflows/adr-numbering-guard.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/adr-numbering-guard.yml b/.github/workflows/adr-numbering-guard.yml index 04d673b8af..43bc78d8ac 100644 --- a/.github/workflows/adr-numbering-guard.yml +++ b/.github/workflows/adr-numbering-guard.yml @@ -102,7 +102,23 @@ jobs: esac done - node scripts/verify-adr-numbering.js --dir "$eff/docs/adr" + # The checker itself has to be resolved the same way as the ADRs, and + # for the same reason. On a `pull_request` event GitHub takes the + # WORKFLOW from the merge ref but this job checks out the PR HEAD — + # so every PR branched before this guard landed has the workflow file + # and not the script, and `node scripts/...` died with + # MODULE_NOT_FOUND. That reds the PR with no ADR output at all, which + # reads as a broken guard rather than a real collision (#1504). + # Effective content: the PR's version if it changed the script, + # otherwise main's. + bin=$(mktemp -d) + if git cat-file -e "HEAD:scripts/verify-adr-numbering.js" 2>/dev/null; then + git show "HEAD:scripts/verify-adr-numbering.js" > "$bin/verify-adr-numbering.js" + else + git show "FETCH_HEAD:scripts/verify-adr-numbering.js" > "$bin/verify-adr-numbering.js" + fi + + node "$bin/verify-adr-numbering.js" --dir "$eff/docs/adr" # The check above cannot see a collision between two PRs that are both # still open — neither tree contains the other's file. That is the state