Repository navigation
Conversation
ffdaa24 to
13b7495
Compare
13b7495 to
dfc18de
Compare
…ify, on by default The action runs `gh actions-lock --verify` on the checked-out repository before the analysis. A failed verification fails the job, and soft-fail does not mask it. A repository without .github/workflows/actions.lock gets a warning with the commands to create one, and the job continues. The step is skipped with a warning when project is set (no checkout) or on GitHub Enterprise Server, which gh-actions-lock does not support. New inputs: verify-lockfile (default true) and actions-lock-version (default 0.4.1, written without the v so the release bump leaves it alone). TestActionMissingLockfileOnlyWarns pins the recorded statuses of every branch of the verify step (missing, skipped, error, passed, failed), the github.com pass-through, and that the Enforce gate checks the lockfile status before the exit code, so soft-fail can never mask it. Refs #590 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
68101a9 to
638dc70
Compare
| echo "::error::verify-lockfile is true but the gh CLI is not available on this runner. Install gh or set verify-lockfile: false." | ||
| status error; exit 0 | ||
| fi | ||
| if ! gh extension install github/gh-actions-lock --pin "v${LOCK_VERSION#v}"; then |
There was a problem hiding this comment.
🔴 Bug risks
Medium: the lockfile step runs gh extension install unconditionally and treats an "already installed" failure as status error, which fails the job on repeated runs on persistent self-hosted runners even when the lockfile verifies. (Medium)
The Verify workflow lockfile step always runs gh extension install github/gh-actions-lock --pin "v${LOCK_VERSION#v}" and treats any non-zero exit as a hard failure:
if ! gh extension install github/gh-actions-lock --pin "v${LOCK_VERSION#v}"; then
echo "::error::Could not install gh-actions-lock v${LOCK_VERSION#v}. Check actions-lock-version."
status error; exit 0
fistatus error is then turned into an unconditional job failure by the Enforce gate (action.yml:392), and the PR explicitly documents that soft-fail does not mask it.
Cross-run failure scenario (self-hosted / non-ephemeral runners): gh persists installed extensions under ~/.local/share/gh/extensions, which survives between jobs on a self-hosted runner that is not torn down after each job. gh extension install exits non-zero when an extension already provides that command (it reports "there is already an installed extension that provides the ... command"). So:
- Run 1 on the runner: extension not present → installs →
gh actions-lock --verify→status passed, job succeeds. - Run 2+ on the same runner: extension already present →
gh extension installexits non-zero → the code recordsstatus error→ Enforce gate exits 1 with "The workflow lockfile could not be verified", failing a job whose lockfile is actually valid, andsoft-failcannot override it.
This makes an idempotent operation (verify the committed lockfile) non-idempotent across runs: identical state yields success then failure depending on leftover runner state from a prior run. GitHub-hosted runners are unaffected (fresh each job), but self-hosted runners are a documented, common configuration.
Suggested fix: make the install idempotent — skip it when the command is already available, or ignore the "already installed" case. For example:
if ! gh actions-lock --version >/dev/null 2>&1; then
if ! gh extension install github/gh-actions-lock --pin "v${LOCK_VERSION#v}"; then
echo "::error::Could not install gh-actions-lock v${LOCK_VERSION#v}. Check actions-lock-version."
status error; exit 0
fi
fior fall back to gh extension upgrade actions-lock --pin "v${LOCK_VERSION#v}" when install fails because it is already present.
Control: .github/claude-prompts/bug-risks.md · resolve this conversation once addressed.
| t.Errorf("the gh-missing and install-failure branches must record status error, found %d", got) | ||
| } | ||
| for _, status := range []string{"status skipped", "status missing"} { | ||
| if strings.Contains(setup, status) { |
There was a problem hiding this comment.
🔴 Test coverage
The new Job summary status→message mapping (action.yml:318–324) is left entirely untested, so a regression that misreports lockfile verification status would ship silently. (Low)
This PR adds three new run: blocks to action.yml, and TestActionMissingLockfileOnlyWarns pins the shape of two of them — the Verify workflow lockfile step and the Enforce gate step. The third new block, the Job summary mapping at action.yml:318-324, has no test coverage. A grep over cmd/ confirms the only test reference to LOCKFILE_STATUS is the Enforce-gate case assertion (cmd/action_template_test.go:166); nothing asserts the summary arms.
The test's own doc comment says it "reads the shape of the file," yet it skips the summary arms that translate each status into user-facing text:
case "${LOCKFILE_STATUS:-}" in
passed) echo "**Workflow lockfile:** ✅ verified" ;;
failed) echo "**Workflow lockfile:** ❌ verification failed" ;;
missing) echo "**Workflow lockfile:** ⚠️ missing (.github/workflows/actions.lock)" ;;
skipped) echo "**Workflow lockfile:** ⚠️ skipped" ;;
error) echo "**Workflow lockfile:** ❌ could not run the verification" ;;
esacConcrete regression this lets through: an edit that swaps the passed/failed arms — or changes the failed)/error) arm to print the ✅ "verified" string — would make the job summary report the lockfile as verified when gh actions-lock --verify actually failed (or could not run). Because this block only writes $GITHUB_STEP_SUMMARY, the compile/YAML-parse steps and the existing tests all still pass, so the misreport ships unnoticed. The Enforce gate still fails the job (that path is tested), but the human-readable supply-chain verdict presented to reviewers would be wrong.
Suggested test: extend TestActionMissingLockfileOnlyWarns (or add a sibling) to cut out the Job summary step's case "${LOCKFILE_STATUS:-}" block and assert the five status→string pairings — specifically that the failed) and error) arms carry the ❌ marker (not ✅ "verified"), the passed) arm carries ✅ "verified", and missing)/skipped) carry
Control: .github/claude-prompts/test-coverage.md · resolve this conversation once addressed.
What type of PR is this?
feat
What this PR does / why we need it:
The Plumber action now runs
gh actions-lock --verifyon the checked-out repository, on by default, so users move to GitHub workflow lockfiles.passed,failed,missing,skipped,error) and never fails on its own: the Enforce gate step fails the job after SARIF and artifacts are uploaded.soft-faildoesn't mask a failed verification..github/workflows/actions.lockgets a warning, with the commands to create one and the opt-out, and the job continues. Nothing is installed in that case.projectis set (no checkout to verify) or whengithub-urlis a GitHub Enterprise Server host (gh-actions-lock supports github.com and *.ghe.com only).verify-lockfile(defaulttrue) andactions-lock-version(default0.4.1). The version has novbecausescripts/release-bump-version.shrewrites everydefault: "vX.Y.Z"line in action.yml; a test now guards it.Why it's needed even though GitHub enforces lockfiles: the runner only checks the workflow that is running. A tampered commit or a missing entry for any other workflow in the lockfile goes unnoticed until that workflow runs.
--verifychecks all of them (e2e cases c8 and c9 below).Which issue(s) this PR is related to:
Fixes #590
Special notes for your reviewer:
gh actions-lock --verify(on by default) #590: a missing lockfile warns instead of failing the job, so the PR is no longer a breaking change. The issue description is updated.gh extension install --pinprints "already installed" and keeps that version. Hosted runners start clean.Does this PR introduce a user-facing change?
How was this tested?
go test ./cmd/...passes, including the newTestActionMissingLockfileOnlyWarns, which pins the warning, the recorded statuses and the Enforce gate cases in action.yml. It fails whenstatus missingis changed tostatus failed.bash scripts/release-bump-version.test.shpasses, including the new actions-lock-version check and the run against the real action.yml.shellcheckis clean on the new step and the changed Job summary and Enforce gate scripts.run:blocks: a missing lockfile warns and recordsmissing. Enforce gate exits checked formissing,passed,skipped,failed,errorand no status, with soft-fail on and off where it matters. A low score still fails the job when the lockfile is missing.All cases ran on this PR's exact action.yml (branch
590-final-action, same blob as the PR head), withsoft-fail: trueunless noted:590-f-missing(no lockfile,soft-fail: false,threshold: 0)590-f-valid590-f-opt-out(verify-lockfile: false)590-f-project590-f-bad-version590-f-other-tampered(another workflow's commit tampered)590-f-other-unlocked(another workflow not in the lockfile)590-f-tampered(running workflow)590-f-stale(running workflow)AI usage disclosure:
YES. Claude Code wrote the change and ran the tests and the e2e under my direction; I reviewed it and am responsible for it.
🤖 Generated with Claude Code