Building a Rust Project

What This Guide Covers #

Language versions and other build-environment specific information are in our reference pages:

The rest of this guide covers configuring Rust projects in Travis CI. If you’re new to Travis CI please read our Tutorial and build configuration guides first.

Choosing a Rust version #

By default, we download and install the latest stable Rust release at the start of the build, along with appropriate language tools including cargo, rustc, rustdoc, rust-gdb, rust-lldb, and rustup.

To test against specific Rust releases:

language: rust
  - 1.0.0
  - 1.1.0

Travis CI also supports all three Rust release channels: stable, beta, and nightly.

The Rust team appreciates testing against the beta and nightly channels, even if you are only targeting stable. A full configuration looks like this:

language: rust
  - stable
  - beta
  - nightly
    - rust: nightly
  fast_finish: true

This will runs your tests against all three channels, but any breakage in nightly will not fail the rest of build.

Dependency Management #

Travis CI uses Cargo to install your dependencies:

cargo build --verbose

You can cache your dependencies so they are only recompiled if they or the compiler were upgraded:

cache: cargo

Default Build Script #

Travis CI uses Cargo to run your build, the default commands are:

cargo test --verbose

You can always configure different comands if you need to. For example, if your project is a workspace, you should pass --all to the build commands to build and test all of the member crates:

language: rust
  - cargo build --verbose --all
  - cargo test --verbose --all

Environment variables #

The Rust version that is specified in the .travis.yml is available during the build in the TRAVIS_RUST_VERSION environment variable.