From 6af133786067ad5be087366963aa70af2b486447 Mon Sep 17 00:00:00 2001 From: aiongg Date: Tue, 17 Nov 2026 19:00:41 +0000 Subject: [PATCH] ci: nextest on every leg, tests with all features once Every Workspace leg runs nextest with --all-features and the doctests with cargo test --doc. The default-feature test run is gone: it added exactly four tests, all in craft-image-codecs and craft-text (feature-off behaviour), so those two crates run their tests with default features as well. The default-feature compile stays covered by the first clippy run. The resource groups from craft-libs#2058's audit move into the ci profile with platform = 'cfg(unix)', so Linux and macOS share one profile and Windows keeps the groups it already passes with. No separate example build: nextest builds examples as cargo test does, and clippy --all-targets checks them. scripts/test-workspace-tests.py follows the single command set. --- .config/nextest.toml | 26 ++++++++-------- .github/workflows/workspace.yml | 26 ++++++---------- scripts/test-workspace-tests.py | 54 +++++++++++++-------------------- 3 files changed, 44 insertions(+), 62 deletions(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index 5e02e048d..0bc679e47 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -1,6 +1,6 @@ # cargo-nextest (https://nexte.st) runs every test in its own process, in parallel across test -# binaries. Linux and Windows in the Workspace gate use it (.github/workflows/workspace.yml). -# macOS and local runs keep `cargo test`. Both nextest legs also run `cargo test --doc`. +# binaries. Every leg of the Workspace gate uses it (.github/workflows/workspace.yml); local runs may +# keep `cargo test`. Nextest does not run doctests, so the gate also runs `cargo test --doc`. # # cargo nextest run --workspace --profile ci # cargo test --workspace --doc @@ -21,8 +21,9 @@ video-fixtures = { max-threads = 1 } # craft-print: `PRINT_TICKET_PROVIDER` serializes the Windows PrintTicket provider, and the tests # share the one test print queue the gate installs. print = { max-threads = 1 } -# The Linux pilot serializes video integration tests sharing generated fixture directories. -linux-video-fixtures = { max-threads = 1 } +# craft-video integration tests on Linux and macOS: the binaries generate and read the same fixture +# directories (see the `ci` overrides below). +video-integration = { max-threads = 1 } [[profile.default.overrides]] filter = 'package(craft-ui) & (binary(visual_regression) | test(/^combo::tests::|selected_tab_erases_a_baseline_centered_on_its_bottom_edge/))' @@ -44,16 +45,17 @@ fail-fast = false slow-timeout = { period = "60s" } failure-output = "immediate-final" -# Linux-only pilot: keep the established Windows profile unchanged. GPU consumers share one -# process-independent slot; the video integration binaries share fixture directories. This -# deliberately starts conservatively rather than relying on in-process mutexes across binaries. -[profile.ci-linux] -inherits = "ci" -[[profile.ci-linux.overrides]] +# Linux and macOS (the resource audit in craft-libs#2058): every GPU consumer shares the one `gpu` +# slot, and the craft-video integration binaries share their fixture directories. Conservative on +# purpose: the in-process mutexes these tests rely on do not reach across nextest's processes. +# Windows keeps the default groups above, which its leg has passed with since it moved to nextest. +[[profile.ci.overrides]] +platform = 'cfg(unix)' filter = 'package(craft-ui) | package(craft-keymap) | package(craft-update)' test-group = 'gpu' -[[profile.ci-linux.overrides]] +[[profile.ci.overrides]] +platform = 'cfg(unix)' filter = 'package(craft-video) & kind(test)' -test-group = 'linux-video-fixtures' +test-group = 'video-integration' diff --git a/.github/workflows/workspace.yml b/.github/workflows/workspace.yml index e3295d251..554e645ae 100644 --- a/.github/workflows/workspace.yml +++ b/.github/workflows/workspace.yml @@ -25,7 +25,7 @@ jobs: with: os: '["ubuntu-latest","windows-latest","macos-latest"]' timeout-minutes: 120 - # Linux and Windows use nextest with explicit doctests (.config/nextest.toml). + # Every leg runs its tests with nextest, and its doctests with cargo test (.config/nextest.toml). tools: cargo-nextest@0.9.150 packages: mesa-vulkan-drivers libvulkan1 craft-fonts-ref: b076417b5880bd4154bd22f00695b1d28c6bea83 @@ -45,29 +45,21 @@ jobs: cargo fmt --check cargo clippy --workspace --all-targets --locked -- -D warnings cargo clippy --workspace --all-targets --all-features --locked -- -D warnings - if [ "$RUNNER_OS" = Linux ]; then - # Keep example compilation as well as test=true example tests selected by nextest. - cargo build --workspace --examples --locked - cargo nextest run --workspace --locked --profile ci-linux - cargo test --workspace --doc --locked - cargo build --workspace --examples --all-features --locked - cargo nextest run --workspace --all-features --locked --profile ci-linux - cargo test --workspace --doc --all-features --locked - else - cargo test --workspace --locked - cargo test --workspace --all-features --locked - fi + # The tests run once, with every feature, in parallel across test binaries; nextest skips + # doctests, so `cargo test --doc` runs them. The default-feature compile is the first + # clippy run's; the second command runs the crates whose tests check behaviour with a + # feature off, which an all-features build cannot reach. + cargo nextest run --workspace --all-features --locked --profile ci + cargo test --workspace --doc --all-features --locked + cargo nextest run -p craft-image-codecs -p craft-text --locked --profile ci windows-command: | powershell.exe -NoProfile -Command '$ErrorActionPreference = "Stop"; Start-Service Spooler; Add-PrinterDriver -Name "Generic / Text Only"' cargo fmt --check cargo clippy --workspace --all-targets --locked -- -D warnings cargo clippy --workspace --all-targets --all-features --locked -- -D warnings - # The same tests as `cargo test`, run in parallel across test binaries instead of one - # binary at a time; nextest skips doctests, so `cargo test --doc` runs them. - cargo nextest run --workspace --locked --profile ci - cargo test --workspace --doc --locked cargo nextest run --workspace --all-features --locked --profile ci cargo test --workspace --doc --all-features --locked + cargo nextest run -p craft-image-codecs -p craft-text --locked --profile ci msrv: name: Rust 1.95 diff --git a/scripts/test-workspace-tests.py b/scripts/test-workspace-tests.py index f6e55f968..4da52d701 100644 --- a/scripts/test-workspace-tests.py +++ b/scripts/test-workspace-tests.py @@ -40,65 +40,53 @@ COMMON = [ "clippy --workspace --all-targets --locked -- -D warnings", "clippy --workspace --all-targets --all-features --locked -- -D warnings", ] -LINUX = [ - "build --workspace --examples --locked", - "nextest run --workspace --locked --profile ci-linux", - "test --workspace --doc --locked", - "build --workspace --examples --all-features --locked", - "nextest run --workspace --all-features --locked --profile ci-linux", +TESTS = [ + "nextest run --workspace --all-features --locked --profile ci", "test --workspace --doc --all-features --locked", + "nextest run -p craft-image-codecs -p craft-text --locked --profile ci", ] class WorkspaceTests(unittest.TestCase): - def test_linux_keeps_both_feature_sets_examples_and_doctests(self): - result = commands("Linux") - self.assertEqual(result.returncode, 0, result.stderr) - self.assertEqual(result.stdout.splitlines(), COMMON + LINUX) + def test_linux_and_macos_run_one_feature_set_with_doctests(self): + for os_name in ("Linux", "macOS"): + with self.subTest(os=os_name): + result = commands(os_name) + self.assertEqual(result.returncode, 0, result.stderr) + self.assertEqual(result.stdout.splitlines(), COMMON + TESTS) - def test_macos_keeps_cargo_test(self): - result = commands("macOS") - self.assertEqual(result.returncode, 0, result.stderr) - self.assertEqual(result.stdout.splitlines(), COMMON + [ - "test --workspace --locked", "test --workspace --all-features --locked"]) - - def test_each_linux_stage_failure_remains_fatal(self): - for index, command in enumerate(COMMON + LINUX): + def test_each_stage_failure_remains_fatal(self): + for index, command in enumerate(COMMON + TESTS): with self.subTest(command=command): result = commands("Linux", command) self.assertEqual(result.returncode, 17, result.stderr) - self.assertEqual(result.stdout.splitlines(), (COMMON + LINUX)[:index + 1]) + self.assertEqual(result.stdout.splitlines(), (COMMON + TESTS)[:index + 1]) - def test_windows_keeps_its_existing_profile_and_doctests(self): + def test_windows_runs_the_same_cargo_commands(self): source = block(WORKFLOW.read_text(), "windows-command") cargo = [line.strip() for line in source.splitlines() if line.strip().startswith("cargo ")] - self.assertEqual(cargo, ["cargo " + command for command in COMMON + [ - "nextest run --workspace --locked --profile ci", - "test --workspace --doc --locked", - "nextest run --workspace --all-features --locked --profile ci", - "test --workspace --doc --all-features --locked", - ]]) + self.assertEqual(cargo, ["cargo " + command for command in COMMON + TESTS]) - def test_linux_inherits_no_retries_no_filtering_and_existing_failure_policy(self): + def test_ci_profile_keeps_its_failure_policy_without_retries_or_filtering(self): config = tomllib.loads((ROOT / ".config/nextest.toml").read_text()) - self.assertEqual(config["profile"]["ci-linux"]["inherits"], "ci") self.assertIs(config["profile"]["ci"]["fail-fast"], False) for profile in config["profile"].values(): self.assertNotIn("default-filter", profile) self.assertNotIn("retries", profile) self.assertEqual(config["profile"]["ci"]["slow-timeout"], {"period": "60s"}) - def test_linux_resource_groups_are_serial_and_do_not_change_windows(self): + def test_unix_resource_groups_are_serial_and_leave_windows_alone(self): config = tomllib.loads((ROOT / ".config/nextest.toml").read_text()) - overrides = config["profile"]["ci-linux"]["overrides"] + overrides = config["profile"]["ci"]["overrides"] self.assertEqual(overrides, [ - {"filter": "package(craft-ui) | package(craft-keymap) | package(craft-update)", + {"platform": "cfg(unix)", + "filter": "package(craft-ui) | package(craft-keymap) | package(craft-update)", "test-group": "gpu"}, - {"filter": "package(craft-video) & kind(test)", "test-group": "linux-video-fixtures"}, + {"platform": "cfg(unix)", "filter": "package(craft-video) & kind(test)", + "test-group": "video-integration"}, ]) for override in overrides: self.assertEqual(config["test-groups"][override["test-group"]]["max-threads"], 1) - self.assertNotIn("overrides", config["profile"]["ci"]) def test_workflow_stays_shared_and_keeps_platform_gates(self): source = WORKFLOW.read_text()