Skip to content

feat(action): verify the workflow lockfile with gh actions-lock --verify, on by default - #594

Open
Exypte wants to merge 1 commit into
mainfrom
feature/590-action-verify-lockfile
Open

Exypte wants to merge 1 commit into
mainfrom
feature/590-action-verify-lockfile

Conversation

@Exypte

@Exypte Exypte commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What type of PR is this?

feat

What this PR does / why we need it:

The Plumber action now runs gh actions-lock --verify on the checked-out repository, on by default, so users move to GitHub workflow lockfiles.

  • New step "Verify workflow lockfile", before the analysis. It checks for the lockfile first, then records a status (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-fail doesn't mask a failed verification.
  • A repository without .github/workflows/actions.lock gets a warning, with the commands to create one and the opt-out, and the job continues. Nothing is installed in that case.
  • Skipped with a warning when project is set (no checkout to verify) or when github-url is a GitHub Enterprise Server host (gh-actions-lock supports github.com and *.ghe.com only).
  • The job summary gets a "Workflow lockfile" line.
  • New inputs: verify-lockfile (default true) and actions-lock-version (default 0.4.1). The version has no v because scripts/release-bump-version.sh rewrites every default: "vX.Y.Z" line in action.yml; a test now guards it.
  • README: the lockfile check, how to create the lockfile, the opt-out.

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. --verify checks all of them (e2e cases c8 and c9 below).

Which issue(s) this PR is related to:

Fixes #590

Special notes for your reviewer:

Does this PR introduce a user-facing change?

The Plumber action now verifies .github/workflows/actions.lock with `gh actions-lock --verify` and fails the job when the lockfile doesn't verify (soft-fail does not mask it). A repository without a lockfile gets a warning and the job continues. Create the lockfile with `gh extension install github/gh-actions-lock` then `gh actions-lock`, and commit it, or set `verify-lockfile: false` to opt out. New inputs: verify-lockfile, actions-lock-version.

How was this tested?

  • go test ./cmd/... passes, including the new TestActionMissingLockfileOnlyWarns, which pins the warning, the recorded statuses and the Enforce gate cases in action.yml. It fails when status missing is changed to status failed.
  • bash scripts/release-bump-version.test.sh passes, including the new actions-lock-version check and the run against the real action.yml.
  • shellcheck is clean on the new step and the changed Job summary and Enforce gate scripts.
  • Local run of the real run: blocks: a missing lockfile warns and records missing. Enforce gate exits checked for missing, passed, skipped, failed, error and no status, with soft-fail on and off where it matters. A low score still fails the job when the lockfile is missing.
  • E2E on GitHub Actions in getplumber-examples/cli-working-lab, one branch per case.

All cases ran on this PR's exact action.yml (branch 590-final-action, same blob as the PR head), with soft-fail: true unless noted:

Case Result
590-f-missing (no lockfile, soft-fail: false, threshold: 0) ✅ warning annotation, job passes
590-f-valid ✅ "All 1 workflow valid"
590-f-opt-out (verify-lockfile: false) ✅ step skipped
590-f-project ✅ skip warning
590-f-bad-version ❌ "Could not install gh-actions-lock v9.9.9"
590-f-other-tampered (another workflow's commit tampered) ❌ "locked commit 0123456789ab is not in actions/setup-node's history"
590-f-other-unlocked (another workflow not in the lockfile) ❌ "Not pinned actions/setup-node@v4"
590-f-tampered (running workflow) ❌ the runner fails it at Set up job, before the action runs
590-f-stale (running workflow) ❌ GitHub refuses to start the run (startup_failure)

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

Comment thread action.yml Resolved
Comment thread action.yml Resolved
@Exypte
Exypte force-pushed the feature/590-action-verify-lockfile branch from ffdaa24 to 13b7495 Compare November 5, 2026 09:21
@Exypte Exypte changed the title feat(action)!: verify the workflow lockfile with gh actions-lock --verify, on by default feat(action): verify the workflow lockfile with gh actions-lock --verify, on by default Nov 5, 2026
Comment thread action.yml Resolved
Comment thread cmd/action_template_test.go Resolved
@Exypte
Exypte force-pushed the feature/590-action-verify-lockfile branch from 13b7495 to dfc18de Compare November 5, 2026 09:46
Comment thread action.yml Resolved
Comment thread cmd/action_template_test.go Resolved
Comment thread action.yml Resolved
…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>
@thomasboni
thomasboni force-pushed the feature/590-action-verify-lockfile branch from 68101a9 to 638dc70 Compare November 24, 2026 09:23
Comment thread action.yml
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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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
fi

status 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 install exits non-zero → the code records status error → Enforce gate exits 1 with "The workflow lockfile could not be verified", failing a job whose lockfile is actually valid, and soft-fail cannot 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
fi

or 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) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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" ;;
esac

Concrete 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 ⚠️ — mirroring the structural assertions already made against the Enforce gate.

Control: .github/claude-prompts/test-coverage.md · resolve this conversation once addressed.

@Exypte Exypte assigned Exypte and unassigned thomasboni Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plumber action: verify the caller's workflow lockfile with gh actions-lock --verify (on by default)

2 participants