Skip to content

ci: run the parts of Build, Unit Tests, E2E Local in parallel jobs - #963

Merged
belaboe merged 3 commits into
mainfrom
ci/e2e-split-build-local
Oct 26, 2026
Merged

belaboe merged 3 commits into
mainfrom
ci/e2e-split-build-local

Conversation

@belaboe

@belaboe belaboe commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

What

The required check Build, Unit Tests, E2E Local ran build, checks, check:api (~2.4 min), unit tests (~8.5-9 min), local E2E (~3.5 min) and packing one after another: 15.4 min p50 over 25 runs, 17.6 / 18.9 min in the main baseline (#940). Every job that needs it (Templates, and on main the AWS E2E jobs) starts only after it.

This PR runs the parts as parallel jobs:

Job Does
local-build (Local Build and Checks) the old job's first half: lint (advisory), lint:deps, build, the consistency / guard checks and their tests, npm run check:api, pack and upload dist-registry
local-unit (Local Unit Tests, shards 1-3) build, npm run test in the shard's workspaces, the real-CDK probe marker check in the shard that runs @aws-blocks/core
local-e2e (Local E2E) build, npm run test:e2e:local
build-and-test-local (Build, Unit Tests, E2E Local) the required check, now an aggregator

Why it is safe

  • The required check cannot pass without its parts. build-and-test-local keeps its id and name, runs with if: always() (so it is never skipped), and fails unless every part's result is success. A failed, cancelled or skipped part, or one missing from needs, fails it. scripts/ci/unit-test-shard.test.mjs checks this wiring, and also runs the aggregator's own script with crafted needs results: it must exit 0 only when every part succeeded. Mutations that drop a part from needs or from the loop, switch to success(), accept a non-success result, turn the final exit 1 into exit 0, delete the failure block, or add a second matrix axis all fail the test.
  • Downstream semantics are unchanged. Templates, the AWS E2E jobs (on main) and the Build and Test gate still needs: build-and-test-local, which now succeeds only once every part has. Under ci: start the AWS E2E jobs without waiting for unit tests #941 the AWS jobs drop that edge and Templates keep it, as before.
  • No test is dropped. scripts/ci/unit-test-shard.mjs reads the root workspaces, which is the list npm run test --workspaces uses. It puts each workspace in exactly one shard and prints package names, because -w <path> would also select nested workspaces. It refuses glob, duplicate or unnamed entries. A new workspace is picked up automatically. The probe check fails if no shard runs @aws-blocks/core. Test counts before and after are below.
  • Same artifact. dist-registry is now packed right after the build instead of after the tests. A local run packed it both ways: 3347 files, all identical.
  • No change to permissions, OIDC, environments or fork checks. Every action stays pinned to a full SHA (check-actions-pinned.mjs, actionlint clean).

Cost

The setup (npm ci + build, ~2.8 min) now runs in 5 jobs instead of 1, so a run uses roughly 11 more runner minutes, in exchange for wall-clock time. Install caching (separate work) would cut it.

Measurements

Minutes from run creation. Before: the main baseline (#940, runs 39812188339 and 39821845972) and the 25-run p50. After: this PR's runs 39864968616 (run 1) and 39873258910 (run 2).

#940 pr2 #940 pr3 25-run p50 run 1 run 2
Build, Unit Tests, E2E Local: duration of the local work 18.9 17.6 15.4 6.3 (parts) 6.5 (parts)
Build, Unit Tests, E2E Local: green at 19.2 21.7 15.9 16.7 6.8
Downstream jobs start 19.3 23.8-31.4 16.0 16.9-20.8 6.9
E2E Templates end 26.3 37.1 23.9 29.6 13.5
E2E Templates (Windows) end 40.9 39.0 33.8 32.7 26.8
E2E Production (duration) 62.6 (43.3) 83.2 (52.8) 61.0 (43.9) 62.9 (42.3, failed, see below) 50.4 (43.5)
Required checks done 62.6 83.2 ~61 62.9 50.4
Wall clock 66.5 96.3 62.9 63.0 50.5
  • Local parts in run 2 (before check:api moved into Build and Checks; it added ~1.4 min there, still under Local E2E): Build and Checks 3.2, API Check 3.1, Unit shards 5.0 / 5.5 / 5.9, Local E2E 6.5 (critical), then the aggregator 0.1. Each part spends ~2.5 min on npm ci + build.
  • Run 2 had no runner queueing and shows the effect. E2E Production starts 12.4 min earlier and runs just as long, so required checks are done 12.2 min sooner than ci: baseline E2E timing run (do not merge) #940 pr2 and ~10 min sooner than the p50.
  • Run 1 ran while runners were saturated by other runs. Every local part queued 6.2 min before starting, and the aggregator queued another 4.2 min for a runner. That extra hop is a real cost of the aggregator when runners are scarce. Its E2E Production failed in one Agent test on a Bedrock service error (StreamFailedException: Bedrock is unable to process your request., HTTP 500, test preset SMART returns a response). This PR does not touch that job, and the same SHA passed it in run 2.
  • With ci: start the AWS E2E jobs without waiting for unit tests #941 (AWS jobs no longer wait for this check), this change still shortens time-to-green for this required check (~16 -> ~7) and moves Templates up by the same ~10 min.

Test counts

before (#940) after (run 1 and run 2)
unit tests (npm run test:unit vs 3 shards) 6011 (6005 pass, 6 skipped) 6061 (6055 pass, 6 skipped)
local E2E 433 (432 pass, 1 skipped) 433 (432 pass, 1 skipped)
script tests in the build job 10 + 28 + 6 10 + 28 + 6, plus 28 new (unit-test-shard.test.mjs)

Per workspace, the shards match a plain npm run test:unit of the same tree exactly: 63 workspaces, each run once. The +50 is @aws-blocks/core (1546 -> 1596) from #791, which merged after the baseline.

Red check proof

A throwaway commit with a deliberately failing unit test in packages/bb-logger (shard 2) ran in 39872287962. Shard 2 failed. Build, Unit Tests, E2E Local failed (local-unit: failure, "Every part of Build, Unit Tests, E2E Local must succeed."), every E2E job was skipped, and Build and Test failed. The commit was then dropped (force-push back to dff18e9).

Overlaps

Merges clean with #941, #950, #951, #957, #962, #964 and #965: their new steps after "Test the E2E job selection" land in local-build. #966 and #967 insert a step next to the moved check:api / Unit Tests steps, which is a one-line conflict for whichever lands second (put the step in local-build).

The measured runs above were on dff18e9 with E2E: all. The head no longer carries a trailer, so a CI-only push selects no AWS E2E job; the review follow-ups below change only where check:api runs and a test.

Review follow-ups (2026-10-23)

  • check:api runs in Local Build and Checks, and the Local API Check job is gone (d0b96d81).
  • The wiring test runs the aggregator script with crafted needs and does not skip in CI when jq is missing (d0b96d81, 53166632). With exit 1 turned into exit 0, or the failure block deleted, the old test still passed 28/28 and the new one fails.

Build and checks, the API report check, the unit tests (in 3 shards) and
the local E2E suite now run as parallel jobs. Build, Unit Tests, E2E Local
stays as the required check: an always() job that fails unless every part
succeeded, so jobs that need it keep waiting for all of them.

scripts/ci/unit-test-shard.mjs splits the root workspaces so each one runs
in exactly one shard; its test also checks the workflow wiring.

E2E: all
@changeset-bot

changeset-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5316663

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

…haviour

- check:api only needs the build, so it moves into local-build after the
  packed-assets check, and the separate local-api job goes. That saves
  one install and build and one runner per run; local-build stays well
  under Local E2E.
- The wiring test now runs the required check's aggregator script with
  crafted NEEDS: it must exit 0 only when every part succeeded, and 1
  for any failed, skipped, cancelled or missing part. An `exit 0` or a
  dropped failure check used to pass the text-only assertions.
Locally it still skips without jq; in CI a missing jq now fails the test
instead of hiding the check.

@osama-rizk osama-rizk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the last review: 2 resolved · 0 new · 0 still open

  • Resolved: the wiring test now runs the aggregator's own run: block (scripts/ci/unit-test-shard.test.mjs).
  • Resolved: check:api is folded into local-build, and local-api is gone.

Approving. The required check keeps its shape, and the test now guards what the script does, not only its text.

What I verified at 5316663:

  • The test fails on the edits that used to slip through. I applied each of these edits to .github/workflows/pr-checks.yml and ran node --test scripts/ci/unit-test-shard.test.mjs:

    • final exit 1 changed to exit 0;
    • the closing if [ "$failed" != 0 ] ... fi deleted;
    • exit 1 changed to true;
    • != success narrowed to = failure;
    • skipped allowed through;
    • local-e2e dropped from the loop;
    • always() changed to !cancelled().

    Each one fails the test. The unmodified file passes 29/29.

  • The jq fallback behaves as described. With jq off PATH, the new test skips locally and fails when CI (continuous integration) is set, so it can't go quiet on a runner.

  • The aggregator still gates on every part. I extracted the new run: block and ran it against every result combination. Only an all-success run exits 0. A failure, skipped or cancelled part fails it, and so do a missing part and an empty needs. The job is still if: always() and still named "Build, Unit Tests, E2E Local", which is the context the main ruleset requires.

  • No step from the old monolith was lost. I compared the job against main (763f67e). All 19 steps of main's build-and-test-local are still there. Unit Tests and the CDK (Cloud Development Kit) probe check now run as the sharded local-unit versions. "Check API backward compatibility" runs once, in local-build, after the packed-assets check.

  • CI is green. Run 39979839028 at this head passed. Local Build and Checks ran check:api (step 15), and the aggregator test ran rather than skipping. The aggregator log shows the three parts, all success.

  • It merges cleanly. A trial merge with current main has no conflicts, and the test passes 29/29 on the merged tree.

No follow-ups from me. One observation, not a request: with check:api folded in, Local Build and Checks (6m37s) is now about level with the slowest unit shard (6m33s), so wall-clock time is essentially unchanged.

@belaboe
belaboe marked this pull request as ready for review October 26, 2026 13:57
@belaboe
belaboe requested a review from a team as a code owner October 26, 2026 13:57
@belaboe
belaboe merged commit c8ec214 into main Oct 26, 2026
42 checks passed
@belaboe
belaboe deleted the ci/e2e-split-build-local branch October 26, 2026 14:04
This was referenced Oct 27, 2026

This branch was successfully deployed

1 inactive deployment
e2e — 53166632 Deployed Oct 23, 2026 by belaboe via E2E Amplify Interop (Smoke) #3985
agent-bench — c9bff8cf Deployed Oct 22, 2026 by belaboe via bench / oidc-dsql-notes · react #3290
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.

2 participants