Skip to content

Commit f2b42ad

Browse files
Work around CircleCI's unhappiness with mutable docker tags
1 parent f18dd12 commit f2b42ad

File tree

1 file changed

+34
-16
lines changed

1 file changed

+34
-16
lines changed

.circleci/config.yml

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,36 +8,51 @@ workflows:
88
matrix:
99
parameters:
1010
rust_img: [
11-
# The default rust images (not -slim or -alpine) are based on buildpack-deps. Hopefully this will
12-
# be easier on the CI hosts since presumably those fat lower layers will already be cached, and
13-
# therefore faster than a minimal, customized alpine.
14-
# MSRV
15-
'rust:1.47.0',
16-
# stable
17-
'rust:latest',
18-
'rustlang/rust:nightly'
19-
# would be nice to have beta as well: https://github.com/rust-lang/docker-rust/issues/14
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.47.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'
2025
]
2126

2227
jobs:
2328
build:
2429
parameters:
2530
rust_img:
2631
type: string
32+
toolchain_override:
33+
type: string
2734
docker:
2835
- image: << parameters.rust_img >>
2936
steps:
3037
- checkout
3138
- restore_cache:
32-
key: project-cache-v3-<< parameters.rust_img >>-{{ checksum "Cargo.toml" }}
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
3351
- run:
3452
name: Check formatting
3553
command: |
3654
rustup component add rustfmt
3755
cargo fmt -- --check
38-
- run:
39-
name: Add arm toolchain
40-
command: rustup target add thumbv6m-none-eabi
4156
- run:
4257
name: Build all targets
4358
command: cargo build --all-targets
@@ -47,6 +62,9 @@ jobs:
4762
- run:
4863
name: Build with only alloc
4964
command: cargo build --no-default-features --features alloc
65+
- run:
66+
name: Add arm toolchain
67+
command: rustup target add thumbv6m-none-eabi
5068
- run:
5169
name: Build ARM without default features (no_std)
5270
command: cargo build --target thumbv6m-none-eabi --no-default-features
@@ -60,19 +78,19 @@ jobs:
6078
name: Build docs
6179
command: cargo doc --verbose
6280
- run:
63-
name: Confirm a fuzzer can run
81+
name: Confirm fuzzers can run
6482
# TERM=dumb prevents cargo fuzz list from printing with color
6583
environment:
6684
TERM: dumb
6785
command: |
68-
if [[ '<< parameters.rust_img >>' = 'rustlang/rust:nightly' ]]
86+
if [[ '<< parameters.toolchain_override >>' = 'nightly' ]]
6987
then
7088
cargo install cargo-fuzz
7189
cargo fuzz list | xargs -I FUZZER cargo fuzz run FUZZER -- -max_total_time=1
7290
fi
7391
7492
- save_cache:
75-
key: project-cache-v3-<< parameters.rust_img >>-{{ checksum "Cargo.toml" }}
93+
key: project-cache-v5-<< parameters.rust_img >>-<< parameters.toolchain_override >>-{{ checksum "Cargo.toml" }}
7694
paths:
7795
# rust docker img doesn't use $HOME/[.cargo,.rustup]
7896
- /usr/local/cargo

0 commit comments

Comments
 (0)