Skip to content

Visual Studio Code, rebuilt in Rust

Rust

ci: cut the macOS test build with an incremental cache (#43)

Artur Rok250575db6d84
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml
index 71c98c7330e..9f6daed89e7 100644
--- a/.github/actions/setup/action.yml
+++ b/.github/actions/setup/action.yml
@@ -38,10 +38,21 @@ runs:
with:
toolchain: stable
components: clippy
+ - id: zig
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ${{ runner.temp }}/zig-0.17.1
+ key: zig-0.17.1-${{ runner.os }}-${{ runner.arch }}
- name: Zig 0.17.1
# libghostty-vt-sys's build.rs builds libghostty-vt with it.
shell: bash
+ env:
+ CACHE_HIT: ${{ steps.zig.outputs.cache-hit }}
run: |
+ echo "$RUNNER_TEMP/zig-0.17.1" >> "$GITHUB_PATH"
+ if [[ $CACHE_HIT == true ]]; then
+ exit 0
+ fi
case "$RUNNER_OS-$RUNNER_ARCH" in
macOS-ARM64) zig=zig-aarch64-macos-0.17.1.tar.xz sha=75f1bc7a1e9852f17ec9a0c1895f767c4ec56d46bc8a834920eece1d0359dd8d ;;
Linux-X64) zig=zig-x86_64-linux-0.17.1.tar.xz sha=3581863e3cbcfd0fce0efc682ce7e9e93da96668a977791d356a26d2a7e9b17a ;;
@@ -57,7 +68,12 @@ runs:
*.zip) unzip -q "$RUNNER_TEMP/$zig" -d "$RUNNER_TEMP"; dir=${zig%.zip} ;;
*) tar xJf "$RUNNER_TEMP/$zig" -C "$RUNNER_TEMP"; dir=${zig%.tar.xz} ;;
esac
- echo "$RUNNER_TEMP/$dir" >> "$GITHUB_PATH"
+ mv "$RUNNER_TEMP/$dir" "$RUNNER_TEMP/zig-0.17.1"
+ - if: steps.zig.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: ${{ runner.temp }}/zig-0.17.1
+ key: ${{ steps.zig.outputs.cache-primary-key }}
# Saved on failure too: the Windows and Linux tests are red today and would otherwise rebuild from scratch each run.
# Saved from main only, as longbridge/gpui-component's CI does: five jobs' Rust and upstream caches pass the 10 GB
# repository limit, and a pull request's caches, scoped to its ref, would evict main's.
@@ -72,7 +88,7 @@ runs:
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: upstream
- key: upstream-1.148.0-pnpm12.16.0-node24-${{ runner.os }}-${{ runner.arch }}
+ key: upstream-1.148.0-pnpm12.16.0-node24-trimmed-${{ runner.os }}-${{ runner.arch }}
- name: VS Code 1.148.0
if: steps.upstream.outputs.cache-hit != 'true'
shell: bash
@@ -85,6 +101,8 @@ runs:
cd upstream
VSCODE_SKIP_NODE_VERSION_CHECK=1 npx -y [email protected] install
npx -y [email protected] run compile
+ # Nothing the tests, build-exthost or the smoke run read (port/notes.md "CI"): about half of the cache.
+ rm -rf .git out build/node_modules node_modules/.pnpm/{electron@,@openai+codex,@github+copilot,@anthropic-ai+claude-agent-sdk,@microsoft+copilot-sdk,foundry-local-sdk}*
# Saved here, not in a post step, so a failing test run later in the job still keeps it.
- if: steps.upstream.outputs.cache-hit != 'true' && github.ref == 'refs/heads/main'
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 13a8e6df306..65f9ebb2579 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -129,8 +129,20 @@ jobs:
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: ./.github/actions/setup
+ # rustc's incremental state of the workspace crates, which rust-cache drops: app is one 316k-line crate and its
+ # rebuild is most of the job (port/notes.md "CI"). macOS only: the critical path, and the 10 GB cache limit.
+ - id: incremental
+ if: matrix.os == 'macos'
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: native/target/debug/incremental
+ key: incremental-test-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('native/rust-toolchain.toml') }}-${{ github.sha }}
+ restore-keys: incremental-test-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('native/rust-toolchain.toml') }}-
- name: cargo test
working-directory: native
+ # Overrides rust-cache's CARGO_INCREMENTAL=0.
+ env:
+ CARGO_INCREMENTAL: ${{ matrix.os == 'macos' && '1' || '0' }}
# The dialog, keyboard and system-wide keybinding tests open X11 windows; GPUI's headless renderer uses Mesa's Vulkan.
run: |
test=(cargo test --workspace --locked --no-fail-fast)
@@ -139,3 +151,9 @@ jobs:
else
"${test[@]}"
fi
+ # Before rust-cache's post step, which deletes the directory. A red test run still built it.
+ - if: matrix.os == 'macos' && !cancelled() && github.ref == 'refs/heads/main'
+ uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: native/target/debug/incremental
+ key: ${{ steps.incremental.outputs.cache-primary-key }}
diff --git a/port/notes.md b/port/notes.md
index 9115ed36f20..1f6ee2e3929 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -1064,6 +1064,7 @@ What to do (milestone 21, in order):
- Linux x64's apt downloads stalled at ~100 kB/s on the image's `azure.archive.ubuntu.com` mirror (12 and 15 min in 2 of 3 runs). [awalsh128/cache-apt-pkgs-action](https://github.com/awalsh128/cache-apt-pkgs-action) (Apache-2.0) caches the packages' files but restores neither dpkg's database nor the postinst triggers WebKitGTK and Mesa need, and its docs name the same stall with the fix the setup takes: apt pointed at `archive.ubuntu.com`. arm64 already uses `ports.ubuntu.com`.
- Linux test jobs are `continue-on-error` until M23 closes its test failures; `checks`, the `safety` jobs and the macOS tests fail the run. Outside CI: ui-pair, pixel-check and api-tests, which drive the reference app in a GUI session on the Studio.
- Speed (fast-ci, 6 push runs before the change): the wall clock is the macOS test job, p50 1004 s and p90 1725 s. In its run on 06ecd24b0eb: setup 139 s (96 s of it restoring the 1.5 GB `upstream/` cache), clippy 261 s, `cargo test` 714 s (about 450 s building, 238 s of app tests), cache save 40 s. Clippy moved to its own `safety` job, off that path. Windows left ci.yml while M24 is paused (Artur): its four caches (4.6 GB) and the other five passed the 10 GB repository limit, so GitHub evicted macOS's Rust cache and every few runs macOS set up cold (setup p90 1022 s).
+- Speed, second pass (fast-ci, 11 pull request runs): the macOS test job, p50 951 s and p90 1446 s. In run 46881836418: restoring `upstream/` 75 s, rust-cache 35 s, Zig 13 s, building 439 s (about 374 s of it the `app` crate, which rust-cache never keeps) and app tests 234 s. Three changes. The macOS test job caches `native/target/debug/incremental` (767 MiB, saved from main) and builds with `CARGO_INCREMENTAL=1`: on the Studio the workspace rebuild after a fresh checkout went from 77 s to 20 s. The `upstream/` cache drops `.git`, `out`, `build/node_modules` and the Electron, Codex, Copilot, Claude Agent SDK and Foundry packages after the compile, 4.0 of 7.7 GB on the Studio's tree, with `cargo test --workspace` green on the trimmed copy; that makes the room the incremental cache needs under the 10 GB limit. Zig comes from a cache instead of a download. Not taken: a macOS runner on the Studio (Artur).
## Documents and guardrails (branch worktree-docs)