version: 2.1 executors: default: description: Executor environment for building Rust crates. docker: - image: circleci/rust:1 commands: update_toolchain: description: Update the Rust toolchain to use for building. parameters: toolchain: description: Rust toolchain to use. Overrides the default toolchain (stable) or any toolchain specified in the project via `rust-toolchain`. type: string default: "" steps: - run: name: Update toolchain command: | test -z "<>" || echo "<>" >rust-toolchain rustup show active-toolchain - run: name: Version information command: | rustup --version rustc --version cargo --version build: description: Build all targets of a Rust crate. steps: - run: name: Calculate dependencies command: | rustc --version >rust-version test -e Cargo.lock || cargo generate-lockfile - restore_cache: keys: - v6-cargo-cache-{{arch}}-{{checksum "rust-version"}}-{{checksum "Cargo.lock"}} - run: name: Build all targets command: cargo build --tests --all-features - save_cache: paths: - /usr/local/cargo/registry - target key: v6-cargo-cache-{{arch}}-{{checksum "rust-version"}}-{{checksum "Cargo.lock"}} check: description: Check all targets of a Rust crate. steps: - run: name: Calculate dependencies command: test -e Cargo.lock || cargo generate-lockfile - run: name: Check all targets command: | if rustup component add clippy; then cargo clippy --all --all-targets --all-features -- -Dwarnings else echo Skipping clippy fi test: description: Run all tests of a Rust crate. Make sure to build first. parameters: release: description: By default, the crate is build in debug mode without optimizations. Set this to true to compile in release mode. type: boolean default: false steps: - run: name: Run all tests command: cargo test --all-features jobs: check: description: Check a Rust crate. parameters: toolchain: description: Rust toolchain to use. Overrides the default toolchain (stable) or any toolchain specified in the project via `rust-toolchain`. type: string default: "" executor: default steps: - checkout - update_toolchain: toolchain: <> - check test: description: Builds a Rust crate and runs all tests. parameters: toolchain: description: Rust toolchain to use. Overrides the default toolchain (stable) or any toolchain specified in the project via `rust-toolchain`. type: string default: "" executor: default steps: - checkout - update_toolchain: toolchain: <> - build - test workflows: Project: jobs: - test: name: cargo test (stable) toolchain: stable - test: name: cargo test (beta) toolchain: beta - test: name: cargo test (nightly) toolchain: nightly