Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ jobs:
steps:
- name: Install gh-aw extension
run: curl -fsSL https://raw.githubusercontent.com/githubnext/gh-aw/refs/heads/main/install-gh-aw.sh | bash
- name: Verify gh-aw installation
run: gh aw version
- name: Checkout code
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd
- name: Set up Node.js
Expand Down
17 changes: 3 additions & 14 deletions pkg/cli/copilot_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ jobs:
uses: githubnext/gh-aw/actions/setup-cli%s
with:
version: %s
- name: Verify gh-aw installation
run: gh aw version
`, actionRef, version)
}

Expand Down Expand Up @@ -78,8 +76,6 @@ jobs:
- name: Install gh-aw extension
run: |
curl -fsSL https://raw.githubusercontent.com/githubnext/gh-aw/refs/heads/main/install-gh-aw.sh | bash
- name: Verify gh-aw installation
run: gh aw version
`
}

Expand All @@ -106,8 +102,6 @@ jobs:
- name: Install gh-aw extension
run: |
curl -fsSL https://raw.githubusercontent.com/githubnext/gh-aw/refs/heads/main/install-gh-aw.sh | bash
- name: Verify gh-aw installation
run: gh aw version
`

// CopilotWorkflowStep represents a GitHub Actions workflow step for Copilot setup scaffolding
Expand Down Expand Up @@ -239,26 +233,21 @@ func injectExtensionInstallStep(workflow *Workflow, actionMode workflow.ActionMo
}
}

verifyStep := CopilotWorkflowStep{
Name: "Verify gh-aw installation",
Run: "gh aw version",
}

// Find the copilot-setup-steps job
job, exists := workflow.Jobs["copilot-setup-steps"]
if !exists {
return fmt.Errorf("copilot-setup-steps job not found in workflow")
}

// Insert the extension install and verify steps at the beginning
// Insert the extension install step at the beginning
insertPosition := 0

// Prepare steps to insert based on mode
var stepsToInsert []CopilotWorkflowStep
if actionMode.IsRelease() {
stepsToInsert = []CopilotWorkflowStep{checkoutStep, installStep, verifyStep}
stepsToInsert = []CopilotWorkflowStep{checkoutStep, installStep}
} else {
stepsToInsert = []CopilotWorkflowStep{installStep, verifyStep}
stepsToInsert = []CopilotWorkflowStep{installStep}
}

// Insert steps at the determined position
Expand Down
70 changes: 17 additions & 53 deletions pkg/cli/copilot_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,13 @@ func TestEnsureCopilotSetupSteps(t *testing.T) {
}

// Extension install and verify steps should be injected at the beginning
if len(job.Steps) < 4 {
t.Fatalf("Expected at least 4 steps after injection (2 injected + 2 existing), got %d", len(job.Steps))
if len(job.Steps) < 3 {
t.Fatalf("Expected at least 3 steps after injection (1 injected + 2 existing), got %d", len(job.Steps))
}

if job.Steps[0].Name != "Install gh-aw extension" {
t.Errorf("Expected first step to be 'Install gh-aw extension', got %q", job.Steps[0].Name)
}

if job.Steps[1].Name != "Verify gh-aw installation" {
t.Errorf("Expected second step to be 'Verify gh-aw installation', got %q", job.Steps[1].Name)
}
},
},
}
Expand Down Expand Up @@ -206,17 +202,13 @@ func TestInjectExtensionInstallStep(t *testing.T) {
},
},
wantErr: false,
expectedSteps: 4, // 2 injected steps + 2 existing steps
expectedSteps: 3, // 1 injected step + 2 existing steps
validateFunc: func(t *testing.T, w *Workflow) {
steps := w.Jobs["copilot-setup-steps"].Steps
// Extension install should be at index 0 (beginning)
if steps[0].Name != "Install gh-aw extension" {
t.Errorf("Expected step 0 to be 'Install gh-aw extension', got %q", steps[0].Name)
}
// Verify step should be at index 1
if steps[1].Name != "Verify gh-aw installation" {
t.Errorf("Expected step 1 to be 'Verify gh-aw installation', got %q", steps[1].Name)
}
},
},
{
Expand All @@ -229,19 +221,16 @@ func TestInjectExtensionInstallStep(t *testing.T) {
},
},
wantErr: false,
expectedSteps: 2, // 2 injected steps (install + verify)
expectedSteps: 1, // 1 injected step (install only)
validateFunc: func(t *testing.T, w *Workflow) {
steps := w.Jobs["copilot-setup-steps"].Steps
// Should have 2 steps
if len(steps) != 2 {
t.Errorf("Expected 2 steps, got %d", len(steps))
// Should have 1 step
if len(steps) != 1 {
t.Errorf("Expected 1 step, got %d", len(steps))
}
if steps[0].Name != "Install gh-aw extension" {
t.Errorf("Expected step 0 to be 'Install gh-aw extension', got %q", steps[0].Name)
}
if steps[1].Name != "Verify gh-aw installation" {
t.Errorf("Expected step 1 to be 'Verify gh-aw installation', got %q", steps[1].Name)
}
},
},
{
Expand Down Expand Up @@ -385,21 +374,6 @@ func TestCopilotSetupStepsYAMLConstant(t *testing.T) {
t.Error("Template should not contain 'make build' command for universal use")
}
}

// Verify verification step uses 'gh aw version' (works via GitHub CLI after bash install)
hasVerification := false
for _, step := range job.Steps {
if strings.Contains(step.Name, "Verify") {
hasVerification = true
if !strings.Contains(step.Run, "gh aw") {
t.Error("Verification step should use 'gh aw version' after bash install")
}
}
}

if !hasVerification {
t.Error("Expected template to contain verification step")
}
}

func TestEnsureCopilotSetupStepsFilePermissions(t *testing.T) {
Expand Down Expand Up @@ -984,9 +958,9 @@ func TestInjectExtensionInstallStep_ReleaseMode(t *testing.T) {

job := wf.Jobs["copilot-setup-steps"]

// Should have 4 steps: checkout, install, verify, existing
if len(job.Steps) != 4 {
t.Fatalf("Expected 4 steps (checkout, install, verify, existing), got %d", len(job.Steps))
// Should have 3 steps: checkout, install, existing (no verify)
if len(job.Steps) != 3 {
t.Fatalf("Expected 3 steps (checkout, install, existing), got %d", len(job.Steps))
}

// Verify checkout step
Expand All @@ -1009,14 +983,9 @@ func TestInjectExtensionInstallStep_ReleaseMode(t *testing.T) {
t.Errorf("Install step should have version: %s in with, got: %v", testVersion, job.Steps[1].With)
}

// Verify verify step
if job.Steps[2].Name != "Verify gh-aw installation" {
t.Errorf("Third step should be verify, got: %s", job.Steps[2].Name)
}

// Verify original step is preserved
if job.Steps[3].Name != "Existing step" {
t.Errorf("Fourth step should be existing step, got: %s", job.Steps[3].Name)
if job.Steps[2].Name != "Existing step" {
t.Errorf("Third step should be existing step, got: %s", job.Steps[2].Name)
}
}

Expand All @@ -1039,9 +1008,9 @@ func TestInjectExtensionInstallStep_DevMode(t *testing.T) {

job := wf.Jobs["copilot-setup-steps"]

// Should have 3 steps: install, verify, existing (no checkout in dev mode)
if len(job.Steps) != 3 {
t.Fatalf("Expected 3 steps (install, verify, existing), got %d", len(job.Steps))
// Should have 2 steps: install, existing (no verify, no checkout in dev mode)
if len(job.Steps) != 2 {
t.Fatalf("Expected 2 steps (install, existing), got %d", len(job.Steps))
}

// Verify install step uses curl
Expand All @@ -1055,13 +1024,8 @@ func TestInjectExtensionInstallStep_DevMode(t *testing.T) {
t.Errorf("Install should reference install-gh-aw.sh, got: %s", job.Steps[0].Run)
}

// Verify verify step
if job.Steps[1].Name != "Verify gh-aw installation" {
t.Errorf("Second step should be verify, got: %s", job.Steps[1].Name)
}

// Verify original step is preserved
if job.Steps[2].Name != "Existing step" {
t.Errorf("Third step should be existing step, got: %s", job.Steps[2].Name)
if job.Steps[1].Name != "Existing step" {
t.Errorf("Second step should be existing step, got: %s", job.Steps[1].Name)
}
}
Loading