CI: check the launcher's workspace on every push to main and on pull requests that touch it
verify's cargo runs never build launcher/ (its own workspace), so #2059 and the registry ratings commit each passed alone and left main's launcher failing to compile (E0061). The new launcher job runs its rustfmt, clippy -D warnings and lib tests when a pull request changes the launcher, a crate it builds or the root manifests, and on every push to main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -73,6 +73,42 @@ jobs:
|
||||
run: |
|
||||
cargo +stable test --workspace --lib --bins --tests --features horizon-client/mods,horizon-mods/pack
|
||||
cargo +stable test --workspace --doc --features horizon-client/mods,horizon-mods/pack
|
||||
# The launcher is its own workspace (launcher/Cargo.toml), so verify's cargo runs never build it. A pull request that
|
||||
# changes it or a crate it builds is checked here, and so is every push to main: two pull requests can each pass
|
||||
# alone and break it together (#2059 and the registry ratings did, 2026-10-26).
|
||||
launcher:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Does this pull request change the launcher or a crate it builds?
|
||||
if: github.event_name == 'pull_request'
|
||||
id: launcher
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
run: python3 tools/ci/rust_changes.py --launcher "$BASE_SHA" "$HEAD_SHA" >> "$GITHUB_OUTPUT"
|
||||
- name: Install Rust and the headers GPUI links against
|
||||
if: steps.launcher.outputs.required != 'false'
|
||||
run: |
|
||||
sudo apt-get update && sudo apt-get install -y --no-install-recommends libxkbcommon-x11-dev libwayland-dev \
|
||||
libx11-xcb-dev libfontconfig-dev libvulkan-dev libasound2-dev libudev-dev
|
||||
rustup toolchain install stable --profile minimal --component rustfmt --component clippy
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
if: steps.launcher.outputs.required != 'false'
|
||||
with:
|
||||
workspaces: launcher
|
||||
shared-key: launcher
|
||||
save-if: ${{ github.ref == 'refs/heads/main' }}
|
||||
- name: Check the launcher's formatting, lint and tests
|
||||
if: steps.launcher.outputs.required != 'false'
|
||||
working-directory: launcher
|
||||
run: |
|
||||
cargo +stable fmt --check
|
||||
cargo +stable clippy --all-targets --locked -- -D warnings
|
||||
cargo +stable test --locked --lib
|
||||
# Most pull requests leave the harnesses to parity-main, which runs them on main a batch of merges at a time
|
||||
# (.github/workflows/parity-main.yml; releases wait for it). A pull request still runs them itself when it changes
|
||||
# a harness, an oracle, a probe or the runner, or carries the run-parity label (run-parity.yml, when it is added).
|
||||
|
||||
@@ -4,7 +4,7 @@ import subprocess
|
||||
import tempfile
|
||||
import unittest
|
||||
|
||||
from tools.ci.rust_changes import changed_paths, needs_rust
|
||||
from tools.ci.rust_changes import changed_paths, needs_launcher, needs_rust
|
||||
|
||||
|
||||
class RustChangesTests(unittest.TestCase):
|
||||
@@ -21,6 +21,17 @@ class RustChangesTests(unittest.TestCase):
|
||||
with self.subTest(path=path):
|
||||
self.assertTrue(needs_rust(["README.md", path]))
|
||||
|
||||
def test_launcher_checks_follow_the_crates_it_builds(self):
|
||||
for path in ["crates/horizon-client/src/game.rs", "launcher/links.json", "launcher/docs/a.md",
|
||||
"launcher/README.md", "website/src/index.html", "tools/pr_ready.py"]:
|
||||
with self.subTest(path=path):
|
||||
self.assertFalse(needs_launcher([path]))
|
||||
for path in ["launcher/src/main.rs", "launcher/Cargo.lock", "crates/horizon-port-pack/src/net.rs",
|
||||
"crates/horizon-theme/src/lib.rs", "Cargo.toml", "Cargo.lock",
|
||||
".github/workflows/ci.yml"]:
|
||||
with self.subTest(path=path):
|
||||
self.assertTrue(needs_launcher(["README.md", path]))
|
||||
|
||||
def test_moving_source_into_docs_still_requires_rust(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
def git(*args):
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Keep verify's Rust steps for any change beyond website content or documentation."""
|
||||
"""Keep verify's Rust steps for any change beyond website content or documentation.
|
||||
|
||||
--launcher: whether the change is built into the launcher, its own workspace (release_train.LAUNCHER_PATHS).
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
import release_train # noqa: E402
|
||||
|
||||
# The root workspace's manifest and toolchain files: the launcher's path crates inherit from them.
|
||||
ROOT_RUST = {"Cargo.toml", "Cargo.lock", "rust-toolchain.toml", "rustfmt.toml", "clippy.toml"}
|
||||
# The check itself: a change to it runs it.
|
||||
LAUNCHER_CHECK = {".github/workflows/ci.yml", "tools/ci/rust_changes.py", "tools/release_train.py"}
|
||||
|
||||
|
||||
def needs_rust(paths):
|
||||
@@ -12,6 +25,14 @@ def needs_rust(paths):
|
||||
) for path in paths)
|
||||
|
||||
|
||||
def needs_launcher(paths):
|
||||
return any(path in ROOT_RUST or path in LAUNCHER_CHECK or (
|
||||
path.startswith(tuple(release_train.LAUNCHER_PATHS))
|
||||
and not path.startswith(tuple(release_train.LAUNCHER_IGNORED))
|
||||
and not path.endswith(".md")
|
||||
) for path in paths)
|
||||
|
||||
|
||||
def changed_paths(base, head):
|
||||
# Renames must include deletions too: moving source into docs still affects Rust.
|
||||
output = subprocess.check_output([
|
||||
@@ -24,5 +45,7 @@ if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("base")
|
||||
parser.add_argument("head")
|
||||
parser.add_argument("--launcher", action="store_true", help="answer for the launcher instead")
|
||||
args = parser.parse_args()
|
||||
print(f"required={str(needs_rust(changed_paths(args.base, args.head))).lower()}")
|
||||
needs = needs_launcher if args.launcher else needs_rust
|
||||
print(f"required={str(needs(changed_paths(args.base, args.head))).lower()}")
|
||||
|
||||
Reference in New Issue
Block a user