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
dev-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 |
opt-in (enable_coverage) |
cargo llvm-cov nextest --workspace … --lcov, then cargo llvm-cov report --fail-under-lines $[[ inputs.coverage_threshold ]]. Cobertura artifact for the GitLab coverage badge. |
Inputs¶
| Input | Type | Default | Description |
|---|---|---|---|
image |
string | dev-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 |
Adds the coverage job. |
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. |
Usage¶
include:
- component: gitlab.com/phpboyscout/cicd/[email protected]
inputs:
enable_coverage: true
coverage_threshold: 80