fix: harden GitHub Action version resolution#3
Closed
qartik wants to merge 9 commits into
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates actupdate’s resolver and CLI so exact semver action refs (e.g. @v3.0) can be upgraded to newer eligible tags within the same major (e.g. @v3.3), and ensures per-repo resolutions aren’t incorrectly reused across different refs during a single scan.
Changes:
- Add
ResolveLatestStableto resolve upgrades within the current major and still prefer moving major tags when a newer major is eligible. - Update the CLI scan/report flow to resolve per ref (removing the repo-level resolution reuse that caused incorrect behavior).
- Add regression tests covering mixed refs for the same repo (e.g.
pypa/cibuildwheel@v3.3and@v3.0) and same-major upgrade behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates documentation to describe “latest eligible stable version” behavior and moving-tag preference rules. |
| internal/github/client.go | Introduces ResolveLatestStable and same-major exact-tag upgrade detection logic. |
| internal/github/client_test.go | Adds unit tests for same-major upgrades and behavior with moving tags. |
| cmd/actupdate/main.go | Switches CLI resolution to ResolveLatestStable and removes repo-wide resolution caching across refs. |
| cmd/actupdate/main_test.go | Adds CLI regression test for mixed refs from the same repo in one workflow file. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+353
to
+359
| if candidates[i].HasMovingMinor { | ||
| eligible, err := c.tagEligible(ctx, repo, candidates[i].MovingMinor.Original, cutoff) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
| candidates[i].MovingMinorEligible = eligible | ||
| if eligible && !candidates[i].HasMovingMajor { |
Comment on lines
+82
to
+83
| - When a newer major exists, moving major tags such as `v6` are preferred over | ||
| exact tags such as `v6.2.1` |
Comment on lines
+645
to
+690
| func candidateFromState(major, state int) (majorCandidates, bool) { | ||
| candidate := majorCandidates{Major: major} | ||
| switch state { | ||
| case 0: | ||
| return majorCandidates{}, false | ||
| case 1: | ||
| candidate.MovingMajor = mustParseStableVersion(nil, fmt.Sprintf("v%d", major)) | ||
| candidate.HasMovingMajor = true | ||
| candidate.MovingMajorEligible = true | ||
| case 2: | ||
| candidate.MovingMajor = mustParseStableVersion(nil, fmt.Sprintf("v%d", major)) | ||
| candidate.HasMovingMajor = true | ||
| case 3: | ||
| candidate.Exact = mustParseStableVersion(nil, fmt.Sprintf("v%d.2.0", major)) | ||
| candidate.HasExact = true | ||
| candidate.ExactEligible = true | ||
| case 4: | ||
| candidate.Exact = mustParseStableVersion(nil, fmt.Sprintf("v%d.2.0", major)) | ||
| candidate.HasExact = true | ||
| case 5: | ||
| candidate.MovingMajor = mustParseStableVersion(nil, fmt.Sprintf("v%d", major)) | ||
| candidate.HasMovingMajor = true | ||
| candidate.MovingMajorEligible = true | ||
| candidate.Exact = mustParseStableVersion(nil, fmt.Sprintf("v%d.2.0", major)) | ||
| candidate.HasExact = true | ||
| candidate.ExactEligible = true | ||
| case 6: | ||
| candidate.MovingMajor = mustParseStableVersion(nil, fmt.Sprintf("v%d", major)) | ||
| candidate.HasMovingMajor = true | ||
| candidate.Exact = mustParseStableVersion(nil, fmt.Sprintf("v%d.2.0", major)) | ||
| candidate.HasExact = true | ||
| candidate.ExactEligible = true | ||
| case 7: | ||
| candidate.MovingMajor = mustParseStableVersion(nil, fmt.Sprintf("v%d", major)) | ||
| candidate.HasMovingMajor = true | ||
| candidate.Exact = mustParseStableVersion(nil, fmt.Sprintf("v%d.2.0", major)) | ||
| candidate.HasExact = true | ||
| case 8: | ||
| candidate.MovingMajor = mustParseStableVersion(nil, fmt.Sprintf("v%d", major)) | ||
| candidate.HasMovingMajor = true | ||
| candidate.MovingMajorEligible = true | ||
| candidate.Exact = mustParseStableVersion(nil, fmt.Sprintf("v%d.2.0", major)) | ||
| candidate.HasExact = true | ||
| default: | ||
| panic(fmt.Sprintf("unknown state %d", state)) | ||
| } |
Comment on lines
+885
to
+890
| func (s policyScenario) currentVersion() actionspec.StableVersion { | ||
| if s.CurrentKind { | ||
| return mustParseStableVersion(nil, fmt.Sprintf("v%d.1.0", s.CurrentMajor)) | ||
| } | ||
| return mustParseStableVersion(nil, fmt.Sprintf("v%d", s.CurrentMajor)) | ||
| } |
| } | ||
| } | ||
|
|
||
| func TestResolveLatestStableTreatsEquivalentExactTagsAsUnchanged(t *testing.T) { |
Owner
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
v3and minor-moving tags likev3.4Details
actupdatenow resolves action tags through an explicit per-major candidate model instead of a sequence of ad hoc helper interactions. For each published major, the resolver distinguishes moving major tags such asv6, moving minor tags such asv6.2, and exact tags such asv6.2.1, then applies one consistent selection policy across upgrade, cooldown, and unchanged paths.This makes the tool behave correctly for cases such as:
v3.0tov3.3v3.4instead of rewriting them tov3.4.1v3.0andv3.0.0without treating them as upgradesValidation
go test ./...testing/quick