Skip to content

rust-test

cargo-nextest-driven test runs for a Rust workspace. Linux is the always-on baseline (test-linux); three opt-in extensions add jobs for projects that need them. All Linux-runner jobs share the disk-pressure tuning that broke a prior rust-tool-base pipeline on a SaaS medium runner: CARGO_INCREMENTAL=0, CARGO_PROFILE_DEV_DEBUG/CARGO_PROFILE_TEST_DEBUG = "line-tables-only", and stripping target/debug/incremental on entry.

The Linux jobs run on rust-tools (bakes cargo-nextest + cargo-llvm-cov, no runtime install). The cross-OS (macOS/Windows) jobs still binstall on their own runners.

Jobs

Job Always on? What it runs
test-linux yes cargo nextest run --workspace $[[ inputs.features ]] $[[ inputs.nextest_extra ]]
test-macos, test-windows opt-in (enable_cross_os) binstalls cargo-nextest on a saas-macos/saas-windows runner, cargo nextest run --workspace. allow_failure: true; gated behind $RUN_CROSS_OS_TESTS == "true" so they stay dormant until eligible runners exist.
test-integration opt-in (enable_integration) cargo nextest run $[[ inputs.integration_features ]] against a docker:27-dind service, for testcontainers-style suites.

Coverage comes out of the test run

With enable_coverage: true, test-linux runs the suite under cargo llvm-cov nextest --no-report, then writes lcov.info and enforces coverage_threshold. It is the same suite, the same workspace and the same features — llvm-cov collects while the tests run.

Until 2026-09-05 a separate coverage job did its own cargo llvm-cov nextest over the same workspace, so every pipeline in a coverage-enabled project ran the whole suite twice. All twelve consumers have coverage enabled. Measured over the 21 days to 2026-09-03, coverage cost 721 runner minutes and test-linux 590, together 8.4% of the estate's merge-request minutes.

If you referenced the coverage job by name in needs: or a rule, point it at test-linux. No consumer did when this changed.

Inputs

Input Type Default Description
image string rust-tools:v0.1.2 Image for the Linux test jobs.
stage string test GitLab CI stage.
if string '$CI_PIPELINE_SOURCE == "merge_request_event"' Gating rules:if: for test-linux.
changes array ["**/*.rs", "**/Cargo.toml", "Cargo.lock", "rustfmt.toml", "rust-toolchain.toml", ".gitlab-ci.yml"] Change-detection paths — applies to every test job in this component.
features string "--all-features" Feature flags for the Linux test run.
nextest_extra string "" Extra arguments appended to cargo nextest run (e.g. a binary filter).
binstall_version string "" DEPRECATED / ignored on the default image (cargo-nextest is baked).
enable_cross_os boolean false Adds test-macos + test-windows.
enable_integration boolean false Adds test-integration with a docker:dind service.
integration_features string "--features integration" Feature flag(s) for the integration job.
integration_extra string "" Extra arguments for the integration cargo nextest run.
enable_coverage boolean false Runs test-linux under cargo llvm-cov and fails below coverage_threshold. Not a separate job — see below.
coverage_threshold number 70 --fail-under-lines threshold.
coverage_regex string '/^\s*TOTAL\s+\|.*\s(\d+\.\d+)%/' Regex for the coverage badge.
extra_before_script string "" Shell snippet prepended to each Linux job's before_script.
resource_group string "$CI_PROJECT_PATH_SLUG-rust-compile" Serialises the compile-heavy Linux jobs (test-linux/test-integration) onto one project-scoped group (shared with rust-lint/rust-docs). Cross-OS jobs exempt; project-scoped, never affects other projects.

Usage

include:
  - component: gitlab.com/phpboyscout/cicd/[email protected]
    inputs:
      enable_coverage: true
      coverage_threshold: 80

See also