[ci-coach] Rebalance cgo.yml unit test shards by measured execution time

CI Optimization Coach · issue · open

Filter2mode:review mode:live
All recorded Export JSON
github-actions[bot]

published Aug 26, 2026, 1:50 PM · updated Aug 26, 2026, 2:03 PM

CI Optimization Proposal

Summary

Pre-flight validation (deps-dev, lint, lint-errors, npm-ci, build, recompile, test-unit) all passed cleanly, so this run focused on optimization opportunities in cgo.yml's test matrix job.

Top Optimization

Rebalance unit test shards by measured execution time

  • Type: Test suite restructuring
  • Impact: High — cuts longest-running shard from ~82s to ~45s (~45% reduction), shrinking the test job's critical path
  • Risk: Low — patterns still partition the full ^Test.* namespace exhaustively and mutually exclusively; no tests are skipped or duplicated
  • Changes: .github/workflows/cgo.yml — changed the 5-way matrix.include pattern split from alphabetical ranges (A-C/D-G/H-M/N-R/S-Z) to time-balanced ranges (A-B/C/D-H/I-O/P-Z)
  • Rationale: Analyzed go test -json timing data from /tmp/gh-aw/agent/test-results.json (recent CI run). Top-level test durations per starting letter showed TestC* alone took ~45s (237 tests) and the old A-C shard totalled ~82s, while other shards ranged 21–37s — a >2x imbalance. Since fail-fast: false matrix jobs run in parallel, the wall-clock time for the whole test job is bounded by its slowest shard. Regrouping by measured time (verified against the actual timing data) balances all 5 shards to 31–45s each.
Before/after shard timing (from CI run's go test -json data)
Old shard Time New shard Time
A-C 82.2s A-B 37.5s
D-G 36.3s C 44.8s
H-M 34.8s D-H 43.8s
N-R 21.1s I-O 30.7s
S-Z 21.9s P-Z 39.7s

Expected Impact

  • Reduces test job wall-clock time by up to ~45% (bounded by previously-slowest shard A-C at 82s → new max shard C at ~45s)
  • No change to total test count, coverage, or matrix breadth — same 5 parallel shards, just rebalanced boundaries

Validation Results

  • YAML syntax validated via js-yaml parser: OK
  • make lint: only pre-existing, unrelated JS warnings (37 warnings, 0 errors) and a missing golangci-lint binary in this sandbox (unrelated to this change; pre-flight validation step already confirmed lint passes with deps installed)
  • Verified new pattern set is exhaustive/non-overlapping across the full test namespace by re-running the shard-timing analysis script against all 10,126 top-level test names

Metrics Baseline

  • Pre-flight validation: all 7 steps passed (deps-dev, lint, lint-errors, npm-ci, build, recompile, test-unit)
  • Source: /tmp/gh-aw/agent/test-results.json (raw go test -json stream from most recent CI run)

Warning

Protected Files — Push Permission Denied

This was originally intended as a pull request, but the change modifies protected files. A human must create the pull request manually.

Protected files

The push was rejected because GitHub Actions does not have workflows permission to push these changes, and is never allowed to make such changes, or other authorization being used does not have this permission.

Create the pull request manually
# Download the artifact from the workflow run
gh run download '32974386050' -n agent -D '/tmp/agent-32974386050'

# Resolve the bundle source ref, fetch it into a temporary ref, then create the local branch
bundle_path='/tmp/agent-32974386050/aw-ci-coach-rebalance-test-shards.bundle'
temp_ref='refs/bundles/create-pr-ci-coach-rebalance-test-shards-c9f637620d00abcc-04ef1541'
target_ref='refs/heads/ci-coach-rebalance-test-shards-c9f637620d00abcc'
bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 ~ /^refs\/heads\// { print $2 }')
if [ -z "$bundle_source_ref" ]; then
  bundle_source_ref=$(git bundle list-heads "$bundle_path" | awk '$2 == "HEAD" { print $2 }')
fi
if [ "$(printf '%s\n' "$bundle_source_ref" | sed '/^$/d' | wc -l | tr -d ' ')" != "1" ]; then
  echo "Expected exactly one bundle source ref, found: $bundle_source_ref" >&2
  exit 1
fi
git fetch "$bundle_path" "${bundle_source_ref}:${temp_ref}"
git update-ref "$target_ref" "$temp_ref"
git checkout 'ci-coach-rebalance-test-shards-c9f637620d00abcc'
# Ensure the working tree matches the updated branch
git reset --hard
# Remove the temporary bundle ref
git update-ref -d "$temp_ref"

# Push the branch and create the pull request
git push origin ci-coach-rebalance-test-shards-c9f637620d00abcc
gh pr create --title '[ci-coach] Rebalance cgo.yml unit test shards by measured execution time' --base main --head ci-coach-rebalance-test-shards-c9f637620d00abcc --repo github/gh-aw

Generated by CI Optimization Coach · copilot · auto · 55.9 AIC · ⌖ 10.9 AIC · ⊞ 16.4K ·

  • expires on Aug 28, 2026, 5:50 AM UTC-08:00