Skip to content

Faster CI: shard tests by file, cache analysis, skip needless web builds - #37

Merged
burhankhanzada merged 3 commits into
mainfrom
ci/shard-by-file
Oct 4, 2026
Merged

burhankhanzada merged 3 commits into
mainfrom
ci/shard-by-file

Conversation

@burhankhanzada

@burhankhanzada burhankhanzada commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

What and why

Follow-up to #36, which took a pull request from ~12½ min to 4m35s. Three more:

  • Shard tests by file (5f672a5). flutter test --total-shards splits the tests, not the files: every shard still compiled all ~105 test files — most of the suite's time — and ran a third of them, ~3 min each. Each shard now takes every third file (git ls-files, so a new file joins a shard on its own) and compiles only those. Measured on this PR: shards ~105–120 s of tests, and the whole run 2m52s.
  • Cache the analyzer's work (a3917c9, 9d1a0c4). dart analyze --cache=<absolute path>, kept between runs with actions/cache (~61 MB). Measured on this PR: Analyze 84 s cold → 32 s warm (+3 s to restore). The path has to be absolute: a relative one is resolved against the analyzer's own install for the plugin builds it keeps there, riverpod_lint then fails to load, and the plugin-load guard fails the step — which is what the first run here did.
  • Skip the web build when it can't change (a3917c9). A pull request touching only tests, native runners or the git hooks skips it. Checked inside the job rather than by detect, so the web build — now CI's longest job — doesn't wait for another job first. Workflow changes still build, since they can break the job.

How it was verified

  • actionlint 1.7.12 — clean; the skip pattern checked against GNU-style grep for tests-only, native-only, lib/ and workflow changes
  • The first commit's run: 2m52s
  • The analysis cache on CI — 84 s with it empty, 32 s restored (a re-run of the same PR run; caches are scoped to the ref, so a workflow_dispatch run on the branch can't see the PR's)

Pushed without the local pre-push hook: workflow-only changes, which CI checks itself.

Not done

Compiling each shard's tests as one generated file was tried and dropped: combined into one isolate, the suite hung in port_hover_label_test on state left by an earlier file, and some tests depend on per-isolate state (re_editor caches the platform once per isolate). Not safe without auditing every file.

🤖 Generated with Claude Code

burhankhanzada and others added 2 commits October 4, 2026 16:56
`flutter test --total-shards` splits the tests, not the files: every
shard still compiled all ~105 test files, which is most of the suite's
time, and then ran a third of them, so each shard took ~3 min of the old
job's 4. Each shard now takes every third file and compiles only those.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
- Analyze keeps `dart analyze`'s own cache — summaries of the SDK, the
  dependencies and every library it has seen — between runs. Locally
  that took analysis from 48 s with an empty cache to 27 s warm, for
  76 MB.
- A pull request that touches only what the web build does not compile
  (tests, the native runners, the git hooks) skips it. Checked inside
  the job, so the web build — now CI's longest — does not wait for
  `detect` first. Workflow changes still build: they can break the job.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@burhankhanzada burhankhanzada changed the title Shard CI's tests by file, not by test Faster CI: shard tests by file, cache analysis, skip needless web builds Oct 4, 2026
A relative --cache is resolved against the analyzer's own install for
the plugin builds it keeps there, so riverpod_lint failed to load and
Analyze exited 4 — caught by the plugin-load guard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@burhankhanzada
burhankhanzada merged commit 2082b24 into main Oct 4, 2026
63 checks passed
@burhankhanzada
burhankhanzada deleted the ci/shard-by-file branch October 4, 2026 20:20
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