Skip to content

Visual Studio Code, rebuilt in Rust

Rust

ci: test every crate on macOS, Linux and Windows on push and PR (#11)

Artur Rokdea82a2ef263
diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml
new file mode 100644
index 00000000000..e19f6e169cc
--- /dev/null
+++ b/.github/actions/setup/action.yml
@@ -0,0 +1,66 @@
+name: Setup
+description: Toolchains, VS Code 1.148.0 in upstream/ (installed, compiled, built-in extensions fetched) and the extension host bundle, as the Studio's reference checkout has them.
+
+runs:
+ using: composite
+ steps:
+ - name: System packages
+ if: runner.os == 'Linux'
+ # port/tools/linux/Dockerfile's list, with libkrb5-dev and libxkbfile-dev for VS Code's native modules.
+ shell: bash
+ # The x64 image's azure.archive.ubuntu.com mirror stalled at ~100 kB/s for 12-15 min in 2 of 3 runs; arm64 uses
+ # ports.ubuntu.com. Fix from awalsh128/cache-apt-pkgs-action docs/caveats.md "Stalled mirrors".
+ run: |
+ sudo sed -i 's#mirror+file:/etc/apt/apt-mirrors.txt#http://archive.ubuntu.com/ubuntu/#' /etc/apt/sources.list.d/ubuntu.sources
+ if [[ $RUNNER_ARCH == X64 ]] && ! grep -q archive.ubuntu.com /etc/apt/sources.list.d/ubuntu.sources; then
+ echo "::warning::apt sources changed layout, still on the image's mirror"
+ fi
+ sudo apt-get update
+ sudo apt-get install -y --no-install-recommends pkg-config clang \
+ libasound2-dev libfontconfig-dev libfreetype-dev libwayland-dev libx11-xcb-dev libxcb1-dev libxkbcommon-x11-dev \
+ libvulkan1 mesa-vulkan-drivers libssl-dev libzstd-dev libdbus-1-dev libwebkit2gtk-4.1-dev libsecret-1-dev \
+ libkrb5-dev libxkbfile-dev xvfb xauth file
+ - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
+ with:
+ node-version: 24
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
+ with:
+ bun-version: 1.4.5
+ # Pinned by SHA, the action no longer reads the toolchain from its ref.
+ - uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
+ with:
+ toolchain: stable
+ # 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.
+ - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
+ with:
+ workspaces: native
+ cache-on-failure: true
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+ # port/patches apply in build-exthost, after this cache, so the key has only what the install and compile read.
+ - id: upstream
+ uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
+ with:
+ path: upstream
+ key: upstream-1.148.0-pnpm12.16.0-node24-${{ runner.os }}-${{ runner.arch }}
+ - name: VS Code 1.148.0
+ if: steps.upstream.outputs.cache-hit != 'true'
+ shell: bash
+ # @vscode/ripgrep's postinstall downloads from the GitHub API, which answers 403 to runners without a token.
+ env:
+ GITHUB_TOKEN: ${{ github.token }}
+ run: |
+ git clone --branch 1.148.0 --depth 1 https://github.com/microsoft/vscode upstream
+ port/tools/fetch-builtin-extensions
+ cd upstream
+ VSCODE_SKIP_NODE_VERSION_CHECK=1 npx -y [email protected] install
+ npx -y [email protected] run compile
+ # 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
+ with:
+ path: upstream
+ key: ${{ steps.upstream.outputs.cache-primary-key }}
+ - shell: bash
+ run: bun port/tools/build-exthost
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 00000000000..ae3eb02ce99
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,89 @@
+name: CI
+
+# The repository checks and every crate's tests on macOS, Linux and Windows. Dispatch runs it on any branch.
+# Outside CI: ui-pair, pixel-check and api-tests need the reference app and a GUI session (port/tools/studio --lane).
+on:
+ push:
+ branches: [main]
+ pull_request:
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+defaults:
+ run:
+ shell: bash
+
+# Debug info is most of target/'s size and nothing in CI reads it; without it the Rust caches fit the 10 GB limit.
+env:
+ CARGO_PROFILE_DEV_DEBUG: 0
+
+jobs:
+ checks:
+ runs-on: ubuntu-24.04
+ timeout-minutes: 20
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
+ with:
+ bun-version: 1.4.5
+ - uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
+ with:
+ toolchain: stable
+ - run: bun port/tools/ledger-check.ts
+ - run: bun test port/tools
+ - run: port/tools/check-licenses
+
+ test:
+ name: test (${{ matrix.os }} ${{ matrix.arch }})
+ strategy:
+ fail-fast: false
+ matrix:
+ include:
+ # app's build.rs renders the Dock icons with Xcode 26's ictool.
+ - os: macos
+ arch: arm64
+ runner: macos-26
+ # Expected red until M23 Linux closes its test gaps (port/ledger.md).
+ - os: linux
+ arch: x64
+ runner: ubuntu-24.04
+ expected-red: true
+ - os: linux
+ arch: arm64
+ runner: ubuntu-24.04-arm
+ expected-red: true
+ # Expected red until M24 Windows fixes its test failures (port/ledger.md).
+ - os: windows
+ arch: x64
+ runner: windows-latest
+ expected-red: true
+ - os: windows
+ arch: arm64
+ runner: windows-11-arm
+ expected-red: true
+ runs-on: ${{ matrix.runner }}
+ continue-on-error: ${{ matrix.expected-red == true }}
+ timeout-minutes: 240
+ steps:
+ # The runners check out with CRLF, which port/patches/*.patch and the tests' fixtures do not expect;
+ # node_modules paths pass MAX_PATH.
+ - if: runner.os == 'Windows'
+ run: git config --global core.autocrlf false && git config --global core.longpaths true
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ - uses: ./.github/actions/setup
+ - name: cargo test
+ working-directory: native
+ # 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)
+ if [[ $RUNNER_OS == Linux ]]; then
+ xvfb-run -a -s '-screen 0 1600x1000x24' "${test[@]}"
+ else
+ "${test[@]}"
+ fi
diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml
index 43ce964d139..5f64d4f1367 100644
--- a/.github/workflows/windows.yml
+++ b/.github/workflows/windows.yml
@@ -29,29 +29,7 @@ jobs:
# node_modules paths pass MAX_PATH.
- run: git config --global core.autocrlf false && git config --global core.longpaths true
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
- with:
- node-version: 24
- - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2
- with:
- bun-version: 1.4.5
- # Pinned by SHA, the action no longer reads the toolchain from its ref.
- - uses: dtolnay/rust-toolchain@39008827e6b4319a349e9a42dfc90579dd25f1ca # stable
- with:
- toolchain: stable
- - uses: Swatinem/rust-cache@d1527c8f67ef9af357290475d4af4b0fab8f12e0 # v2.9.3
- with:
- workspaces: native
- - name: VS Code 1.148.0
- # @vscode/ripgrep's postinstall downloads from the GitHub API, which answers 403 to runners without a token.
- env:
- GITHUB_TOKEN: ${{ github.token }}
- run: |
- git clone --branch 1.148.0 --depth 1 https://github.com/microsoft/vscode upstream
- cd upstream
- VSCODE_SKIP_NODE_VERSION_CHECK=1 npx -y [email protected] install
- npx -y [email protected] run compile
- - run: bun port/tools/build-exthost
+ - uses: ./.github/actions/setup
- run: cargo build --release -p app --locked
working-directory: native
# Every failing test in one run, not only the first failing binary's.
diff --git a/README.md b/README.md
index 5020d8c7b77..adbbd349099 100644
--- a/README.md
+++ b/README.md
@@ -111,6 +111,8 @@ bun port/tools/build-exthost
native/target/release/vsrustium
```
+[CI](.github/workflows/ci.yml) runs the ledger, README coverage and license checks, and `cargo test --workspace` on macOS arm64, Linux x64 and arm64, and Windows x64 and arm64, on every push to main and pull request.
+
`port/tools/package-app` (macOS) and `port/tools/package-linux` make the release app. How the work is tracked and checked: [CONTRIBUTING.md](CONTRIBUTING.md). Security issues: [SECURITY.md](SECURITY.md).
## License
diff --git a/port/notes.md b/port/notes.md
index 105121104c1..dd912d97189 100644
--- a/port/notes.md
+++ b/port/notes.md
@@ -1027,6 +1027,14 @@ What to do (milestone 21, in order):
- Keybindings: `keybindings.rs` `Os` is platform.ts `OperatingSystem`, `OS` the build's; labels, the Electron accelerator and contributed rules (`win`, `mac`, `linux` before `key`, keybindingService.ts `bindToCurrentPlatform`) take it as a parameter so the host tests check Windows. `default-win.json` is the reference's own Windows export ("Developer: Export Default Keybindings" with the platform forced, keybindingsExport.contribution.ts) turned into the port's table by `port/tools/default-keybindings`, which reproduces `default-macos.json` byte for byte from the macOS export; the weights come from the macOS rows. Linux keeps the macOS table until M23 adds `default-linux.json` in `default_table`. Windows has no keyboard mapper yet: labels are the US layout's.
- Menu bar and title bar: on Windows `workbench.rs` `title_bar` adds `menubar.rs` `custom_menubar` at the left and `window_controls` at the right, gated on `keybindings::OS`, so Linux (M23) turns it on by its `OS`. A title opens its `MenubarMainMenu` submenu as the workbench's context menu below it; `compact` opens one menu of the menus. The context keys `isMac`, `isMacNative`, `isWindows` and `isLinux` follow `OS` (`contextkey.rs` `constant_in`), which brings in upstream's Windows-only rows. Difference: Electron's title bar overlay draws the window controls with the system's glyphs; the port draws them with the codicon `chrome-*` glyphs and titlebarpart.css's `.window-icon` hover colors, and marks them with GPUI's `WindowControlArea`, so Windows hit-tests them as caption buttons (`HTMINBUTTON`, `HTMAXBUTTON` with snap layouts, `HTCLOSE`). The rest of the bar is `HTCAPTION`, hit-tested before any listener runs: the menu bar, the command center and the toolbar `occlude` it.
+## CI (.github/workflows/ci.yml)
+
+- Shape compared with two GPUI projects' CI: [zed-industries/zed run_tests.yml](https://github.com/zed-industries/zed/blob/main/.github/workflows/run_tests.yml) (GPL/Apache) runs on paid Namespace and self-hosted runners with sccache in S3 and nextest filtered to the changed crates' dependents, too much infrastructure for a repository on GitHub's free runners; [longbridge/gpui-component ci.yml](https://github.com/longbridge/gpui-component/blob/main/.github/workflows/ci.yml) (Apache-2.0) runs on GitHub's runners with rust-cache saved from main only and `CARGO_PROFILE_DEV_DEBUG=0` to stay under the 10 GB cache limit. The port follows gpui-component: one matrix job per OS and arch, `cargo test --workspace`, caches saved from main only, no debug info.
+- `.github/actions/setup` is shared by ci.yml and windows.yml: the system packages of `port/tools/linux/Dockerfile` on Linux, Node 24, Bun, Rust, rust-cache, and `upstream/` cloned, installed, compiled and with its built-in extensions fetched, cached per OS and arch (1.5 GB each). Tests on Linux run under `xvfb-run`; GPUI's headless renderer takes Mesa's Vulkan.
+- 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 and Windows test jobs are `continue-on-error` until M23 and M24 close their test failures; `checks` 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.
+
## Accepted platform differences
GPUI or Rust std limits Artur accepted as differences from 1.147.0; one line each.
diff --git a/port/tools/fetch-builtin-extensions b/port/tools/fetch-builtin-extensions
index 9d51666cc4d..3da6fb8377b 100755
--- a/port/tools/fetch-builtin-extensions
+++ b/port/tools/fetch-builtin-extensions
@@ -6,7 +6,8 @@ set -euo pipefail
source "$(dirname "$0")/vscode-src.sh"
cd "$VSCODE_SRC"
mkdir -p .build/builtInExtensions
-jq -r '.builtInExtensions[] | "\(.name) \(.version)"' product.json | while read -r name version; do
+# jq on Windows ends lines with CRLF, and the \r in the version made curl exit 3 (malformed URL).
+jq -r '.builtInExtensions[] | "\(.name) \(.version)"' product.json | tr -d '\r' | while read -r name version; do
target=.build/builtInExtensions/$name
if [[ "$(jq -r .version "$target/package.json" 2>/dev/null)" == "$version" ]]; then
continue