• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1cargo_cache:
2  folder: $CARGO_HOME/registry
3  fingerprint_script: cat Cargo.lock || echo ""
4
5env:
6  # Build by default; don't just check
7  BUILD: build
8  CLIPPYFLAGS: -D warnings -A unknown-lints
9  RUSTFLAGS: -D warnings
10  RUSTDOCFLAGS: -D warnings
11  TOOL: cargo
12  MSRV: 1.56.1
13  ZFLAGS:
14
15# Tests that don't require executing the build binaries
16build: &BUILD
17  build_script:
18    - . $HOME/.cargo/env || true
19    - $TOOL -Vv
20    - rustc -Vv
21    - $TOOL $BUILD $ZFLAGS --target $TARGET --all-targets
22    - $TOOL doc $ZFLAGS --no-deps --target $TARGET
23    - $TOOL clippy $ZFLAGS --target $TARGET --all-targets -- $CLIPPYFLAGS
24    - if [ -z "$NOHACK" ]; then mkdir -p $HOME/.cargo/bin; export PATH=$HOME/.cargo/bin:$PATH; fi
25    - if [ -z "$NOHACK" ]; then curl -LsSf https://github.com/taiki-e/cargo-hack/releases/latest/download/cargo-hack-${HOST:-$TARGET}.tar.gz | tar xzf - -C ~/.cargo/bin; fi
26    - if [ -z "$NOHACK" ]; then $TOOL hack $ZFLAGS check --target $TARGET --each-feature; fi
27
28# Tests that do require executing the binaries
29test: &TEST
30  << : *BUILD
31  test_script:
32    - . $HOME/.cargo/env || true
33    - $TOOL test --target $TARGET
34
35# Test FreeBSD in a full VM.  Test the i686 target too, in the
36# same VM.  The binary will be built in 32-bit mode, but will execute on a
37# 64-bit kernel and in a 64-bit environment.  Our tests don't execute any of
38# the system's binaries, so the environment shouldn't matter.
39task:
40  env:
41    TARGET: x86_64-unknown-freebsd
42  matrix:
43    - name: FreeBSD 12 amd64 & i686
44      freebsd_instance:
45        image: freebsd-12-3-release-amd64
46    - name: FreeBSD 14 amd64 & i686
47      freebsd_instance:
48        image_family: freebsd-14-0-snap
49      # Enable tests that would fail on FreeBSD 12
50      RUSTFLAGS: --cfg fbsd14 -D warnings
51      RUSTDOCFLAGS: --cfg fbsd14
52  setup_script:
53    - kldload mqueuefs
54    - fetch https://sh.rustup.rs -o rustup.sh
55    - sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
56    - . $HOME/.cargo/env
57    - rustup target add i686-unknown-freebsd
58    - rustup component add clippy
59    - cp Cargo.lock.msrv Cargo.lock
60  << : *TEST
61  i386_test_script:
62    - . $HOME/.cargo/env
63    - cargo build --target i686-unknown-freebsd
64    - cargo doc --no-deps --target i686-unknown-freebsd
65    - cargo test --target i686-unknown-freebsd
66  i386_feature_script:
67    - . $HOME/.cargo/env
68    - if [ -z "$NOHACK" ]; then cargo hack check --each-feature --target i686-unknown-freebsd; fi
69  before_cache_script: rm -rf $CARGO_HOME/registry/index
70
71# Test macOS aarch64 in a full VM
72task:
73  name: macOS aarch64
74  env:
75    TARGET: aarch64-apple-darwin
76  macos_instance:
77    image: ghcr.io/cirruslabs/macos-ventura-base:latest
78  setup_script:
79    - curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
80    - sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
81    - . $HOME/.cargo/env
82    - rustup component add clippy
83    - cp Cargo.lock.msrv Cargo.lock
84  << : *TEST
85  before_cache_script: rm -rf $CARGO_HOME/registry/index
86
87# Use cross for QEMU-based testing
88# cross needs to execute Docker, so we must use Cirrus's Docker Builder task.
89task:
90  env:
91    RUST_TEST_THREADS: 1            # QEMU works best with 1 thread
92    HOME: /tmp/home
93    HOST: x86_64-unknown-linux-gnu
94    PATH: $HOME/.cargo/bin:$PATH
95    RUSTFLAGS: --cfg qemu -D warnings
96    TOOL: cross
97  matrix:
98    - name: Linux arm gnueabi
99      env:
100        TARGET: arm-unknown-linux-gnueabi
101    - name: Linux armv7 gnueabihf
102      env:
103        TARGET: armv7-unknown-linux-gnueabihf
104    - name: Linux i686
105      env:
106        TARGET: i686-unknown-linux-gnu
107    - name: Linux i686 musl
108      env:
109        TARGET: i686-unknown-linux-musl
110    - name: Linux MIPS
111      env:
112        TARGET: mips-unknown-linux-gnu
113    - name: Linux MIPS64
114      env:
115        TARGET: mips64-unknown-linux-gnuabi64
116    - name: Linux MIPS64 el
117      env:
118        TARGET: mips64el-unknown-linux-gnuabi64
119    - name: Linux mipsel
120      env:
121        TARGET: mipsel-unknown-linux-gnu
122    - name: Linux powerpc64le
123      env:
124        TARGET: powerpc64le-unknown-linux-gnu
125  compute_engine_instance:
126    image_project: cirrus-images
127    image: family/docker-builder
128    platform: linux
129    cpu: 1                          # Since QEMU will only use 1 thread
130    memory: 4G
131  setup_script:
132    - mkdir /tmp/home
133    - curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs
134    - sh rustup.sh -y --profile=minimal --default-toolchain $MSRV
135    - . $HOME/.cargo/env
136    - cargo install cross --version 0.2.1 --locked # cross 0.2.2 bumped the MSRV to 1.58.1
137    - cp Cargo.lock.msrv Cargo.lock
138  << : *TEST
139  before_cache_script: rm -rf $CARGO_HOME/registry/index
140
141# Tasks for Linux native builds
142task:
143  matrix:
144    - name: Linux aarch64
145      arm_container:
146        image: rust:1.56
147      env:
148        TARGET: aarch64-unknown-linux-gnu
149    - name: Linux x86_64
150      container:
151        image: rust:1.56
152      env:
153        TARGET: x86_64-unknown-linux-gnu
154    - name: Linux x86_64 musl
155      container:
156        image: rust:1.56
157      env:
158        TARGET: x86_64-unknown-linux-musl
159  setup_script:
160    - rustup target add $TARGET
161    - rustup component add clippy
162    - cp Cargo.lock.msrv Cargo.lock
163  << : *TEST
164  before_cache_script: rm -rf $CARGO_HOME/registry/index
165
166task:
167  name: Rust Stable
168  container:
169    image: rust:latest
170  env:
171    TARGET: x86_64-unknown-linux-gnu
172  setup_script:
173    - rustup component add clippy
174  << : *TEST
175  before_cache_script: rm -rf $CARGO_HOME/registry/index
176
177# Tasks for cross-compiling, but no testing
178task:
179  container:
180    image: rust:1.56
181  env:
182    BUILD: check
183    HOST: x86_64-unknown-linux-gnu
184  matrix:
185    # Cross claims to support Android, but when it tries to run Nix's tests it
186    # reports undefined symbol references.
187    - name: Android aarch64
188      env:
189        TARGET: aarch64-linux-android
190    - name: Android arm
191      env:
192        TARGET: arm-linux-androideabi
193    - name: Android armv7
194      env:
195        TARGET: armv7-linux-androideabi
196    - name: Android i686
197      env:
198        TARGET: i686-linux-android
199    - name: Android x86_64
200      env:
201        TARGET: x86_64-linux-android
202    - name: Linux arm-musleabi
203      env:
204        TARGET: arm-unknown-linux-musleabi
205    - name: Fuchsia x86_64
206      env:
207        TARGET: x86_64-fuchsia
208    - name: Illumos
209      env:
210        TARGET: x86_64-unknown-illumos
211    # Cross claims to support running tests on iOS, but it actually doesn't.
212    # https://github.com/rust-embedded/cross/issues/535
213    - name: iOS aarch64
214      env:
215        # cargo hack tries to invoke the iphonesimulator SDK for iOS
216        NOHACK: 1
217        TARGET: aarch64-apple-ios
218    - name: iOS x86_64
219      env:
220        # cargo hack tries to invoke the iphonesimulator SDK for iOS
221        NOHACK: 1
222        TARGET: x86_64-apple-ios
223    # Cross testing on powerpc fails with "undefined reference to renameat2".
224    # Perhaps cross is using too-old a version?
225    - name: Linux powerpc
226      env:
227        TARGET: powerpc-unknown-linux-gnu
228    # Cross claims to support Linux powerpc64, but it really doesn't.
229    # https://github.com/rust-embedded/cross/issues/441
230    - name: Linux powerpc64
231      env:
232        TARGET: powerpc64-unknown-linux-gnu
233    - name: Linux s390x
234      env:
235        TARGET: s390x-unknown-linux-gnu
236    - name: Linux x32
237      env:
238        TARGET: x86_64-unknown-linux-gnux32
239    - name: macOS x86_64
240      env:
241        TARGET: x86_64-apple-darwin
242    - name: NetBSD x86_64
243      env:
244        TARGET: x86_64-unknown-netbsd
245  setup_script:
246    - rustup target add $TARGET
247    - rustup component add clippy
248    - cp Cargo.lock.msrv Cargo.lock
249  << : *BUILD
250  before_cache_script: rm -rf $CARGO_HOME/registry/index
251
252task:
253  container:
254    # Redox's MSRV policy is unclear.  Until they define it, use nightly.
255    image: rustlang/rust:nightly
256  env:
257    BUILD: check
258  name: Redox x86_64
259  env:
260    HOST: x86_64-unknown-linux-gnu
261    TARGET: x86_64-unknown-redox
262    CLIPPYFLAGS: -D warnings
263  setup_script:
264    - rustup target add $TARGET
265    - rustup component add clippy
266  << : *BUILD
267  before_cache_script: rm -rf $CARGO_HOME/registry/index
268
269## Rust Tier 3 targets can't use Rustup
270task:
271  container:
272    image: rustlang/rust:nightly
273  env:
274    BUILD: check
275    HOST: x86_64-unknown-linux-gnu
276    ZFLAGS: -Zbuild-std
277    CLIPPYFLAGS: -D warnings
278  matrix:
279    - name: DragonFly BSD x86_64
280      env:
281        TARGET: x86_64-unknown-dragonfly
282    - name: OpenBSD x86_64
283      env:
284        TARGET: x86_64-unknown-openbsd
285    - name: Linux armv7 uclibceabihf
286      env:
287        TARGET: armv7-unknown-linux-uclibceabihf
288    - name: Haiku x86_64
289      env:
290        TARGET: x86_64-unknown-haiku
291  setup_script:
292    - rustup component add rust-src
293  << : *BUILD
294  before_cache_script: rm -rf $CARGO_HOME/registry/index
295
296# Test that we can build with the lowest version of all dependencies.
297# "cargo test" doesn't work because some of our dev-dependencies, like
298# rand, can't build with their own minimal dependencies.
299task:
300  name: Minver
301  env:
302    HOST: x86_64-unknown-linux-gnu
303  container:
304    image: rustlang/rust:nightly
305  setup_script:
306    - cargo update -Zminimal-versions
307  check_script:
308    - cargo check
309  before_cache_script: rm -rf $CARGO_HOME/registry/index
310
311# Tasks that checks if the code is formatted right using `cargo fmt` tool
312task:
313  name: Rust Formatter
314  container:
315    image: rust:latest
316  setup_script: rustup component add rustfmt
317  test_script: cargo fmt --all -- --check **/*.rs
318