Skip to content

ci(test): run suites against pre-built dist to skip repeated rebuilds - #587

Merged
Astro-Han merged 1 commit into
mainfrom
ci/test-skip-rebuild
Jul 6, 2026
Merged

Astro-Han merged 1 commit into
mainfrom
ci/test-skip-rebuild

Conversation

@Astro-Han

Copy link
Copy Markdown
Contributor

Summary

CI test job ran npm run build and then npm run test. The root test script delegates to each workspace's own test, which all do clean && build first, so the dist just built got thrown away and every package was rebuilt a second time. Build effectively ran twice in the job.

Adds a test:dist script that assumes npm run build already ran and runs the suites directly against dist, and switches the CI test job to it.

Why

The test job was the CI bottleneck (~185s wall, vs ~91s for typecheck/e2e), and most of its test step (~111s) was rebuild, not testing. The repeated build is pure waste.

Measured on the last green run:

step before
npm run build 44s
npm run test (incl. per-workspace clean+build+test) 111s

Scope

Changed:

  • package.json: new test:dist script.
  • .github/workflows/ci.yml: test job runs build then test:dist instead of test.

Not included:

  • typecheck and e2e jobs untouched.
  • The original test script is kept as-is so local npm test / npm --workspace X test stays self-contained (still clean+build+test per workspace).

How test:dist is built

  • The six node packages run node --test "dist/**/*.test.js" in their own workspace cwd (same glob and cwd as their test script), so no rebuild and behavior is identical.
  • headless reuses scripts/run-headless-tests.mjs (git-config isolation).
  • desktop keeps its own test script (clean:main && build:main && node --test dist/main). Its main tests import renderer modules that tsc emits under dist/renderer during build:main, which the subsequent build:renderer (vite) clears. So desktop must re-run build:main before testing — this is inherent to how the package is wired, not something to fold into the skip.

Verification

In a clean worktree (branch off main):

  • npm run build then npm run test:dist → 4863 tests, 0 fail, exit 0, ~25s.
  • Per-package test counts match running each workspace's own test (same globs/scripts).
  • The earlier root-relative-glob variant failed one storage test and all desktop main tests because process.cwd() differed; the -w form restores each workspace's cwd and they pass.

Expected CI effect: test job step test:dist ≈ 25–35s instead of 111s; job wall roughly halved.

User-facing impact

None. CI/dev scripts only; no shipped behavior change.

Reviewer notes

  • The one non-obvious bit is why desktop is special (see above). It is not skipped out of laziness; its main tests structurally depend on tsc side-effects that vite wipes.
  • test:dist requires a prior npm run build; the CI job keeps the build step right before it, and a comment notes this.

Checklist

  • Scope matches the PR title and excludes unrelated changes
  • Verification lists commands/results
  • User-facing impact: none
  • Risk/review focus: desktop's retained rebuild is called out
  • UI changes: n/a

The CI test job ran `npm run build` and then `npm run test`, but the root
`test` script delegates to each workspace's own `test`, which all do
`clean && build` first. That discarded the dist just built and rebuilt
every package a second time, so the build effectively ran twice in one job
(~44s build + ~111s test, the latter mostly rebuild).

Add `test:dist`: assumes `npm run build` already ran, runs the suites
directly against dist. The six node packages run `node --test` against
their dist; headless reuses its git-isolated runner; desktop keeps its own
`test` script, because its main tests import renderer modules that `tsc`
emits under dist/renderer during `build:main`, which the subsequent
`build:renderer` (vite) clears — so desktop must `clean:main && build:main`
once more to re-materialize them before testing.

Local run: test:dist 4863 tests / 0 fail in ~25s, versus the old
rebuild+test ~111s.
@Astro-Han
Astro-Han merged commit 74b4c78 into main Jul 6, 2026
3 checks passed
@Astro-Han
Astro-Han deleted the ci/test-skip-rebuild branch July 14, 2026 05:05
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