| 1 |
version: '2.1' |
| 2 |
|
| 3 |
workflows: |
| 4 |
version: 2 |
| 5 |
build: |
| 6 |
jobs: |
| 7 |
- build: |
| 8 |
matrix: |
| 9 |
parameters: |
| 10 |
rust_img: [ |
| 11 |
# Yes, a single-parameter axis, but means it can be referred to as a cache parameter easily without |
| 12 |
# duplicating the magic version number throughout this file. |
| 13 |
# The default rust images (not -slim or -alpine) are based on buildpack-deps. Hopefully this will |
| 14 |
# be easier on the CI hosts since presumably those fat lower layers will already be cached, and |
| 15 |
# therefore faster than a minimal, customized alpine. |
| 16 |
# MSRV |
| 17 |
'rust:1.48.0' |
| 18 |
] |
| 19 |
# a hacky scheme to work around CircleCI's inability to deal with mutable docker tags, forcing us to |
| 20 |
# get a nightly or stable toolchain via rustup instead of a mutable docker tag |
| 21 |
toolchain_override: [ |
| 22 |
'__msrv__', # won't add any other toolchains, just uses what's in the docker image |
| 23 |
'1.65.0', # minimum needed to build dev-dependencies |
| 24 |
'stable', |
| 25 |
'beta', |
| 26 |
'nightly' |
| 27 |
] |
| 28 |
|
| 29 |
jobs: |
| 30 |
build: |
| 31 |
parameters: |
| 32 |
rust_img: |
| 33 |
type: string |
| 34 |
toolchain_override: |
| 35 |
type: string |
| 36 |
docker: |
| 37 |
- image: << parameters.rust_img >> |
| 38 |
steps: |
| 39 |
- checkout |
| 40 |
- restore_cache: |
| 41 |
key: project-cache-v5-<< parameters.rust_img >>-<< parameters.toolchain_override >>-{{ checksum "Cargo.toml" }} |
| 42 |
- run: |
| 43 |
name: Setup toolchain |
| 44 |
command: | |
| 45 |
if [[ '<< parameters.toolchain_override >>' != '__msrv__' ]] |
| 46 |
then |
| 47 |
rustup toolchain add '<< parameters.toolchain_override >>' |
| 48 |
rustup default '<< parameters.toolchain_override >>' |
| 49 |
fi |
| 50 |
- run: |
| 51 |
name: Log rustc version |
| 52 |
command: rustc --version |
| 53 |
- run: |
| 54 |
name: Build main target |
| 55 |
# update first to select dependencies appropriate for this toolchain |
| 56 |
command: | |
| 57 |
cargo update |
| 58 |
cargo build |
| 59 |
- run: |
| 60 |
name: Check formatting |
| 61 |
command: | |
| 62 |
rustup component add rustfmt |
| 63 |
cargo fmt -- --check |
| 64 |
- run: |
| 65 |
name: Check clippy lints |
| 66 |
# we only care about stable clippy -- nightly clippy is a bit wild |
| 67 |
command: | |
| 68 |
if [[ '<< parameters.toolchain_override >>' == 'stable' ]] |
| 69 |
then |
| 70 |
rustup component add clippy |
| 71 |
cargo clippy --all-targets |
| 72 |
fi |
| 73 |
- run: |
| 74 |
name: Build all targets |
| 75 |
command: | |
| 76 |
if [[ '<< parameters.toolchain_override >>' != '__msrv__' ]] |
| 77 |
then |
| 78 |
cargo build --all-targets |
| 79 |
fi |
| 80 |
- run: |
| 81 |
name: Build without default features |
| 82 |
command: | |
| 83 |
cargo build --no-default-features |
| 84 |
if [[ '<< parameters.toolchain_override >>' != '__msrv__' ]] |
| 85 |
then |
| 86 |
cargo build --no-default-features --all-targets |
| 87 |
fi |
| 88 |
- run: |
| 89 |
name: Build with only alloc |
| 90 |
command: | |
| 91 |
cargo build --no-default-features --features alloc |
| 92 |
if [[ '<< parameters.toolchain_override >>' != '__msrv__' ]] |
| 93 |
then |
| 94 |
cargo build --no-default-features --features alloc --all-targets |
| 95 |
fi |
| 96 |
- run: |
| 97 |
name: Add arm toolchain |
| 98 |
command: rustup target add thumbv6m-none-eabi |
| 99 |
- run: |
| 100 |
name: Build ARM without default features (no_std) |
| 101 |
command: cargo build --target thumbv6m-none-eabi --no-default-features |
| 102 |
- run: |
| 103 |
name: Build ARM with only alloc feature |
| 104 |
command: cargo build --target thumbv6m-none-eabi --no-default-features --features alloc |
| 105 |
- run: |
| 106 |
# dev dependencies can't build on 1.48.0 |
| 107 |
name: Run tests |
| 108 |
command: | |
| 109 |
if [[ '<< parameters.toolchain_override >>' != '__msrv__' ]] |
| 110 |
then |
| 111 |
cargo test --no-default-features |
| 112 |
cargo test |
| 113 |
fi |
| 114 |
- run: |
| 115 |
name: Build docs |
| 116 |
command: cargo doc --verbose |
| 117 |
- run: |
| 118 |
name: Confirm fuzzers can run |
| 119 |
# TERM=dumb prevents cargo fuzz list from printing with color |
| 120 |
environment: |
| 121 |
TERM: dumb |
| 122 |
command: | |
| 123 |
if [[ '<< parameters.toolchain_override >>' = 'nightly' ]] |
| 124 |
then |
| 125 |
cargo install cargo-fuzz |
| 126 |
cargo fuzz list | xargs -I FUZZER cargo fuzz run FUZZER -- -max_total_time=1 |
| 127 |
fi |
| 128 |
|
| 129 |
- save_cache: |
| 130 |
key: project-cache-v5-<< parameters.rust_img >>-<< parameters.toolchain_override >>-{{ checksum "Cargo.toml" }} |
| 131 |
paths: |
| 132 |
# rust docker img doesn't use $HOME/[.cargo,.rustup] |
| 133 |
- /usr/local/cargo |
| 134 |
- /usr/local/rustup |
| 135 |
- ./target |