Repository navigation
release.yml: gate goreleaser on tests passing - #2
Conversation
A tag push has no relation to the test workflow (only triggers on push:branches/pull_request) — release.yml went straight from tag push to goreleaser, so a tag could publish binaries whose tests never ran or failed. `just release` checks version.txt/clean-tree/tag-existence but not CI status. Added a `test` job (build/vet/test/gofmt, matching test.yml) that `goreleaser` now needs. Same gap unidoc-alip's age-plugin-sshagent review caught (F2) — fixing here too ahead of today's release.
unidoc-alip
left a comment
There was a problem hiding this comment.
Verdict: COMMENT — 0 must-fix, 1 should-fix, 1 nit
This PR closes a real hole: release.yml triggers on push: tags: ["v*"] and went straight
to goreleaser release --clean, while test.yml triggers only on push: branches: [master]
and pull_request. A tag push therefore ran no build, no go vet, no go test and no
gofmt check — binaries could be published from a commit whose tests had never run. The fix
(a test job in release.yml plus needs: test on goreleaser) is the right shape, holds
regardless of how the tag was created, and is correctly minimal at 19 added lines with nothing
removed.
The gap and the fix were both verified by machine, not just read — see the appendix. Nothing
here blocks merge; both findings are follow-ups you could reasonably take in a separate commit.
Findings are keyed F1, F2, … (not #1, which GitHub would autolink to an unrelated issue).
F1 [should-fix] .github/workflows/release.yml line 18 — the test job is a verbatim copy of test.yml, and nothing keeps them in sync
The new jobs.test in release.yml is step-for-step identical to jobs.test in test.yml.
The PoC asserts that parity today and it holds (inline-match), which is exactly the point:
the two are equal now, and there is no mechanism that keeps them equal. The next change to the
CI recipe — a new linter, a -race flag, an apt-get install for an integration dependency,
a Go version pin — will land in test.yml because that is the workflow people see on PRs, and
release.yml will silently start gating releases on a weaker check than the one that gates
merges. That is a quiet failure: the release still goes green.
GitHub's reusable-workflow support removes the duplication without changing behaviour. In
test.yml, add one trigger:
on:
push:
branches: [master]
pull_request:
workflow_call:and in release.yml, replace the whole inline job with:
test:
uses: ./.github/workflows/test.ymlI built this variant and ran it through the same assertions plus actionlint under a real
.github/workflows/ layout, so the uses: path actually resolves; both are clean and
goreleaser still resolves needs: test. Two things to know before taking it: a called
workflow's checks surface as test / test rather than test, so any branch-protection rule
naming the required check needs updating; and a uses: job cannot carry runs-on or steps,
which is why the block collapses to a single line.
Worth folding in while you are in there: the gofmt step masks gofmt's own exit code.
$ bash -c 'gofmt -l /nonexistent | tee /tmp/fmt.out && test ! -s /tmp/fmt.out'; echo $?
stat /nonexistent: no such file or directory
0
The pipeline's status is tee's, and GitHub Actions runs run: steps under bash -e {0}
without pipefail, so a gofmt that errors out rather than printing filenames passes the
step. It is low-impact — gofmt rarely fails outright — but the copy in release.yml now
inherits it, and consolidating via workflow_call means fixing it once instead of twice.
If you would rather leave the workflows duplicated, the one-line fix is shell: bash on that
step — GitHub then runs it as bash --noprofile --norc -eo pipefail {0}, and with pipefail
set the same command returns 2 on a gofmt error instead of 0. Note that test -z "$(gofmt -l .)" is not a fix: gofmt's error goes to stderr, stdout is empty, and test -z "" succeeds
just the same.
F2 [nit] .github/workflows/release.yml line 8 — the new test job inherits contents: write
permissions: contents: write is declared at workflow level, so it applied to one job before
this PR and applies to two after it. The test job now runs go build, go vet and
go test ./... — arbitrary project and dependency code — with a GITHUB_TOKEN that can push
to the repo and create releases. Only goreleaser needs that.
permissions:
contents: read # workflow-level default
jobs:
test:
runs-on: ubuntu-latest
# inherits contents: read
goreleaser:
needs: test
runs-on: ubuntu-latest
permissions:
contents: write # only the publishing jobGenuinely a nit given the threat model — your own code, tags pushed by maintainers — but it is
a two-line change that makes the blast radius of a compromised transitive dependency smaller,
and this PR is the moment the second job appears.
PR description verification
- "A tag push has no relation to the test workflow (only triggers on
push:branches/pull_request)" — confirmed. Parsedtest.yml's triggers:on.pushhas abrancheskey and notagskey, and tags are not branches, so av*tag push starts nothing intest.yml. Asserted in the PoC astest.yml-tag-trigger=Falseacross all three variants. - "
release.ymlwent straight from tag push to goreleaser" — confirmed. Onmaster,release.ymlhas exactly one job and it carries noneeds(release-test-job=False | goreleaser-needs=None). - "Added a
testjob (build/vet/test/gofmt, matchingtest.yml) thatgoreleasernow needs" — confirmed. At head,release-test-job=True | goreleaser-needs=test, and the job's step list compares equal totest.yml's step list — the four commands and thecheckout/setup-gopreamble match exactly, not approximately. - "
just releasechecks version.txt/clean-tree/tag-existence but not CI status" — confirmed.Justfilelines 103–110: version regex,git status --porcelain,version.txtequality, andgit rev-parse "v{{VERSION}}". Nogh run listor any other CI query. (I also checked thegit rev-parse … && { exit 1; }line for aset -einteraction that would let a duplicate tag slip through — it behaves correctly; no issue there.) - "Same gap unidoc-alip's age-plugin-sshagent review caught (F2), also present here" — confirmed, and the fix mirrors it faithfully. That review's F2 on
unidoc/age-plugin-sshagent#1describes the identical trigger mismatch and recommends "a gate in the workflow itself, so it holds regardless of how the tag was created," with an inlinetestjob andneeds: test— structurally what landed here, adapted to this repo's four commands rather than that repo'sageapt dependency and barego test. Its alternative suggestion (querygh run listfrom thereleaserecipe) was correctly not taken; the workflow-level gate is the stronger of the two. Note that PR is still open, so this repo gets the fix first. - "
go build/vet/test/gofmtclean (verified locally, CI will confirm)" — partially confirmed, and worth being precise about. The single passing check on this PR istest.yml's job, fired bypull_request. It confirms the repo passes those four commands. It does not exercise anything this PR adds: the newrelease.ymltestjob and theneeds: testedge only fire on av*tag push, so as of this review they have never executed. The first run of the code under review will be the next real release. That is the residual risk, and it is why I linted all three variants withactionlint(clean) rather than relying on the green check. - "Merge, then tag/release as normal —
goreleaserwill now wait ontest" — confirmed by static analysis, not by execution.needs: testis correctly wired andactionlintaccepts the file; no tag was pushed during this review.
Appendix — how this was checked
poc_2_release_gate.py parses the real workflow files — copied verbatim out of git at
master (base), pr-2-review (head), and a workflow_call refactor (fixed) — and asserts a
single joined outcome string per variant:
[PASS] base: test.yml-tag-trigger=False | release-on-tags=['v*'] | release-test-job=False | goreleaser-needs=None | no-test-job
[PASS] head: test.yml-tag-trigger=False | release-on-tags=['v*'] | release-test-job=True | goreleaser-needs=test | inline-match
[PASS] fixed: test.yml-tag-trigger=False | release-on-tags=['v*'] | release-test-job=True | goreleaser-needs=test | reused:./.github/workflows/test.yml
Base reproduces the gap; head closes it; the F1 refactor closes it too and keeps step parity
by construction. Head, the F1 refactor and the F2 permissions variant were each additionally
linted with actionlint under a real .github/workflows/ layout — all clean.
The script, so you can re-run it yourself:
import os, sys, yaml
def outcome(d):
t = yaml.safe_load(open(os.path.join(d, "test.yml")))
r = yaml.safe_load(open(os.path.join(d, "release.yml")))
# PyYAML parses a bare `on:` key as boolean True (YAML 1.1). Handle both.
ton, ron = t.get("on", t.get(True)), r.get("on", r.get(True))
push = ton.get("push")
test_tag_trigger = "tags" in push if isinstance(push, dict) else False
jobs = r["jobs"]
has_test = "test" in jobs
if has_test and "steps" in jobs["test"]:
parity = "inline-match" if jobs["test"]["steps"] == t["jobs"]["test"]["steps"] else "inline-DRIFT"
elif has_test:
parity = "reused:" + str(jobs["test"].get("uses"))
else:
parity = "no-test-job"
return " | ".join([
f"test.yml-tag-trigger={test_tag_trigger}",
f"release-on-tags={(ron.get('push') or {}).get('tags')}",
f"release-test-job={has_test}",
f"goreleaser-needs={jobs.get('goreleaser', {}).get('needs')}",
parity,
])
# each dir holds a release.yml + test.yml copied verbatim out of git
for v in ("base", "head", "fixed"):
print(f"{v}: {outcome(os.path.join(sys.argv[1], v))}")Save that as poc_2_release_gate.py, then build the three variants from git and run it. This
block is copy-pasteable from the repo root and was run as-is to produce the output above:
git fetch origin pull/2/head:pr-2-review
mkdir -p poc/base poc/head poc/fixed
for f in release test; do
git show master:.github/workflows/$f.yml > poc/base/$f.yml
git show pr-2-review:.github/workflows/$f.yml > poc/head/$f.yml
done
# `fixed` = head with the F1 refactor applied
sed 's|^ pull_request:$| pull_request:\
workflow_call:|' poc/head/test.yml > poc/fixed/test.yml
awk '/^ test:$/{print " test:"; print " uses: ./.github/workflows/test.yml"; skip=1; next}
skip && /^ goreleaser:$/{skip=0}
!skip{print}' poc/head/release.yml > poc/fixed/release.yml
pip install pyyaml
python3 poc_2_release_gate.py pocTo reproduce the actionlint half, give each variant a real workflow layout — otherwise
actionlint cannot resolve the uses: ./.github/workflows/test.yml path and its clean exit
means nothing:
for v in head fixed; do
mkdir -p poc/$v/.github/workflows && cp poc/$v/*.yml poc/$v/.github/workflows/
(cd poc/$v && go run github.com/rhysd/actionlint/cmd/actionlint@latest)
doneThe gofmt exit-code point in F1 stands alone:
bash -c 'gofmt -l /nonexistent | tee /tmp/fmt.out && test ! -s /tmp/fmt.out'; echo $? # 0
bash -c 'set -o pipefail
gofmt -l /nonexistent | tee /tmp/fmt.out && test ! -s /tmp/fmt.out'; echo $? # 2
bash -c 'test -z "$(gofmt -l /nonexistent)"'; echo $? # 0Caveats, so nobody over-reads this: the harness models the workflow graph, not GitHub's
scheduler. It establishes that goreleaser declares a dependency on a test job and that
test.yml cannot be triggered by a tag — it does not prove that a failing test job actually
blocks goreleaser at runtime, which is documented GitHub behaviour rather than something
verified here. It also does not model branch protection, GITHUB_TOKEN scoping, or goreleaser
itself. F2 is source-read only. Nothing was tagged, pushed, or published during this review,
and the working tree was not switched to the PR branch — the head was read via
git fetch origin pull/2/head:pr-2-review and git show.
F1 [should-fix] — the test job in release.yml was a verbatim copy of
test.yml's, with nothing keeping them in sync; the next change to the
CI recipe would land in test.yml (what people see on PRs) and
release.yml would silently start gating releases on a weaker check.
Added `workflow_call:` to test.yml's triggers and replaced the inline
job in release.yml with `uses: ./.github/workflows/test.yml`, so
there is exactly one copy. Also folded in the related point: the
gofmt step's `| tee ... && test ! -s ...` pipeline reported the exit
code of `tee`, not `gofmt`, and GitHub Actions runs unspecified-shell
`run:` steps as `bash -e {0}` without `-o pipefail` — a gofmt crash
(not just files needing formatting) would have passed silently.
Confirmed the gap and the fix locally:
$ bash -c 'gofmt -l /nonexistent | tee /tmp/fmt.out && test ! -s /tmp/fmt.out'; echo $?
0
$ bash -o pipefail -c 'gofmt -l /nonexistent | tee /tmp/fmt.out && test ! -s /tmp/fmt.out'; echo $?
2
Fixed by naming the step and adding `shell: bash`, which GitHub runs
as `bash --noprofile --norc -eo pipefail {0}` — confirmed this is the
actual documented difference (unspecified vs. explicit `shell: bash`),
not an assumption.
F2 [nit] — `contents: write` was declared at workflow level, so it
applied to the new `test` job too (arbitrary project/dependency code
running with a token that can push and create releases), when only
`goreleaser` needs it. Moved to the `goreleaser` job only; `test` now
inherits the default `contents: read`.
Verified `actionlint` clean against both files in place (not a copy),
confirming `uses: ./.github/workflows/test.yml` actually resolves.
go build/vet/test/gofmt clean.
|
Addressed both. F1 [should-fix] — confirmed the drift risk and took the F2 [nit] — confirmed, moved go build/vet/test/gofmt clean. |
Re-review of F1 [resolved] —
|
Same bug fixed in age-plugin-sshagent's release-pr: writing
version.txt unconditionally and committing means a bump to a version
version.txt already carries (true for this repo's own pending 0.1.0
release) is a no-op — git commit exits 1, set -euo pipefail aborts
after the release branch is already checked out, and the recipe
leaves you stranded on a stray local branch with no PR opened.
Fixed with a guard right after git fetch: refuse with a clear message
("nothing to bump; run: just release VERSION") before touching
anything, plus a trap that returns to master and deletes the stray
branch on any later failure, so the recipe is re-runnable.
Verified with the same PoC methodology used for age-plugin-sshagent's
fix: a scratch clone against a local bare origin, gh stubbed. Refusal
case (release-pr 0.1.0, matching master's current version.txt) exits
1 and stays on master with no stray branch; normal-bump case
(release-pr 0.2.0) commits, pushes, and opens the PR as expected.
Practical effect for today's first release: `just release-pr 0.1.0`
would have hit this immediately, since version.txt already carries
0.1.0. The first release skips release-pr entirely — merge this PR,
then run `just release 0.1.0` directly. release-pr is exercised for
real starting with the next bump (0.1.1+).
|
Also pushed a second, unrelated fix while getting ready to cut today's release: |
The previous fix for F2 (contents:write scoped too broadly) deleted release.yml's workflow-level permissions block instead of downgrading it to read. Per GitHub's reusable-workflow docs, permissions can only be reduced through a workflow_call chain, never elevated — the caller sets the ceiling. Omitting the block entirely does not mean read-only, it falls back to the repository's default GITHUB_TOKEN permissions, which this repo has set permissively (confirmed from the actual workflow run: 17 write scopes, not 1). Restored `permissions: contents: read` at workflow level in release.yml (ceiling for both jobs, including the called test.yml), and added the same to test.yml per the review's suggestion — that also covers test.yml's own direct push/pull_request triggers, which release.yml's ceiling alone can't reach and which is where the 17-scope token was actually observed. goreleaser's existing job-level `contents: write` grant is unaffected — a job-level grant can only narrow further within the workflow ceiling, and read->write within the same scope the ceiling already allows is not an elevation. Verified: actionlint clean on both files in place, go build/vet/test/ gofmt clean.
|
F2 [should-fix, reopened] — confirmed exactly as described, and confirmed against your run-log evidence (17 write scopes is a real problem, and a worse one than the original nit). My mistake was deleting the workflow-level block rather than downgrading it — I hadn't internalized that omitted ≠ read-only for
Thanks for catching this with the actual run log rather than just the diff — I would not have caught the "deleted vs. downgraded" distinction from reading the YAML alone. |
unidoc-alip
left a comment
There was a problem hiding this comment.
Verdict: APPROVE — 0 must-fix, 1 should-fix (F3, new, non-blocking), 1 nit (F4, new)
Re-review of 49e4b00. F2 is fixed exactly as specified and I have nothing further on it —
that thread is closed. The subject of this PR — the release test gate and the permissions
ceiling — is correct and verified, so this is an approval.
Two new findings, both against a36f8af, an unrelated Justfile change that arrived in the
same push and wasn't mentioned in the reply. F3 is a real reproduction, not a reading: the trap
added to make release-pr re-runnable makes it permanently un-re-runnable at the one failure
point that matters most. I'm not blocking on it, because it cannot bite the release this PR is
clearing the way for: version.txt on master is already 0.1.0 and no tags exist, so
a36f8af's own new guard refuses release-pr 0.1.0 by design and today's path is
just release 0.1.0 directly. F3 first becomes reachable at 0.1.1. Please fix it before
then, in this PR or a follow-up. Continuing the F1/F2 keys from the earlier comments.
F2 [resolved] — permissions ceiling restored correctly in both files
permissions: contents: read at workflow level in release.yml (ceiling for both jobs,
including the called workflow), the same in test.yml (covering the direct
push/pull_request triggers where the wide token was actually observed), goreleaser's
job-level contents: write untouched. That is the shape I proposed and the reasoning in the
comments on both blocks is accurate. actionlint clean on both files under a real
.github/workflows/ layout at 49e4b00.
F3 [should-fix] Justfile line 89 — the new trap wedges release-pr permanently if gh pr create fails
a36f8af's stated goal is "so the recipe is re-runnable." For the failure the trap was added
to handle it achieves the opposite, and this is a regression against the behaviour before the
commit.
The trap is armed before git checkout -b and disarmed only after gh pr create succeeds. So
it is still armed across git push -u origin, which means the window it covers includes the
point where the remote branch already exists. If gh pr create fails there — expired auth, an
API blip, a PR already open — the trap deletes the local branch and leaves the remote
one. Every subsequent run then dies on a non-fast-forward push, because the fresh local commit
has a different SHA from the pushed one, and the trap deletes the local branch again. The
recipe cannot recover on its own.
Reproduced against 49e4b00's Justfile in a scratch clone with a local bare origin and gh
stubbed to fail (harness in the appendix):
=== CASE B: bump 0.2.0, gh pr create FAILS ===
gh: stub failing for pr create --title Release v0.2.0 ...
Deleted branch release/v0.2.0 (was 585e159).
local =[master ]
remote =[master release/v0.2.0 ]
=== CASE B2: re-run the same command ===
error: failed to push some refs to '.../origin.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g. 'git pull ...')
Deleted branch release/v0.2.0 (was a657e82).
local =[master ]
remote =[master release/v0.2.0 ]
Note the second run is identical to the first — this repeats forever. The error surfaced is
git's, not the recipe's, and its git pull hint is actively misleading: following it would
merge the release branch's history into whatever you are on. Recovery requires knowing to run
git push -d origin release/v0.2.0 by hand, which nothing tells you.
Before a36f8af, the same gh failure left you standing on the pushed local branch, where
gh pr create by hand finished the job. Loud failure, no data loss, one-command recovery —
which is why this is should-fix rather than must-fix — but the fix inverted it.
Two changes fix it. Disarm the trap at the point of no return rather than at the end, and give
the failure a recovery hint:
git push -u origin "release/v{{VERSION}}"
trap - EXIT # past the point of no return: the remote branch exists, keep the local one
gh pr create --title "Release v{{VERSION}}" \
--body "..." \
|| { echo "✗ branch pushed but PR creation failed — finish with: gh pr create --head release/v{{VERSION}}"; exit 1; }and guard the remote branch alongside the new version.txt guard, so a re-run explains itself
instead of handing you a git hint:
git ls-remote --exit-code --heads origin "release/v{{VERSION}}" >/dev/null 2>&1 && \
{ echo "✗ release/v{{VERSION}} already on origin — open the PR with: gh pr create --head release/v{{VERSION}} (or delete it: git push -d origin release/v{{VERSION}})"; exit 1; }Deliberately not deleting the remote branch in the trap: a PR may already be attached to it,
and a cleanup path that deletes pushed work is worse than the wedge.
I ran that variant through all four cases:
FIXED / CASE B : ✗ branch pushed but PR creation failed — finish with: gh pr create --head release/v0.2.0
ended-on=release/v0.2.0, local=[master release/v0.2.0], remote=[master release/v0.2.0]
FIXED / CASE B2: ✗ release/v0.2.0 already on origin — open the PR with: gh pr create --head ... (or delete it: git push -d origin ...)
FIXED / CASE A : ✗ version.txt on master is already 0.1.0 — nothing to bump; run: just release 0.1.0
FIXED / CASE D : ✓ release PR opened — ended-on=release/v0.2.0 commits=1 version=0.2.0 remote has the branch
The new version.txt guard and the happy path are both unaffected.
F4 [nit] a36f8af is unannounced scope in a workflow-permissions PR
The PR is titled "release.yml: gate goreleaser on tests passing" and its description covers
only that. a36f8af changes release-pr, which is release-critical tooling, and it is not in
the description or in the reply. It is a real bug with a good fix — the guard works exactly as
the commit message claims, verified below — so this is about visibility, not merit: either
extend the PR description to cover it, or split it into its own PR. Worth doing today given
0.1.0 is imminent. (No documentation impact: grep -rn 'release-pr' README.md docs/ returns
nothing, so the commit message's "the first release skips release-pr entirely" contradicts
no written instructions.)
Reply and commit-message verification
- "
permissions: contents: readrestored at workflow level inrelease.yml(ceiling for both jobs)" — confirmed in the diff, with an accurate explanatory comment. - "added the same to
test.ymlsince that's where the wide token was actually observed" — confirmed, and this is the right call for the reason given. - "
goreleaser's job-levelcontents: writegrant is unaffected" — confirmed. - "
actionlintclean on both files in place" — confirmed independently at49e4b00under agit init-ed layout. a36f8af: "refuse with a clear message before touching anything" — confirmed.just release-pr 0.1.0against a master already at0.1.0exits 1, prints the intended message, and leaves you onmasterwith no stray branch and a clean tree.a36f8af: "plus a trap that returns to master and deletes the stray branch on any later failure, so the recipe is re-runnable" — partially confirmed, and this is F3. The return-to-master and branch-deletion both work. "Re-runnable" holds only for failures beforegit push; after the push it is the opposite.a36f8af: "normal-bump case (release-pr 0.2.0) commits, pushes, and opens the PR as expected" — confirmed. One commitRelease v0.2.0,version.txt=0.2.0, remote branch created,gh pr createinvoked, trap correctly disarmed so the branch survives and you are left on it.- PR description as of
49e4b00— incomplete. Still describes only therelease.ymltest gate; covers neither the permissions work nora36f8af.
Appendix — the release-pr harness
Scratch clone against a local bare origin with gh stubbed. Touches no network and no real
remote. Run from anywhere:
W=$(mktemp -d); mkdir -p $W/stub
git init -q --bare $W/origin.git
git init -q $W/seed && cd $W/seed
git config user.email t@t && git config user.name t
git -C /path/to/incus-sync show pr-2-review:Justfile > Justfile
echo "0.1.0" > version.txt
git add -A && git commit -qm init && git branch -M master
git remote add origin $W/origin.git && git push -q -u origin master
cd $W && git clone -q origin.git work && cd work
git config user.email t@t && git config user.name t
# gh stub — flip between failing and succeeding to select the case
printf '#!/bin/sh\necho "gh: stub failing" >&2\nexit 1\n' > $W/stub/gh && chmod +x $W/stub/gh
# CASE A guard: no-op bump is refused
PATH=$W/stub:$PATH just release-pr 0.1.0
# CASE B the bug: gh fails after push -> local deleted, remote survives
PATH=$W/stub:$PATH just release-pr 0.2.0
git branch; git --git-dir=$W/origin.git branch
# CASE B2 the wedge: re-run dies on non-fast-forward, forever
PATH=$W/stub:$PATH just release-pr 0.2.0
# CASE D happy path: swap the stub to exit 0 first
printf '#!/bin/sh\necho "gh: (stub) PR created"\n' > $W/stub/gh && chmod +x $W/stub/ghOne harness artifact worth flagging, since it cost me a run: when testing the fixed variant,
editing Justfile in the clone makes the tree dirty and the recipe's own clean-tree check
fires first, so every case fails with "working tree not clean" rather than exercising the
change. Commit the edit in the scratch clone before running.
Caveats: the harness models the local git and gh invocation sequence only. It does not model
GitHub-side PR creation, protected-branch push rejection, or auth. It establishes what the
recipe does locally up to and past the point of failure, which is where F3 lives. The
workflow-file half of this review is unchanged from the previous pass: the tag path has still
never executed, and nothing was tagged, pushed or published. The working tree of the real repo
was not switched to the PR branch.
a36f8af's trap was armed before git checkout -b and disarmed only after gh pr create succeeded — still armed across git push, so a failure in gh pr create (expired auth, an API blip, a PR already open) deleted the local release branch while the remote one, already pushed, survived. Every re-run then either died on a non-fast-forward push (different commit SHA, same branch name) or silently produced "Everything up-to-date" while deleting the local branch again — no path forward without knowing to run `git push -d origin release/vX.Y.Z` by hand first. The trap's stated goal was making the recipe re-runnable; for this exact failure it was the opposite, permanently so. Reproduced against the actual bug first (scratch clone, local bare origin, gh stubbed to fail after a real push succeeds): local branch deleted, remote branch orphaned, identical on every retry. Fixed as suggested: disarm the trap right after the push succeeds (the actual point of no return — the remote branch exists from here on, so deleting the local one is harmless but recreating it isn't), and give a failed gh pr create a direct recovery hint instead of relying on the trap. Also added a remote-branch-exists guard next to the version.txt guard, so a re-run after a failure explains itself ("already on origin — finish with...") instead of surfacing a confusing git-level rejection. Re-ran all four cases from the review's own harness against the actual fixed Justfile: no-op-bump refusal, gh-fails-after-push (branch survives, clear message), re-run-after-that (clean guard message, no git error), and the normal happy path — all four match the review's expected output exactly. Same bug existed in age-plugin-sshagent's Justfile (same trap, copied from here originally) — fixed there too in a separate PR, since #1 there is already merged. go build/vet/test/gofmt clean.
|
F3 [should-fix] — confirmed exactly as described, and reproduced it first against the actual bug (scratch clone, local bare origin, Also fixed the identical bug in age-plugin-sshagent's Justfile (same trap, originally copied from there to here) — separate PR, since #1 there is already merged. F4 [nit] — fair, updated the PR description to actually cover the Justfile work instead of just the original release.yml scope. go build/vet/test/gofmt clean. |
unidoc-alip
left a comment
There was a problem hiding this comment.
Verdict: APPROVE — 0 must-fix, 0 should-fix, 0 nits. F1–F4 all resolved.
Re-review of ce50055 against the F3/F4 review of 49e4b00. Both are fixed, and the reply's
claims check out on every point I could verify in this repo.
F3 [resolved] — release-pr no longer wedges after a failed gh pr create
ce50055 implements all three suggested changes, verbatim and with nothing omitted:
trap - EXITmoved to immediately aftergit push -u origin, i.e. the actual point of no
return, instead of aftergh pr create.gh pr creategained the|| { echo "✗ branch pushed but PR creation failed — finish with: gh pr create --head release/v{{VERSION}}"; exit 1; }recovery hint.- The
git ls-remote --exit-code --headsguard sits alongside theversion.txtguard, before
anything is touched.
The trap still deliberately does not delete the remote branch, which is the right call for the
reason given in the earlier review — a PR may already be attached to it.
I re-ran the four-case harness from scratch against the real ce50055 Justfile (own bare
origin, own gh stub, Justfile committed in the scratch clone so the recipe's clean-tree
check doesn't pre-empt the cases). All four match the expected output, including the
ending-branch detail:
CASE B ✗ branch pushed but PR creation failed — finish with: gh pr create --head release/v0.2.0
ended-on=release/v0.2.0 local=[master release/v0.2.0] remote=[master release/v0.2.0]
CASE B2 ✗ release/v0.2.0 already on origin — open the PR with: gh pr create --head … (or delete it: git push -d origin …)
no non-fast-forward, no git-level error
CASE A ✗ version.txt on master is already 0.1.0 — nothing to bump; run: just release 0.1.0
CASE D ✓ release PR opened — gh invoked, one commit, remote branch created, left on the branch
Case B2 is the load-bearing one: it previously repeated the wedge indefinitely and surfaced
git's misleading git pull hint; it now exits on the recipe's own message before touching git.
F4 [resolved] — PR description now covers the Justfile work
The description names both Justfile changes and the permissions ceiling, and the
title-vs-scope gap is closed by the "grew during review into the full release-tooling pass"
framing. The test plan also carries the operationally useful note that 0.1.0 ships via
just release 0.1.0 directly, so release-pr's guards are first exercised for real at
0.1.1.
F1 / F2 — still correct at head
workflow_call dedup and the gofmt pipefail fix are unchanged, and 49e4b00's permissions
ceiling is intact: permissions: contents: read at workflow level in both release.yml and
test.yml, goreleaser's job-level contents: write untouched.
Reply verification
- "Fixed exactly as suggested — trap disarms right after the push … recovery command … remote-branch-exists guard" — confirmed, all three, verbatim.
- "Ran your own four-case harness … all match your expected output" — confirmed independently, output above.
- "reproduced it first against the actual bug" — consistent; the commit message matches the failure mode demonstrated in the previous review. I re-ran only the fixed variant this pass, not the broken one.
- "go build/vet/test/gofmt clean" — confirmed; the
testcheck once50055is green. - "Also fixed the identical bug in age-plugin-sshagent's Justfile — separate PR" — unverified, out of this repo; not looked at.
Caveats unchanged from the previous passes: the harness models the local git and gh
invocation sequence only, not GitHub-side PR creation, auth or protected-branch rejection. The
tag path in release.yml has still never executed — nothing was tagged, pushed or published,
and the working tree of the real repo was not switched to the PR branch.
Ship it. For the first release, merge and then run just release 0.1.0 directly, as the test
plan says.
Started as: gate
release.yml'sgoreleaserjob on tests passing —a tag push had no relation to
test.yml, so binaries could publishfrom a commit whose tests never ran. Grew during review into the
full release-tooling pass unidoc-alip's review surfaced:
release.yml/test.yml:testjob thatgoreleaserneeds,deduplicated via
workflow_call(not copy-pasted), gofmt step'spipefailgap fixed, permissions ceiling correctly set toreadat workflow level (not just omitted — omitted falls back to this
repo's permissive default token, which was a worse regression than
the thing being fixed).
Justfile:release-prrefuses cleanly when there's nothing tobump (same bug independently found in age-plugin-sshagent's
identical recipe), and no longer wedges itself if
gh pr createfails after the branch is already pushed.
Test plan
go build/vet/test/gofmtclean (verified locally, CI confirms)just release 0.1.0directly — version.txt already carries 0.1.0, sorelease-prhas nothing to bump for this first release; the next real bump (0.1.1+) is the first live exercise ofrelease-pr's guards