Skip to content

ci(test): build the macOS server cell's unit tests first, and stop a build-script rebuild loop - #1002

Open
xintaofei wants to merge 3 commits into
mainfrom
ci/macos-lib-tests-first
Open

xintaofei wants to merge 3 commits into
mainfrom
ci/macos-lib-tests-first

Conversation

@xintaofei

@xintaofei xintaofei commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The macOS cells are the slowest in the matrix, and nearly all of their time goes to compiling codeg's own crates. The public-repo macos-latest runner has 3 cores and 7 GB of memory, where Linux and Windows have 4 cores and 16 GB. cargo test compiles codeg_lib twice at the same time: the rlib that the bins and integration tests link, and the lib's own unit-test build. Measured locally with CI's settings (line-tables-only, -j3), both were past 6 GB of physical footprint two and a half minutes in, and still growing. Side by side they do not fit, and the runner swaps.

What

macOS server cell: the lib's unit tests are built on their own first, with cargo test --no-default-features --features server-bin --lib --no-run. The cargo test step that follows finds them fresh and compiles the rlib alone.

The first run of this PR did the same in the desktop cell, which got slower:

macOS job main this PR, first run
server 30 min 15.6 min
desktop 59 min 62 min

The desktop cell's cargo test built the unit tests again. One reason is the build.rs loop fixed below. The other stays: Tauri's generate_context! writes its embedded assets into the build script's out dir during the crate's first compile, after that compile started, so the next cargo run takes them for changes, and a CI job always starts without them. Even reused, the desktop unit-test build alone took 18 minutes, so the desktop cell is back to how it was.

build.rs: sidecar placeholders are no longer rewritten on every build. ensure_sidecar_placeholder watches each sidecar path and wrote the 0-byte placeholder again on every run. Cargo counts a watched file as changed when it is newer than the start of the build script's last run, so wherever the sidecars are placeholders (CI, a fresh clone, a worktree that runs cargo directly), every cargo invocation reran the script and rebuilt every target of the crate. Three cargo check -v in a row without sidecars said Dirty codeg: the file `binaries/codeg-mcp-aarch64-apple-darwin` has changed each time. With the fix, the run after the first is Fresh. An existing placeholder is now left alone and a new one is dated back to 1970. The warning still shows on every build, since cargo replays it when the script does not rerun.

What to look for

The macOS server job near 15 minutes again, and the other jobs at main's times.

🤖 Generated with Claude Code

The macOS runners have 3 cores and 7 GB of memory, and cargo test
compiled codeg_lib twice at once: the rlib the bins and integration
tests link, and the lib's own unit-test build, each several GB on its
own. The desktop and server cells spent most of their time in swap,
compiling for about 47 and 25 minutes against 8 and 4 on Linux.

On macOS those two cells now build the unit tests first with
cargo test --no-run, so the cargo test that follows finds them fresh
and compiles the rlib alone. What gets tested is unchanged.
In this PR's first run the macOS server job took 15.6 minutes instead
of 30, but the desktop job got slower, 62 minutes instead of 59: its
cargo test built the unit tests again. Tauri's generate_context! writes
its embedded assets into the build script's out dir during the crate's
first compile, after that compile started, so the next cargo run takes
them for changes, and a CI job always starts without them. Alone, the
desktop unit-test build still took 18 minutes, so that cell is back to
how it was.
ensure_sidecar_placeholder watched each sidecar path and wrote the
0-byte placeholder again on every run. Cargo counts a watched file as
changed when it is newer than the start of the build script's last run,
so wherever the sidecars were placeholders (CI, a fresh clone, a
worktree that runs cargo directly), every cargo invocation reran the
script and rebuilt every target of the crate, with nothing changed.

An existing placeholder is now left alone, and a new one is dated back
to 1970. The warning still shows on every build: cargo replays it when
the script does not rerun.
@xintaofei xintaofei changed the title ci(test): build the lib's unit tests on their own first on macOS ci(test): build the macOS server cell's unit tests first, and stop a build-script rebuild loop Oct 21, 2026
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