ci: cache Docker layers, add concurrency, parallelize smoke, pin bun#413
Merged
Conversation
Speeds up the CI pipeline without weakening the test gate. - Docker layer cache: build the platform + web images via docker/build-push-action with type=gha cache (per-image scope). The base layers (apt deps, node, bun, mpak) are identical across commits and are now restored from cache instead of rebuilt cold every run. - Concurrency: cancel superseded PR-branch runs; never cancel a push to main (each main commit must complete so its SHA-tagged image lands in ECR — group falls back to the unique run_id on push events). - Ordering: smoke no longer chains behind unit+integration. build-and-push still gates on all four test jobs (incl. smoke), so nothing builds until every test is green — chaining smoke only delayed that gate. Build now starts as soon as the slowest test finishes, not after smoke runs serially. - bun-version: pinned to a single workflow-level env var (BUN_VERSION) instead of `latest` duplicated across four jobs — deterministic and DRY.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Speeds up CI without weakening the test gate. Measured baseline (run for `9495ea9`): three serial waves, ~3.2 min wall-clock to a pushed image, with the image build not even starting until ~93s in.
Changes
1. Docker layer caching (the big win)
Both images used raw `docker build` with no cross-run cache, rebuilding identical base layers (`apt-get install curl/git/nodejs`, `bun.sh/install`, `npm i -g @nimblebrain/mpak`) every run. Now built via `docker/build-push-action@v6` with `type=gha` cache (per-image `scope` so platform/web don't clobber each other; `mode=max` for multi-stage layers). Warm builds skip the unchanged base.
Expected: platform ~65s → ~20–30s, web ~28s → ~10s.
2. Concurrency
No `concurrency` existed — stale PR runs ran to completion. Now cancels superseded PR-branch runs. Never cancels a push to main: on push events `head_ref` is empty so the group falls back to the unique `run_id`, keeping every main commit's SHA-tagged image build intact.
3. Ordering (test gate unchanged)
`smoke` no longer chains behind `test-unit`/`test-integration`. `build-and-push` still `needs` all four test jobs including smoke — nothing builds until every test is green. Chaining smoke serially only pushed the build's start later without adding safety. Build now starts when the slowest test finishes (~54s) instead of after smoke runs in a second wave (~93s).
4. Pin bun, DRY
`bun-version: latest` (duplicated in 4 jobs) → single workflow-level `env.BUN_VERSION` pinned to `1.3.14` (what `latest` resolves to today). Deterministic, one place to bump.
Expected critical path
```
before: wave1 tests(~54) → wave2 smoke(~93) → wave3 build(~192) ~3.2 min
after: wave1 all tests(~54) → wave2 build, warm cache(~30–40) ~1.5 min
```
Notes