Skip to content

[ci-coach] Optimize CI by fixing duplicate test execution in unit and integration jobs#8176

Merged
pelikhan merged 1 commit intomainfrom
main-1a4b63091d5a05b4
Dec 30, 2025
Merged

[ci-coach] Optimize CI by fixing duplicate test execution in unit and integration jobs#8176
pelikhan merged 1 commit intomainfrom
main-1a4b63091d5a05b4

Conversation

@github-actions
Copy link
Contributor

CI Optimization: Fix Duplicate Test Execution

Summary

This PR eliminates duplicate test execution by properly tagging slow integration tests. Currently, three test files containing ~60 seconds of slow tests are running in both the unit test job and the integration test job, causing unnecessary duplication.

Problem Identified

Issue: Three test files without //go:build integration tags are running in both jobs:

  • pkg/cli/run_command_test.go (contains TestProgressFlagSignature - 30.26s)
  • pkg/cli/compile_command_test.go (contains TestCompileWorkflows_EmptyMarkdownFiles - 10.24s)
  • pkg/cli/mcp_inspect_headers_test.go (contains TestConnectHTTPMCPServer tests - 20s combined)

Current Behavior:

  • ❌ Unit test job: Runs these tests (no build tag exclusion)
  • ❌ Integration matrix: ALSO runs these tests (dedicated matrix groups target them)
  • ⚠️ Result: ~60 seconds of duplicate test execution per CI run

Root Cause: The integration matrix was properly configured with specific groups for these slow tests:

  • "CLI Progress Flag" group for TestProgressFlagSignature
  • "CLI Compile Workflows" group for TestCompileWorkflows_EmptyMarkdownFiles
  • "CLI HTTP MCP Connect" group for TestConnectHTTPMCPServer

However, the test files lacked the //go:build integration tag, so the unit test job (which uses -tags '!integration') couldn't exclude them.

Changes Made

Added //go:build integration build tags to three test files:

+//go:build integration
+
 package cli

Files Modified:

  1. pkg/cli/run_command_test.go
  2. pkg/cli/compile_command_test.go
  3. pkg/cli/mcp_inspect_headers_test.go

Expected Impact

Unit Test Time Reduction: ~60 seconds (45% reduction from 110s → 50s)

  • Removes TestProgressFlagSignature (30.26s)
  • Removes TestCompileWorkflows_EmptyMarkdownFiles (10.24s)
  • Removes TestConnectHTTPMCPServer_WithHeaders (10.01s)
  • Removes TestConnectHTTPMCPServer_NoHeaders (10.00s)

Integration Test Time: No change (tests already in matrix with dedicated groups)

Net CI Speedup: ~60 seconds per run

Cost Savings:

  • ~60 seconds saved per run
  • ~100 GitHub Actions minutes saved per day (based on 100 runs/day historical average)

Risk: Low

  • Tests are already covered in integration matrix
  • No test coverage is lost
  • Only eliminates duplication

Validation

The changes ensure:

  • ✅ Unit test job skips these tests (via -tags '!integration')
  • ✅ Integration matrix groups still run these tests (already configured)
  • ✅ No loss of test coverage
  • ✅ Significant time savings

CI Structure Analysis

The CI workflow is already very well optimized:

  • ✅ Integration tests run in parallel with unit tests (both depend on lint only)
  • ✅ Large integration matrix (32 groups) with good balance
  • ✅ Expensive jobs (bench, fuzz, security-scan) only run on main
  • ✅ Incremental golangci-lint on PRs (50-75% speedup)
  • ✅ Concurrency groups with cancel-in-progress
  • ✅ Proper Go and npm cache usage
  • ✅ Tests run with -parallel=8 for good CPU utilization

This PR addresses the only significant inefficiency found: duplicate test execution.

Testing Plan

  • Verified slow tests are in dedicated integration matrix groups
  • Confirm unit test job completes ~60 seconds faster
  • Verify integration test jobs still run the tests
  • Monitor first few runs after merge for any issues

Metrics Baseline

Current state (from analysis of 100 recent runs):

  • Total unit tests: 10,998 tests
  • Unit test time: ~110 seconds
  • Tests > 0.5s: 19 tests
  • Test files with integration tags: 34 (now 37 after this PR)

Expected after merge:

  • Unit test time: ~50 seconds (45% reduction)
  • Cleaner separation between unit and integration tests

References:

  • Analysis run: §34
  • Cache memory: /tmp/gh-aw/cache-memory/ci-coach/last-analysis.json

AI generated by CI Optimization Coach

…tion

- Add //go:build integration to run_command_test.go (TestProgressFlagSignature: 30.26s)
- Add //go:build integration to compile_command_test.go (TestCompileWorkflows: 10.24s)
- Add //go:build integration to mcp_inspect_headers_test.go (TestConnectHTTPMCPServer: 20s)

These tests are already isolated in dedicated integration matrix groups but
were running in BOTH the unit test job and integration jobs, causing ~60s
of duplicate test execution per CI run.

Expected impact:
- Unit test time: 110s → 50s (45% reduction)
- Integration test time: No change (tests already in matrix)
- Net savings: ~60 seconds per run (~100 minutes/day)

Fixes duplicate test execution identified by CI Coach workflow run #34
@pelikhan pelikhan marked this pull request as ready for review December 30, 2025 14:37
@pelikhan pelikhan merged commit 26d85b7 into main Dec 30, 2025
4 checks passed
@pelikhan pelikhan deleted the main-1a4b63091d5a05b4 branch December 30, 2025 14:37
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.

1 participant