Skip to content

Commit 1e8c895

Browse files
bors[bot]asomers
andauthored
Merge #1512
1512: DRY in the CI config r=asomers a=asomers * Define the build and test scripts once instead of repeating them * Don't use cross with OSX. We no longer need it. Co-authored-by: Alan Somers <asomers@gmail.com>
2 parents 5465167 + 70d8cf3 commit 1e8c895

File tree

1 file changed

+39
-31
lines changed

1 file changed

+39
-31
lines changed

.cirrus.yml

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,51 @@ cargo_cache:
33
fingerprint_script: cat Cargo.lock || echo ""
44

55
env:
6+
# Build by default; don't just check
7+
BUILD: build
68
RUSTFLAGS: -D warnings
79
RUSTDOCFLAGS: -D warnings
10+
TOOL: cargo
11+
# The MSRV
12+
TOOLCHAIN: 1.46.0
13+
14+
# Tests that don't require executing the build binaries
15+
build: &BUILD
16+
build_script:
17+
- . $HOME/.cargo/env || true
18+
- $TOOL +$TOOLCHAIN $BUILD --target $TARGET --all-targets
19+
- $TOOL +$TOOLCHAIN doc --no-deps --target $TARGET
20+
21+
# Tests that do require executing the binaries
22+
test: &TEST
23+
<< : *BUILD
24+
test_script:
25+
- . $HOME/.cargo/env || true
26+
- $TOOL +$TOOLCHAIN test --target $TARGET
27+
828
# Test FreeBSD in a full VM. Test the i686 target too, in the
929
# same VM. The binary will be built in 32-bit mode, but will execute on a
1030
# 64-bit kernel and in a 64-bit environment. Our tests don't execute any of
1131
# the system's binaries, so the environment shouldn't matter.
1232
task:
1333
name: FreeBSD amd64 & i686
34+
env:
35+
TARGET: x86_64-unknown-freebsd
1436
freebsd_instance:
1537
image: freebsd-11-4-release-amd64
1638
setup_script:
1739
- fetch https://sh.rustup.rs -o rustup.sh
18-
- sh rustup.sh -y --profile=minimal --default-toolchain 1.46.0
40+
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
1941
- $HOME/.cargo/bin/rustup target add i686-unknown-freebsd
20-
amd64_test_script:
21-
- . $HOME/.cargo/env
22-
- cargo test
23-
- cargo doc --no-deps
42+
<< : *TEST
2443
i386_test_script:
2544
- . $HOME/.cargo/env
26-
- cargo test --target i686-unknown-freebsd
45+
- cargo build --target i686-unknown-freebsd
2746
- cargo doc --no-deps --target i686-unknown-freebsd
47+
- cargo test --target i686-unknown-freebsd
2848
before_cache_script: rm -rf $CARGO_HOME/registry/index
2949

30-
# Test OSX and iOS in a full VM
50+
# Test OSX in a full VM
3151
task:
3252
matrix:
3353
- name: OSX x86_64
@@ -37,13 +57,9 @@ task:
3757
image: catalina-xcode
3858
setup_script:
3959
- curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
40-
- sh rustup.sh -y --profile=minimal --default-toolchain 1.46.0
60+
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
4161
- . $HOME/.cargo/env
42-
- cargo install cross
43-
script:
44-
- . $HOME/.cargo/env
45-
- cross build --target $TARGET
46-
- cross test --target $TARGET
62+
<< : *TEST
4763
before_cache_script: rm -rf $CARGO_HOME/registry/index
4864

4965
# Use cross for QEMU-based testing
@@ -54,6 +70,7 @@ task:
5470
HOME: /tmp/home
5571
PATH: $HOME/.cargo/bin:$PATH
5672
RUSTFLAGS: --cfg qemu -D warnings
73+
TOOL: cross
5774
matrix:
5875
- name: Linux arm gnueabi
5976
env:
@@ -91,14 +108,10 @@ task:
91108
setup_script:
92109
- mkdir /tmp/home
93110
- curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
94-
- sh rustup.sh -y --profile=minimal --default-toolchain 1.46.0
111+
- sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN
95112
- . $HOME/.cargo/env
96113
- cargo install cross
97-
script:
98-
- . $HOME/.cargo/env || true
99-
- cross build --target $TARGET
100-
- cross test --target $TARGET
101-
- cross doc --no-deps --target $TARGET
114+
<< : *TEST
102115
before_cache_script: rm -rf $CARGO_HOME/registry/index
103116

104117
# Tasks for Linux native builds
@@ -109,6 +122,7 @@ task:
109122
image: rust:latest
110123
env:
111124
TARGET: x86_64-unknown-linux-gnu
125+
TOOLCHAIN:
112126
- name: Linux aarch64
113127
arm_container:
114128
image: rust:1.46
@@ -127,19 +141,15 @@ task:
127141
TARGET: x86_64-unknown-linux-musl
128142
setup_script:
129143
- rustup target add $TARGET
130-
- uname -a
131-
script:
132-
- cargo build --target $TARGET --all-targets
133-
- cargo test --target $TARGET
134-
- cargo doc --no-deps --target $TARGET
144+
<< : *TEST
135145
before_cache_script: rm -rf $CARGO_HOME/registry/index
136146

137147
# Tasks for cross-compiling, but no testing
138148
task:
139149
container:
140150
image: rust:1.46
141151
env:
142-
TOOLCHAIN: 1.46.0
152+
BUILD: check
143153
matrix:
144154
# Cross claims to support Android, but when it tries to run Nix's tests it
145155
# reports undefined symbol references.
@@ -178,8 +188,7 @@ task:
178188
TARGET: aarch64-apple-ios
179189
# Rustup only supports cross-building from arbitrary hosts for iOS at
180190
# 1.49.0 and above. Below that it's possible to cross-build from an OSX
181-
# host, but OSX VMs
182-
# are more expensive than Linux VMs.
191+
# host, but OSX VMs are more expensive than Linux VMs.
183192
TOOLCHAIN: 1.49.0
184193
- name: iOS x86_64
185194
env:
@@ -214,17 +223,16 @@ task:
214223
setup_script:
215224
- rustup target add $TARGET
216225
- rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET
217-
script:
218-
- cargo +$TOOLCHAIN check --target $TARGET
219-
- cargo +$TOOLCHAIN check --all-targets --target $TARGET
220-
- cargo +$TOOLCHAIN doc --no-deps --target $TARGET
226+
<< : *BUILD
221227
before_cache_script: rm -rf $CARGO_HOME/registry/index
222228

223229
# Test that we can build with the lowest version of all dependencies.
224230
# "cargo test" doesn't work because some of our dev-dependencies, like
225231
# rand, can't build with their own minimal dependencies.
226232
task:
227233
name: Minver
234+
env:
235+
TOOLCHAIN: nightly
228236
container:
229237
image: rustlang/rust:nightly
230238
setup_script:

0 commit comments

Comments
 (0)