Skip to content

fix: correct stale with: version: when uses: comment and version drifted before upgrade#20895

Merged
pelikhan merged 6 commits intomainfrom
copilot/fix-drift-in-copilot-setup-steps
Mar 14, 2026
Merged

fix: correct stale with: version: when uses: comment and version drifted before upgrade#20895
pelikhan merged 6 commits intomainfrom
copilot/fix-drift-in-copilot-setup-steps

Conversation

Copy link
Contributor

Copilot AI commented Mar 14, 2026

gh aw upgrade silently left with: version: stale when the uses: comment and with: version: were already out of sync—e.g., someone manually bumped the SHA without updating the CLI version parameter.

Root cause: versionInWithPattern was constructed at runtime anchored to the exact newUses value via regexp.QuoteMeta. If drift existed prior to the upgrade, the new uses: line matched, but the subsequent version: search was still coupled to that precise ref string in a way that failed under certain drift conditions.

Changes:

  • pkg/cli/copilot_setup.go — Replace the runtime regexp.MustCompile + regexp.QuoteMeta construction with a package-level pre-compiled versionInWithPattern. The new regex matches any valid setup-cli uses: line (version tag, SHA-pinned, or quoted form), making with: version: updates independent of ref format and any pre-existing drift:

    # Before upgrade — drift between uses: comment and with: version:
    uses: github/gh-aw/actions/setup-cli@cb796656...00070e # v0.58.0
    with:
      version: v0.53.6  # ← was left stale
    
    # After upgrade to v0.60.0 — both fields now updated correctly
    uses: github/gh-aw/actions/setup-cli@newsha123 # v0.60.0
    with:
      version: v0.60.0
  • pkg/cli/copilot_setup_test.go — Add two drift test cases to TestUpgradeSetupCliVersionInContent: SHA-pinned ref with stale version:, and version-tag ref with stale version:.

Copilot AI and others added 3 commits March 13, 2026 23:00
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…uring gh aw upgrade

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 14, 2026 02:41
Copilot AI review requested due to automatic review settings March 14, 2026 02:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes gh aw upgrade leaving a stale with: version: when the uses: ref/comment and with.version were already out of sync, by decoupling the version: update regex from the exact upgraded uses: value.

Changes:

  • Replace a runtime-constructed regex (anchored to newUses) with a package-level precompiled versionInWithPattern that matches any valid setup-cli uses: line.
  • Add regression tests covering pre-existing drift for both SHA-pinned and version-tag uses: formats.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/cli/copilot_setup.go Makes with: version: replacement independent of the exact uses: ref to handle pre-upgrade drift.
pkg/cli/copilot_setup_test.go Adds drift-focused test cases ensuring both uses: and with.version are updated together.

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

You can also share your feedback on Copilot code review. Take the survey.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@pelikhan
Copy link
Contributor

@copilot lint go

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

Copilot AI commented Mar 14, 2026

@copilot lint go

Fixed in 103c1c1go fmt added a missing blank comment line before the // Note: paragraph in the versionInWithPattern doc comment. All tests pass and lint is clean.

Copilot AI requested a review from pelikhan March 14, 2026 02:54
@pelikhan pelikhan merged commit 9914773 into main Mar 14, 2026
52 checks passed
@pelikhan pelikhan deleted the copilot/fix-drift-in-copilot-setup-steps branch March 14, 2026 03:03
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.

gh aw upgrade does not correct drift between uses: comment version and with: version: in copilot-setup-steps.yml

3 participants