Skip to content

Visual Studio Code, rebuilt in Rust

Rust

ci: skip the Rust jobs on pull requests that change only documents (#77)

Artur Rokc299688227cb
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 65f9ebb2579..35bef8c1218 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,6 +1,7 @@
name: CI
# The repository checks, every crate's tests and a smoke run of the app on macOS and Linux. Dispatch runs it on any branch.
+# A pull request that changes only documents runs `checks` alone (port/tools/ci-changes).
# Outside CI: ui-pair, pixel-check and api-tests need the reference app and a GUI session (port/tools/studio --lane).
on:
push:
@@ -24,6 +25,24 @@ env:
CARGO_PROFILE_DEV_DEBUG: 0
jobs:
+ changes:
+ runs-on: ubuntu-24.04
+ timeout-minutes: 5
+ outputs:
+ rust: ${{ steps.paths.outputs.rust }}
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ # A pull request's checkout is its merge commit: the first parent is the base.
+ fetch-depth: 2
+ - id: paths
+ run: |
+ if [[ $GITHUB_EVENT_NAME == pull_request ]]; then
+ git diff --name-only HEAD^1 HEAD | port/tools/ci-changes
+ else
+ echo rust=true
+ fi | tee -a "$GITHUB_OUTPUT"
+
checks:
runs-on: ubuntu-24.04
timeout-minutes: 20
@@ -51,6 +70,8 @@ jobs:
# with the test build, and inside the macOS test job it added 261 s to the run. Not expected red on any OS.
safety:
name: SAFETY comments (${{ matrix.os }} ${{ matrix.arch }})
+ needs: changes
+ if: needs.changes.outputs.rust == 'true'
strategy:
fail-fast: false
matrix:
@@ -79,6 +100,8 @@ jobs:
# The dev build, from the test job's Rust cache: a release cache does not fit the 10 GB limit. Not expected red.
smoke:
name: smoke (${{ matrix.os }} ${{ matrix.arch }})
+ needs: changes
+ if: needs.changes.outputs.rust == 'true'
strategy:
fail-fast: false
matrix:
@@ -104,6 +127,8 @@ jobs:
test:
name: test (${{ matrix.os }} ${{ matrix.arch }})
+ needs: changes
+ if: needs.changes.outputs.rust == 'true'
strategy:
fail-fast: false
matrix:
diff --git a/port/notes.md b/port/notes.md
index ceee00049e8..f069151739b 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -1063,6 +1063,7 @@ What to do (milestone 21, in order):
- macOS runs on `macos-26`: app's build.rs renders the Dock icons with Xcode 26's `ictool`, which `macos-15` lacks.
- 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.
+- Affected only: the `changes` job gives `port/tools/ci-changes` the pull request's changed paths, and the `safety`, `smoke` and `test` jobs run only when it prints `rust=true`. It prints `false` only when every path is on its list of documents, agent files and README pictures, so a new kind of file runs everything; `checks` (ledger-check, docs-check) always runs, and so does every job on `main`. As zed's run_tests.yml `orchestrate` job does with its path filters. One switch, not one per crate: app depends on every crate and is most of the build.
- 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).
diff --git a/port/tools/ci-changes b/port/tools/ci-changes
new file mode 100755
index 00000000000..6a9f160657d
--- /dev/null
+++ b/port/tools/ci-changes
@@ -0,0 +1,16 @@
+#!/bin/bash
+# Reads a pull request's changed paths on stdin and prints `rust=true|false` for ci.yml's `changes` job:
+# false only when every path is a document, an agent file or a picture no build reads. Any other path, and no path at all, is true.
+set -euo pipefail
+rust=false
+count=0
+while IFS= read -r path; do
+ count=$((count + 1))
+ case "$path" in
+ native/* | port/patches/*) rust=true ;;
+ *.md | docs/* | .agents/* | port/assets/* | port/plans/* | LICENSE.txt | .github/FUNDING.yml) ;;
+ *) rust=true ;;
+ esac
+done
+[[ $count -gt 0 ]] || rust=true
+echo "rust=$rust"
diff --git a/port/tools/ci-changes.test.ts b/port/tools/ci-changes.test.ts
new file mode 100644
index 00000000000..3ea5aa1aa28
--- /dev/null
+++ b/port/tools/ci-changes.test.ts
@@ -0,0 +1,22 @@
+import { expect, test } from 'bun:test';
+import { join } from 'node:path';
+
+function rust(paths: string[]) {
+ const run = Bun.spawnSync(['bash', join(import.meta.dir, 'ci-changes')], { stdin: Buffer.from(paths.map(path => `${path}\n`).join('')) });
+ expect(run.exitCode).toBe(0);
+ return run.stdout.toString();
+}
+
+test('documents, agent files and README pictures skip the Rust jobs', () => {
+ expect(rust(['README.md', 'AGENTS.md', 'docs/performance.md', 'port/notes.md', 'port/ledger.md', '.agents/skills/pr/SKILL.md', 'port/assets/icon.png', 'port/plans/a.md'])).toBe('rust=false\n');
+});
+
+test('one path outside the list runs them, whatever it is', () => {
+ for (const path of ['native/crates/app/src/main.rs', 'native/crates/app/src/workbench/walkthrough_part/vs_code_editor_walkthrough.md', 'port/patches/a.md', 'port/product.json', 'port/AppIcon.icon/icon.json', '.github/workflows/ci.yml', 'port/tools/ci-changes', 'flake.nix', 'new-folder/file']) {
+ expect(rust(['README.md', path])).toBe('rust=true\n');
+ }
+});
+
+test('no path at all runs them', () => {
+ expect(rust([])).toBe('rust=true\n');
+});