Skip to content

armgit / 67.js

Public Imported from GitHub
0

3D engine that AI agents drive

Spread the unit tests over six shards and store the measured CI coverage as the baseline (issue #560)

Nguyen Xuan An31e10327c730
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index e7846f04..d9f96a59 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -48,20 +48,20 @@ jobs:
- run: npm run tool-cost -- --base "$SIZE_BASE_REF"
# `node --test` already runs every file in its own process (Node 24 default, --test-isolation=process), so one pass over
- # the files is also the isolation check. Three shards keep each runner under a minute of tests.
+ # the files is also the isolation check. Six shards, because the light bake tests are heavy and sit next to each other in the file list.
unit:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
- shard: [1, 2, 3]
+ shard: [1, 2, 3, 4, 5, 6]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./.github/actions/setup
# The live MCP tests need build/ and build/mcp.
- run: npm run build:lib
- - run: mkdir -p coverage && npm run test:coverage -- --test-shard=${{ matrix.shard }}/3 --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/shard-${{ matrix.shard }}.info
+ - run: mkdir -p coverage && npm run test:coverage -- --test-shard=${{ matrix.shard }}/6 --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=coverage/shard-${{ matrix.shard }}.info
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with:
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 6fa7276f..1baa8d86 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -35,7 +35,7 @@ Run `npm run smoke` or the `smoke:*` script for the area that you changed, and l
A change to skinning, glTF loading, poses or IK also needs `npm run smoke:character`, which takes a real character through the MCP server. Run `npm run prepare:release` first.
Screenshots and other output go to `artifacts/`, which Git ignores.
-Every pull request runs `npm audit`, `npm run size`, `npm run tool-cost`, `npm test` (with coverage, three shards; Node runs each file in its own process), `prepare:release`, `smoke:package` and `smoke:mcp-package` in the `Test` workflow. `smoke:mcp-package` draws through the MCP server on SwiftShader in Chrome. `npm run size` compares every bundle with `origin/main`. If a bundle grows past its allowance (64 bytes gzip for core and the scenes, 2% for the npm archive), add `changes/<issue>.size.md` with the line `- entry:core: <why it is worth the bytes>` and say why in the pull request. Never edit `bench/size/budgets.json` or `baseline.json` in a pull request. `bench/size/README.md` has the details.
+Every pull request runs `npm audit`, `npm run size`, `npm run tool-cost`, `npm test` (with coverage, six shards; Node runs each file in its own process), `prepare:release`, `smoke:package` and `smoke:mcp-package` in the `Test` workflow. `smoke:mcp-package` draws through the MCP server on SwiftShader in Chrome. `npm run size` compares every bundle with `origin/main`. If a bundle grows past its allowance (64 bytes gzip for core and the scenes, 2% for the npm archive), add `changes/<issue>.size.md` with the line `- entry:core: <why it is worth the bytes>` and say why in the pull request. Never edit `bench/size/budgets.json` or `baseline.json` in a pull request. `bench/size/README.md` has the details.
`npm run tool-cost` does the same for what the MCP tools cost an agent. If a tool schema grows by more than 64 bytes, a typical result by more than 128 bytes, or the schema total by more than 128 bytes, first move rare detail into `scene_capabilities` or a shared schema. If the growth is worth it, add a line to `changes/<issue>.size.md`, such as `- tool:scene_create: <why it is worth the bytes>`, `- tool-total: <why>` or `- result:scene_capabilities: <why>`. Never edit `bench/tool-cost-budgets.json` in a pull request. `bench/tool-cost/README.md` has the details.
diff --git a/changes/560.md b/changes/560.md
index 91e84c20..cbd06609 100644
--- a/changes/560.md
+++ b/changes/560.md
@@ -1 +1 @@
-- Split the `Test` workflow into parallel jobs (audit, size and tool cost, three unit shards, coverage, package smokes) behind one final `test` job that branch protection keeps requiring, with a shared `.github/actions/setup`. Unit tests now run with Node's built-in coverage; `scripts/coverage-gate.mjs` merges the shard lcov files, writes the job summary and fails when line, branch or function coverage drops more than 0.5 points below `coverage-baseline.json`. `npm run test:isolated` left CI because `node --test` already runs each file in its own process. `publish.yml` calls `test.yml` before publishing and checks `npm view` afterwards. See `docs/ci.md` (issue #560).
+- Split the `Test` workflow into parallel jobs (audit, size and tool cost, six unit shards, coverage, package smokes) behind one final `test` job that branch protection keeps requiring, with a shared `.github/actions/setup`. Unit tests now run with Node's built-in coverage; `scripts/coverage-gate.mjs` merges the shard lcov files, writes the job summary and fails when line, branch or function coverage drops more than 0.5 points below `coverage-baseline.json`. `npm run test:isolated` left CI because `node --test` already runs each file in its own process. `publish.yml` calls `test.yml` before publishing and checks `npm view` afterwards. See `docs/ci.md` (issue #560).
diff --git a/coverage-baseline.json b/coverage-baseline.json
index d62009c2..aee3ff8f 100644
--- a/coverage-baseline.json
+++ b/coverage-baseline.json
@@ -1 +1 @@
-{"lines":0,"branches":0,"functions":0}
+{"lines":93.81,"branches":83.91,"functions":93.77}
diff --git a/docs/ci.md b/docs/ci.md
index 8e0ae883..0b7aa506 100644
--- a/docs/ci.md
+++ b/docs/ci.md
@@ -10,7 +10,7 @@ All jobs start at once.
| --- | --- |
| `audit` | `npm audit --audit-level=high` |
| `size` | `npm run size` and `npm run tool-cost` against the pull request base (pull requests only; a release has no base) |
-| `unit` (3 shards) | `npm run build:lib`, then `npm run test:coverage` on one third of the test files; uploads its lcov |
+| `unit` (6 shards) | `npm run build:lib`, then `npm run test:coverage` on one third of the test files; uploads its lcov |
| `coverage` | merges the shard lcov files, writes the summary, compares with `coverage-baseline.json`, uploads `lcov` |
| `package` | `prepare:release`, `check:links:package`, `smoke:package`, `smoke:mcp-package` |
| `test` | waits for every job above and fails unless each one succeeded. Branch protection on `main` requires this name. |