1version: '2.1' 2 3workflows: 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.57.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 'stable', 24 'nightly' 25 ] 26 27jobs: 28 build: 29 parameters: 30 rust_img: 31 type: string 32 toolchain_override: 33 type: string 34 docker: 35 - image: << parameters.rust_img >> 36 steps: 37 - checkout 38 - restore_cache: 39 key: project-cache-v5-<< parameters.rust_img >>-<< parameters.toolchain_override >>-{{ checksum "Cargo.toml" }} 40 - run: 41 name: Setup toolchain 42 command: | 43 if [[ '<< parameters.toolchain_override >>' != '__msrv__' ]] 44 then 45 rustup toolchain add '<< parameters.toolchain_override >>' 46 rustup default '<< parameters.toolchain_override >>' 47 fi 48 - run: 49 name: Log rustc version 50 command: rustc --version 51 - run: 52 name: Check formatting 53 command: | 54 rustup component add rustfmt 55 cargo fmt -- --check 56 - run: 57 name: Check clippy lints 58 # we only care about stable clippy -- nightly clippy is a bit wild 59 command: | 60 if [[ '<< parameters.toolchain_override >>' == 'stable' ]] 61 then 62 rustup component add clippy 63 cargo clippy --all-targets 64 fi 65 - run: 66 name: Build all targets 67 command: cargo build --all-targets 68 - run: 69 name: Build without default features 70 command: cargo build --no-default-features 71 - run: 72 name: Build with only alloc 73 command: cargo build --no-default-features --features alloc 74 - run: 75 name: Add arm toolchain 76 command: rustup target add thumbv6m-none-eabi 77 - run: 78 name: Build ARM without default features (no_std) 79 command: cargo build --target thumbv6m-none-eabi --no-default-features 80 - run: 81 name: Build ARM with only alloc feature 82 command: cargo build --target thumbv6m-none-eabi --no-default-features --features alloc 83 - run: 84 name: Run tests 85 command: cargo test --verbose 86 - run: 87 name: Build docs 88 command: cargo doc --verbose 89 - run: 90 name: Confirm fuzzers can run 91 # TERM=dumb prevents cargo fuzz list from printing with color 92 environment: 93 TERM: dumb 94 command: | 95 if [[ '<< parameters.toolchain_override >>' = 'nightly' ]] 96 then 97 cargo install cargo-fuzz 98 cargo fuzz list | xargs -I FUZZER cargo fuzz run FUZZER -- -max_total_time=1 99 fi 100 101 - save_cache: 102 key: project-cache-v5-<< parameters.rust_img >>-<< parameters.toolchain_override >>-{{ checksum "Cargo.toml" }} 103 paths: 104 # rust docker img doesn't use $HOME/[.cargo,.rustup] 105 - /usr/local/cargo 106 - /usr/local/rustup 107 - ./target 108