Skip to content

Implement semver-compatible action pin resolution#9027

Merged
pelikhan merged 6 commits intomainfrom
copilot/resolve-highest-compatible-version
Jan 5, 2026
Merged

Implement semver-compatible action pin resolution#9027
pelikhan merged 6 commits intomainfrom
copilot/resolve-highest-compatible-version

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 5, 2026

✅ Semver-Compatible Action Pin Resolution Complete

Successfully implemented semver-compatible version resolution as requested by @pelikhan. All changes are complete, tested, and formatted.

Changes Made

  • Added extractMajorVersion() helper in semver.go
  • Added isSemverCompatible() helper in semver.go
  • Updated GetActionPinWithData() to filter for semver-compatible versions
  • Updated test expectations in TestGetActionPinWithData_SemverPreference
  • Added test case for v5 → v5.0.0 resolution
  • Added comprehensive tests for helper functions
  • Formatted Go code with gofmt
  • All tests pass (100% success rate)

New Behavior

Before (crossed major version boundaries):

v4 requested → v6.0.0 resolved ❌
v5 requested → v6.0.0 resolved ❌

After (respects semver compatibility):

v4 requested → v4.6.2 resolved ✅ (highest v4.x.x)
v5 requested → v5.0.0 resolved ✅ (highest v5.x.x)
v6 requested → v6.1.0 resolved ✅ (highest v6.x.x)

Resolution Algorithm

  1. Sort all pins by version (descending)
  2. Try to find exact version match
  3. If no exact match, filter for semver-compatible versions (matching major version)
  4. Return highest semver-compatible version
  5. If no compatible versions exist, fall back to highest overall version

Example: actions/upload-artifact

Available: v4.6.2, v5.0.0, v6.0.0

# Request v4 → gets v4.6.2 (highest v4.x.x)
uses: actions/upload-artifact@v4

# Request v5 → gets v5.0.0 (highest v5.x.x)
uses: actions/upload-artifact@v5

# Request v6 → gets v6.0.0 (highest v6.x.x)
uses: actions/upload-artifact@v6

# Exact version → gets exact match
uses: actions/upload-artifact@v5.0.0  # → v5.0.0

Test Results

All tests pass with comprehensive coverage:

✓ TestGetActionPinWithData_SemverPreference - All cases pass
✓ TestGetActionPinWithData_V5ExactMatch - Passes
✓ TestGetActionPinSemverPreference - Passes
✓ TestSortPinsByVersion - Passes
✓ TestExtractMajorVersion - Passes (new)
✓ TestIsSemverCompatible - Passes (new)
✓ All other action pin tests - Pass

Commits

  • f0759ec - Implement semver-compatible action pin resolution
  • 9898f77 - Add comprehensive tests for semver helper functions
  • (current) - Format Go code with gofmt
Original prompt

When running the compile command and resolve action pins, the resolution alogirhtm should pick the higest compatible version number.

If resolving actions/upload-artifact, and v5.0.0 and v6.0.0, then v6.0.0 should be the resolved version.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jan 5, 2026

@copilot the upgrade of version should be semver compatible

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix resolution algorithm for action pins Add test coverage for action pin resolution selecting highest version Jan 5, 2026
Copilot AI requested a review from pelikhan January 5, 2026 19:58
- Add extractMajorVersion() and isSemverCompatible() helper functions
- Update GetActionPinWithData() to prefer semver-compatible versions
- When requesting v5, now resolves to v5.0.0 (not v6.0.0)
- When requesting v4, now resolves to v4.6.2 (not v6.0.0)
- Update tests to reflect new semver-compatible behavior

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot the upgrade of version should be semver compatible

Implemented semver-compatible version resolution in commit f0759ec.

Now when requesting a major version (e.g., v5), the system resolves to the highest patch within that major version (e.g., v5.0.0) instead of crossing major version boundaries to v6.0.0.

Examples:

  • v4v4.6.2 (highest v4.x.x)
  • v5v5.0.0 (highest v5.x.x)
  • v6v6.0.0 (highest v6.x.x)

- Add TestExtractMajorVersion with edge cases
- Add TestIsSemverCompatible with various scenarios
- Ensure helper functions handle all version formats correctly

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Add test coverage for action pin resolution selecting highest version Implement semver-compatible action pin resolution Jan 5, 2026
@pelikhan pelikhan marked this pull request as ready for review January 5, 2026 20:22
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Jan 5, 2026

@copilot format, lint go

- Fix indentation in action_pins.go
- Fix indentation in action_pins_test.go
- Remove trailing whitespace

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot format, lint go

Formatted Go code with gofmt in commit 96afd57.

Changes:

  • Fixed indentation in action_pins.go and action_pins_test.go
  • Removed trailing whitespace
  • All tests still pass

@pelikhan pelikhan merged commit 2f32167 into main Jan 5, 2026
88 of 90 checks passed
@pelikhan pelikhan deleted the copilot/resolve-highest-compatible-version branch January 5, 2026 20:35
@github-actions github-actions bot mentioned this pull request Jan 6, 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.

2 participants