Skip to content

Ensure checkout step is always first when importing copilot-setup-steps.yml and remove redundant .github checkout - #13566

Merged
pelikhan merged 6 commits into
mainfrom
copilot/add-checkout-repository-step
Feb 3, 2026
Merged

pelikhan merged 6 commits into
mainfrom
copilot/add-checkout-repository-step

Conversation

Copilot AI commented Feb 3, 2026 •

Copy link
Copy Markdown
Contributor

When copilot-setup-steps.yml is imported, steps requiring repository access (Node.js cache, code builds) ran before checkout, causing failures. Additionally, a redundant sparse .github folder checkout was present when a full repository checkout already existed.

Changes

  • Modified extractStepsFromCopilotSetup() to guarantee checkout step is first:

    • Moves existing checkout to position 0
    • Adds default actions/checkout@v4 if missing
    • No-op if already first
  • Added ensureCheckoutStepFirst() helper with precise pattern matching:

    // Matches "actions/checkout" or "actions/checkout@v4"
    if strings.HasPrefix(usesStr, "actions/checkout@") || usesStr == "actions/checkout"
  • Fixed redundant .github checkout in generateCheckoutGitHubFolder():

    • Skips sparse .github checkout when custom steps contain full checkout
    • Skips sparse .github checkout when automatic full checkout will be added
    • Prevents unnecessary duplicate checkout operations
  • Added 3 test cases covering: move existing, add missing, already first

  • Updated test expectations to verify .github checkout is not present when redundant

Example

Before (from copilot-setup-steps.yml):

- name: Install gh-aw extension
- name: Checkout code
- name: Setup Node.js

After import:

- name: Checkout code        # ← moved to first
- name: Install gh-aw extension
- name: Setup Node.js

Before (redundant checkout):

- name: Checkout actions folder
- name: Setup Scripts
- name: Checkout .github folder  # ← Redundant
- name: Create gh-aw temp directory
- name: Checkout code            # ← Full checkout

After (redundant checkout removed):

- name: Checkout actions folder
- name: Setup Scripts
- name: Create gh-aw temp directory
- name: Checkout code            # ← Full checkout (includes .github)
Original prompt

When the copilot-setup-steps.yml file is imported, an 'checkout repository' step should always be included.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI and others added 2 commits February 3, 2026 19:31
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add checkout repository step to copilot-setup-steps Ensure checkout step is always first when importing copilot-setup-steps.yml Feb 3, 2026
Copilot AI requested a review from pelikhan February 3, 2026 19:34
@pelikhan
pelikhan marked this pull request as ready for review February 3, 2026 19:43
Copilot AI review requested due to automatic review settings February 3, 2026 19:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 ensures that repository checkout always occurs before other steps when importing copilot-setup-steps.yml, preventing failures when subsequent steps require repository access (e.g., Node.js cache, code builds).

Changes:

  • Modified extractStepsFromCopilotSetup() to guarantee checkout step is first by moving existing checkout or adding default actions/checkout@v4
  • Added ensureCheckoutStepFirst() helper function with pattern matching for checkout action detection
  • Added comprehensive test coverage for three scenarios: moving existing checkout, adding missing checkout, and no-op when already first

Reviewed changes

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

File Description
pkg/parser/yaml_import.go Implements checkout step enforcement logic in step extraction
pkg/parser/yaml_import_copilot_setup_test.go Adds test cases validating checkout step ordering behavior
.github/workflows/daily-copilot-token-report.lock.yml Shows reordering of steps with checkout moved after gh-aw installation

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

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

pelikhan commented Feb 3, 2026

Copy link
Copy Markdown
Collaborator

@copilot keep working

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Ensure checkout step is always first when importing copilot-setup-steps.yml Ensure checkout step is always first when importing copilot-setup-steps.yml and remove redundant .github checkout Feb 3, 2026
@pelikhan
pelikhan merged commit 7ab8281 into main Feb 3, 2026
117 of 118 checks passed
@pelikhan
pelikhan deleted the copilot/add-checkout-repository-step branch February 3, 2026 20:10
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.

3 participants