Skip to content

fix(check): gracefully skip workflows without pinned dependencies - #6

Merged
nodeselector merged 1 commit into
mainfrom
ns/skip-unpinned-workflows
Apr 23, 2026
Merged

fix(check): gracefully skip workflows without pinned dependencies#6
nodeselector merged 1 commit into
mainfrom
ns/skip-unpinned-workflows

Conversation

@nodeselector

@nodeselector nodeselector commented Apr 23, 2026

Copy link
Copy Markdown
Collaborator

What

Gracefully handle workflow files that have no pinned dependencies during check, instead of spamming [ERROR] for each one.

Why

When running gh actions-pin check in a repo with many workflows, files without a dependencies: section produce noisy error output:

error: [ERROR] .github/workflows/vendor-firmware.yml: no dependencies: section found -- run `gh actions-pin --write` first
error: [ERROR] .github/workflows/vendor-xcode-release.yml: no dependencies: section found -- run `gh actions-pin --write` first

These aren't errors — they're either not-yet-pinned files (actionable) or run-only workflows (nothing to do). Treating them as errors fails the check and obscures real validation failures.

How

Three-tier handling based on workflow content:

Scenario Behavior
No uses: directives (run-only) Skip silently — nothing to pin
Has uses: but no dependencies: section Skip with guidance: "not yet pinned (run `gh actions-pin --write` first)"
Has dependencies: section Validate normally

Also fixes duplicate error printing: validateOneFile errors were printed inline AND again in the aggregate error loop. Now the aggregate loop skips ERROR-type entries that were already printed.

Skipped files surface as warnings in JSON output so CI consumers can see what was skipped without failing the check.

Risk

Aspect Assessment
Blast radius --check behavior change: previously-failing repos may now pass
Reversibility 🟢 Easy revert
Rollback plan Revert commit
Dependencies None

Testing

  • All existing unit and command tests pass
  • Validated manually that run-only workflows skip silently

Three tiers of handling for workflows discovered by --check:
- No uses: directives at all (run-only) → skip silently
- Has uses: but no dependencies: section → skip with guidance
- Has dependencies: section → validate normally

Also fixes duplicate error printing in aggregate output and surfaces
skipped files as warnings in JSON output for CI consumers.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 22:49
@nodeselector
nodeselector merged commit 90e6937 into main Apr 23, 2026
5 of 6 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the gh actions-pin check command to reduce noisy failures by treating workflows without pinned dependencies as “skipped” (rather than hard errors), while still validating workflows that contain a dependencies: lock section. It also aims to eliminate duplicate human-readable error printing and to surface skipped files as warnings in JSON output.

Changes:

  • Introduces sentinel errors to classify “no dependencies section” vs “no action references” and uses them to skip certain workflows during check.
  • Adds JSON warnings (and human-readable “skipping …” output) for workflows that appear unpinned.
  • Changes human-readable printing to avoid printing ERROR entries twice (inline + aggregate).
Show a summary per file
File Description
root.go Implements skip logic for unpinned/run-only workflows during check, adjusts output behavior, and refactors error printing to reduce duplication.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 3

Comment thread root.go
Comment on lines +716 to +720
refs, _, _ := wf.ExtractActionRefs()
if len(refs) == 0 {
return nil, errNoActions
}
return nil, errNoDeps
Comment thread root.go
Comment on lines +365 to +377
if errors.Is(err, errNoActions) {
// Workflow has only run: steps, no actions to pin — skip silently.
continue
}
if errors.Is(err, errNoDeps) {
if opts.JSONFields != "" {
aggregate.Warnings = append(aggregate.Warnings,
fmt.Sprintf("%s: not yet pinned (run `gh actions-pin --write` first)", workflowPath))
} else {
fmt.Fprintf(os.Stderr, "skipping %s: not yet pinned (run `gh actions-pin --write` first)\n", workflowPath)
}
continue
}
Comment thread root.go
Comment on lines +409 to +419
// Print errors and warnings in human-readable mode.
// Skip ERROR entries — those were already printed inline when validateOneFile returned an error.
for _, e := range aggregate.Errors {
if e.Type == "ERROR" {
continue
}
fmt.Fprintf(os.Stderr, "error: [%s] %s: %s\n", e.Type, e.Dependency, e.Details)
}
for _, w := range aggregate.Warnings {
fmt.Fprintf(os.Stderr, "warning: %s\n", w)
}

Copilot AI commented Apr 23, 2026

Copy link
Copy Markdown

Warning

This is an internal experiment to assess Copilot's ability to auto-approve PRs. Please 👍 this comment if the assessment below is correct and 👎 if not. Feedback in #f-ccr-auto-approve is appreciated!

Copilot thinks this PR is not ready to approve — see review comments for details.

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.

2 participants