Skip to content

Support sub-path actions and per-file emission in validate-action-pins#125

Merged
lex57ukr merged 2 commits intomainfrom
124-validate-action-pins-subpath-and-updates-dedup
Apr 20, 2026
Merged

Support sub-path actions and per-file emission in validate-action-pins#125
lex57ukr merged 2 commits intomainfrom
124-validate-action-pins-subpath-and-updates-dedup

Conversation

@lex57ukr
Copy link
Copy Markdown
Contributor

Summary

Restore classification and drift reporting for GitHub Actions referenced by sub-path (owner/repo/subpath@ref, e.g. Homebrew/actions/setup-homebrew), and change updates to emit one record per workflow file so operators can see every file that needs editing to take an upgrade. Routes diagnostic WARNs to stderr so structured plain/tsv output pipes cleanly.

Related Issues

Fixes #124

Changes

  • Add _action_repo() helper that trims an action reference to its containing owner/repo, and apply it at every API call site in cmd_check, cmd_updates, and cmd_list api_mode. Sub-path refs no longer 404 against /repos/... endpoints.
  • Switch cmd_updates from per-run dedup to per-file dedup mirroring cmd_check, with per-invocation updates_newer_cache / updates_head_cache so API cost stays one call per unique (repo, ref) pair. Drops the now-unused seen_in_run / _once_per_run.
  • Route preflight and missing-file WARNs to stderr across all three subcommands. Per-pin result WARNs in check (drift, unresolvable ref) stay on stdout — they're part of the result payload, not diagnostic output.
  • Refresh cmd_updates docstring and the updates section of the man page.
  • Add bats coverage: sub-path classification across check/list/updates, stale sub-path branch drift, multi-file updates emission, and _action_repo unit tests. 93/93 pass.

Further Comments

Verified end-to-end against knight-owl-dev/homebrew-tap workflows:

$ validate-action-pins list --only=branch .github/workflows/*.yml
ci.yml: Homebrew/actions/setup-homebrew@98cfa07b... (# main)
update-formula.yml: Homebrew/actions/setup-homebrew@98cfa07b... (# main)

$ validate-action-pins check .github/workflows/*.yml
OK  ci.yml: Homebrew/actions/setup-homebrew@98cfa07b984a... matches main
...
OK  update-formula.yml: Homebrew/actions/setup-homebrew@98cfa07b984a... matches main

$ validate-action-pins updates --only=branch --format=tsv .github/workflows/*.yml
.github/workflows/ci.yml\tHomebrew/actions/setup-homebrew\tmain\t\tbranch
.github/workflows/update-formula.yml\tHomebrew/actions/setup-homebrew\tmain\t\tbranch

Before the fix, all three returned empty output (or only the first file) for the Homebrew pin because the resolver 404'd on the sub-path.

lex57ukr and others added 2 commits April 19, 2026 23:07
…dates emission

Sub-path action references (owner/repo/path@ref, e.g. Homebrew/actions/setup-homebrew)
were passed whole to the GitHub REST API as /repos/<owner>/<repo>/..., which 404s.
Downstream: check reported "could not resolve ref", list --only=tag|branch filtered
them as unknown, and updates silently failed head_sha while still emitting classifications.
A new _action_repo helper trims to owner/repo and is applied at every API call site
in cmd_check, cmd_updates, and cmd_list api_mode.

cmd_updates switches from per-run dedup (one record per unique pin across all files)
to per-file dedup matching cmd_check, so a pin appearing in multiple workflows is
now reported for each file — operators can see every file that needs editing to take
an upgrade. API results are cached across files by (repo, ref) so the change adds no
request cost. The unused seen_in_run / _once_per_run machinery is removed.

Bats coverage: sub-path classification across check/list/updates, stale sub-path
branch drift, and multi-file updates emission.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Preflight failures (missing curl/jq, auth rejection, rate limit exhausted
or tight, connectivity loss, unexpected HTTP status) and missing-file WARNs
in cmd_check now write to stderr, matching the existing behaviour of
cmd_list and cmd_updates. Keeps structured plain/tsv output on stdout so
downstream pipes see only the per-pin result payload.

_emit_check WARN lines (ref drift, unresolvable ref) stay on stdout because
those are check's result, not diagnostic output.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lex57ukr lex57ukr added the bug Something isn't working label Apr 20, 2026
@lex57ukr lex57ukr merged commit 686c212 into main Apr 20, 2026
8 checks passed
@lex57ukr lex57ukr deleted the 124-validate-action-pins-subpath-and-updates-dedup branch April 20, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

validate-action-pins mishandles sub-path actions and dedups updates across files

1 participant