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
5 changes: 5 additions & 0 deletions .changeset/patch-parallelize-git-ls-remote-test.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions .github/copilot/instructions/build-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,33 @@ go test -bench=. -benchmem ./pkg/workflow
- Use `go test -p N` for parallel package testing
- Identify and optimize slowest tests (>1s)
- Add Go benchmarks for critical paths
- Use `t.Parallel()` for network-bound test subtests

**Success Story: Parallel Git Ls-Remote Test (2025-10)**:
```go
// BEFORE: Sequential network calls
for key, pin := range actionPins {
t.Run(key, func(t *testing.T) {
cmd := exec.Command("git", "ls-remote", repoURL, tag)
// ... validation
})
}
// Result: 3.83s (slowest test)

// AFTER: Parallel network calls
for key, pin := range actionPins {
key := key // Capture for parallel
pin := pin // Capture for parallel
t.Run(key, func(t *testing.T) {
t.Parallel() // Run concurrently
cmd := exec.Command("git", "ls-remote", repoURL, tag)
// ... validation
})
}
// Result: ~1.1s (70% faster, 3.5x speedup)
```

**Key Insight**: Network-bound tests benefit significantly from parallelization since they're I/O-bound rather than CPU-bound. Always capture loop variables when using `t.Parallel()`.

**Example Benchmark**:
```go
Expand Down
6 changes: 5 additions & 1 deletion pkg/workflow/action_pins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,13 @@ func TestActionPinSHAsMatchVersionTags(t *testing.T) {
t.Skip("Skipping network-dependent test in short mode")
}

// Test all action pins
// Test all action pins in parallel for faster execution
for key, pin := range actionPins {
key := key // Capture for parallel execution
pin := pin // Capture for parallel execution
t.Run(key, func(t *testing.T) {
t.Parallel() // Run subtests in parallel

// Extract the repository URL from the repo field
// For actions like "actions/checkout", the URL is https://github.com/actions/checkout.git
// For actions like "github/codeql-action/upload-sarif", we need the base repo
Expand Down
Loading