Skip to content

ci: optimize test workflows — 32 jobs → 8 on PRs#4599

Open
mattatcha wants to merge 4 commits intomainfrom
matcha/optimize-ci-workflows
Open

ci: optimize test workflows — 32 jobs → 8 on PRs#4599
mattatcha wants to merge 4 commits intomainfrom
matcha/optimize-ci-workflows

Conversation

@mattatcha
Copy link
Copy Markdown
Collaborator

Summary

CI test runs take ~18 min due to 64% overhead (cache management, redundant installs). This restructures all CI workflows to eliminate that overhead: install once per Python version, share the virtualenv via artifact, and only test 3.12+3.13 on PRs (full matrix on push to main).

Key Changes

  • 32 → 8 test jobs on PRs: 2 Python versions (3.12, 3.13) × 4 groups instead of 4 × 8
  • Install once, share via artifact: Single install job per Python version uploads .venv; test jobs download it instead of each running uv sync
  • Replace manual cache with setup-uv built-in caching: Eliminates race conditions where 32 jobs competed to save the same cache key (caused 13-min install outliers)
  • Re-enable duration-based test splitting: Was disabled because the path filter (tests/**/*.py) never matched actual test dirs (lib/crewai/tests/). Fixed path + switched to least_duration algorithm
  • Add --frozen to all uv sync: Skip resolution, install exactly from lockfile
  • Add concurrency group: Cancel in-progress runs when PR is updated
  • Full matrix on push to main: All 4 Python versions tested on merge
  • Gate jobs for branch protection: Required status checks (tests (3.10) etc.) still satisfied
  • Fix update-test-durations.yml: Path filter never triggered — now matches lib/*/tests/**/*.py
  • Simplify linter + type-checker: Remove manual cache save/restore from both

- Restructure tests.yml: install once per Python version, share .venv
  via artifact instead of 32 independent installs
- Reduce test groups from 8 to 4 (tests only take ~60s per group)
- Only test Python 3.12+3.13 on PRs; full matrix on push to main
- Switch all workflows from manual actions/cache to setup-uv built-in
  caching, eliminating cache race conditions
- Add --frozen flag to uv sync for deterministic CI installs
- Re-enable duration-based test splitting with least_duration algorithm
  (was disabled due to a bug in the path filter)
- Fix update-test-durations path filter (tests/**/*.py never matched
  actual test dirs under lib/)
- Add concurrency group with cancel-in-progress for PR runs
- Add gate jobs to satisfy existing branch protection required checks
tar czf on the venv was taking too long (gzip is single-threaded).
Simpler approach: each test job installs with setup-uv's built-in
cache. With warm cache, uv sync --frozen takes ~10-15s which is
faster than tar + upload + download + extract.
Run 3.10, 3.11, 3.12, 3.13 on every PR — we need to catch
version-specific breakage before merge. Removes the configure
job since the matrix is now static. Still 16 jobs (4×4) vs 32.
@github-actions
Copy link
Copy Markdown
Contributor

This PR is stale because it has been open for 45 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant