AWS Builder Center
How We Fixed a 60-Minute CI Timeout with 8,000+ Tests—Without Cutting Test Quality

How We Fixed a 60-Minute CI Timeout with 8,000+ Tests—Without Cutting Test Quality

Our Kiro-assisted AWS IaC project hit a 60-minute GitHub Actions timeout. Here's how we reduced local test runtime by 19% while preserving 59/59 mutation kills, 95% coverage, and all 10 required CI checks.

Senior Director

When CI Becomes the Bottleneck

While building  aws-iac-review-agent-plugin  with Kiro, I encountered an unexpected problem.
Our GitHub Actions workflow reached its 60-minute timeout, with pytest seemingly stuck at 29%.
The project implements bounded remediation and evidence validation for AI-assisted AWS Infrastructure as Code (IaC) changes.
Its test suite includes over 8,000 tests covering regression, property-based testing, evidence integrity, and mutation testing.
Removing expensive tests was tempting, but unacceptable.
For agentic systems, detecting unsafe changes is part of the product's value.
So we investigated the actual bottleneck instead.

Finding the Root Cause

Profiling revealed that our Evidence Chain tests were repeatedly generating identical verification reports.
Each generation invoked external tools, including cfn-lint and cfn-guard.
Metric
Before optimization
Verification helper calls
117
Actual report generations
117
cfn-lint executions
327
Chain Test runtime
452 seconds
The problem wasn't simply too many tests.
We were repeatedly paying the cost of generating the same test data.

The Fix: Cache Test Data, Not Validation Decisions

We introduced a process-local cache for deterministic verification reports.
The cache key considers Git commits, contract content, execution mode, environment variables, and tool identity.
Two safeguards were especially important:
  • Uncommitted changes: When testing the working tree ( head=None ), caching is bypassed to avoid stale results.
  • Mutation isolation: Only verification fixtures are cached. The Evidence Chain validation logic being mutated is never cached.
We also added nine cache-safety tests to our required CI validation.

Results: Faster Without Weakening Tests

Local measurements on macOS showed:
Metric
Before
After
Chain Tests
452s
268s
Mutation Tests
256s
178s
Full pytest
1,225s
988s
Report generations
117
3
The full-suite runtime decreased by approximately 19%, although the comparison was not a perfectly controlled benchmark because of an environment-sensitive test failure in an earlier run.
Most importantly, our quality checks remained intact:
  • 59/59 mutation kills
  • 95% test coverage
  • 349 Chain Tests passing
  • 10/10 required GitHub Actions checks passing
We also extended the macOS Intel / Python 3.9 job timeout from 60 to 90 minutes to provide operational headroom.
The updated job completed successfully in 58m 44s, and the subsequent main-branch CI also succeeded.
This result validates the combined configuration—not that caching alone would always finish within 60 minutes.

What This Taught Me About Agentic Engineering

Three lessons stood out.
1. More tests don't necessarily mean proportionally longer execution.
Chain Test runtime increased approximately 3.8× between development milestones. Profiling revealed duplicated external tool execution.
2. Optimize repeated work before reducing verification.
We improved performance without removing mutation tests or lowering coverage requirements.
3. Test infrastructure needs its own safeguards.
An unsafe cache can hide defects just as easily as an incorrect implementation. Cache invalidation and mutation isolation deserve explicit testing.
Kiro helped us develop and investigate the solution, but measured evidence, regression validation, and human review determined whether the changes were acceptable.
The bigger takeaway: Faster agentic development needs equally reliable—and sustainable—validation.

Explore the Implementation

How are you handling CI performance bottlenecks without compromising test quality in your AI-assisted development workflows?
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article