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