ci: use shallow checkouts for web complexity
Summary
The recent four-hour audit found 24.19 runner-hours in complexity checkouts versus about 12.5 minutes executing their check/validation steps. Both workflows fetched all history, although the checker reads trees and baseline files at specific revisions.
Use depth-one checkouts. Candidate checks fetch the exact PR base or pre-push commit when absent; trusted checks fetch a second commit only for main pushes. Missing comparison commits fail instead of silently dropping the baseline comparison. Real Git tests cover an older base across a multi-commit push, preserved shallow history/HEAD, already-available commits without network access, initial pushes, and invalid/unavailable revisions.
The trusted checker, candidate isolation, required check name, events (including edited), and failure behavior are unchanged. Metadata-event/result deduplication is deliberately left for a separate change: skipping a required job can replace an earlier failure with an accepted skipped status. This is a separate workflow-policy change for owner review. Related: #13095.
Testing
- Regression tests committed first: three cases failed before the fetch helper existed; all four methods pass after implementation.
python3 tests/test_ci_fetch_complexity_base.py— pass using real local origin/shallow clone fixtures (only HEAD and the requested old base become available, not the intervening history).- Trusted complexity isolation guard and merge-queue required-check tests — pass.
actionlinton both workflows,bash -n, andgit diff --check— pass.- No checker logic, web/app runtime, or localized product text changed. No app rebuild is needed for this workflow change. Hosted checkout timing is still unmeasured; 24.19 hours is the previous checkout exposure, not a claim that all of it disappears.
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.
Summary by cubic
Makes web complexity CI use shallow checkouts instead of full history, so the workflows stop downloading the entire repository before running checks that only need specific revisions.
- Both workflows use
fetch-depth: 1; a fetch helper pulls only the exact comparison revision (PR base or pre-push commit, plus a second commit for main pushes in the trusted workflow). - The candidate workflow now triggers only on changes to relevant web source and policy files.
- Unavailable or malformed comparison revisions fail the job instead of silently dropping the baseline comparison.
- Tests exercise real shallow repositories, including multi-commit pushes, initial pushes, already-local commits, and invalid/unavailable revisions; the regression test runs in the guard lane.
- Event/result deduplication is left out because skipping a required job can replace an earlier failure with a skipped status.
Summary by CodeRabbit
- Chores
- Improved web complexity checks by limiting workflow runs to relevant file changes.
- Optimized history retrieval for trusted checks while ensuring push comparisons use the correct base revision.