Rust project
Help me get started with Tuist. Follow the setup at:
https://tuist.dev/en/docs/guides/get-started/rust-project
Prerequisites#
- A Rust project built with Cargo.
- The Tuist CLI and a Tuist account.
- cargo-nextest to report individual test results and split tests across CI workers.
Tuist works with your existing Cargo project. You don't need to add a Rust dependency or change how your project builds.
Nextest gives Tuist individual test results, durations, and retry history. It also lets you build tests once and run them on multiple CI workers. You only need nextest for test insights and sharding, not for build insights.
Connect the project#
Install the Tuist CLI and Rust. Create a project in the dashboard with Cargo (Rust) as its build system. Add a tuist.toml at your repository root:
project = "account/project"
# url = "https://your-tuist-server.example.com"
Log in with tuist auth login, then run your usual Cargo commands through Tuist. In CI, set TUIST_TOKEN to a project token. You can also set TUIST_PROJECT instead of adding a configuration file, and TUIST_URL if you use a self-hosted server.
tuist cargo build --workspace
tuist cargo check --all-targets
tuist cargo test --workspace
Use the same arguments you normally pass to Cargo, including features, toolchains, and test filters. Cargo keeps its usual output and exit code, even if Tuist can't upload a report.
Keep typing Cargo#
With mise's command wrappers enabled, add this to mise.toml:
[wrappers.cargo]
command = "tuist"
args = ["cargo"]
Run mise reshim after adding the wrapper. You can then use cargo build, cargo check, and cargo nextest run as usual. Mise runs them through Tuist for you.
This is useful when working with coding agents: they can keep running cargo build and cargo nextest run without being reminded to add the tuist prefix.
Build insights#
Open Builds in the dashboard to see how long your builds take and compare local builds with CI. Select a build to find the crates that took longest to compile and inspect its warnings and errors.
The compiler timings are for crates, not individual source files. See Rust Build Insights for more on reading a build report.
Test insights#
To see individual test results, run your tests with nextest:
tuist cargo nextest run --workspace
Open Tests in the dashboard to find slow tests, inspect failures, and follow retry attempts. Your existing nextest profiles and JUnit report settings still work. Read more in Rust Test Insights and Rust Flaky Tests.
You can still use cargo test, but it won't send individual test results to Tuist. Nextest doesn't run doctests, so run those separately:
tuist cargo test --doc
Test sharding#
Test sharding splits your test suite across CI workers that run at the same time, so you get results sooner. Tuist uses timing data from previous runs to balance the work dynamically, rather than asking you to maintain fixed groups of tests. Each shard gets a set of test binaries to run.
Build the tests once before starting the workers:
TUIST_SHARD_REFERENCE="${CI_PIPELINE_ID}-${CI_JOB_ATTEMPT}" \
tuist cargo test-build --workspace --shard-total 4
Use your CI provider's pipeline and attempt identifiers for the reference. The command uploads the compiled tests and returns a plan ID and worker indexes.
Pass that plan ID to each worker, with a different index starting at zero:
TUIST_SHARD_PLAN_ID="$PLAN_ID" TUIST_SHARD_INDEX=0 \
tuist cargo nextest run --profile ci
Each worker downloads the compiled tests and runs its assigned binaries without rebuilding. Use the same checkout and compatible operating systems and architectures on all workers. The results appear as one test run in the dashboard.
See Rust Test Sharding for a complete CI example and options for balancing the workers.