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 RUSTFLAGS: -D warnings 9 RUSTDOCFLAGS: -D warnings 10 TOOL: cargo 11 # The MSRV 12 TOOLCHAIN: 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 +$TOOLCHAIN -Vv 20 - rustc +$TOOLCHAIN -Vv 21 - $TOOL +$TOOLCHAIN $BUILD $ZFLAGS --target $TARGET --all-targets 22 - $TOOL +$TOOLCHAIN doc $ZFLAGS --no-deps --target $TARGET 23 - $TOOL +$TOOLCHAIN clippy $ZFLAGS --target $TARGET --all-targets -- -D warnings 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 +$TOOLCHAIN 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 +$TOOLCHAIN 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 $TOOLCHAIN 56 - . $HOME/.cargo/env 57 - rustup target add i686-unknown-freebsd 58 - rustup component add --toolchain $TOOLCHAIN clippy 59 << : *TEST 60 i386_test_script: 61 - . $HOME/.cargo/env 62 - cargo build --target i686-unknown-freebsd 63 - cargo doc --no-deps --target i686-unknown-freebsd 64 - cargo test --target i686-unknown-freebsd 65 i386_feature_script: 66 - . $HOME/.cargo/env 67 - if [ -z "$NOHACK" ]; then cargo hack check --each-feature --target i686-unknown-freebsd; fi 68 before_cache_script: rm -rf $CARGO_HOME/registry/index 69 70# Test macOS aarch64 in a full VM 71task: 72 name: macOS aarch64 73 env: 74 TARGET: aarch64-apple-darwin 75 macos_instance: 76 image: ghcr.io/cirruslabs/macos-ventura-base:latest 77 setup_script: 78 - curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs 79 - sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN 80 - . $HOME/.cargo/env 81 - rustup component add --toolchain $TOOLCHAIN clippy 82 << : *TEST 83 before_cache_script: rm -rf $CARGO_HOME/registry/index 84 85# Use cross for QEMU-based testing 86# cross needs to execute Docker, so we must use Cirrus's Docker Builder task. 87task: 88 env: 89 RUST_TEST_THREADS: 1 # QEMU works best with 1 thread 90 HOME: /tmp/home 91 HOST: x86_64-unknown-linux-gnu 92 PATH: $HOME/.cargo/bin:$PATH 93 RUSTFLAGS: --cfg qemu -D warnings 94 TOOL: cross 95 matrix: 96 - name: Linux arm gnueabi 97 env: 98 TARGET: arm-unknown-linux-gnueabi 99 - name: Linux armv7 gnueabihf 100 env: 101 TARGET: armv7-unknown-linux-gnueabihf 102 - name: Linux i686 103 env: 104 TARGET: i686-unknown-linux-gnu 105 - name: Linux i686 musl 106 env: 107 TARGET: i686-unknown-linux-musl 108 - name: Linux MIPS 109 env: 110 TARGET: mips-unknown-linux-gnu 111 - name: Linux MIPS64 112 env: 113 TARGET: mips64-unknown-linux-gnuabi64 114 - name: Linux MIPS64 el 115 env: 116 TARGET: mips64el-unknown-linux-gnuabi64 117 - name: Linux mipsel 118 env: 119 TARGET: mipsel-unknown-linux-gnu 120 - name: Linux powerpc64le 121 env: 122 TARGET: powerpc64le-unknown-linux-gnu 123 compute_engine_instance: 124 image_project: cirrus-images 125 image: family/docker-builder 126 platform: linux 127 cpu: 1 # Since QEMU will only use 1 thread 128 memory: 4G 129 setup_script: 130 - mkdir /tmp/home 131 - curl --proto '=https' --tlsv1.2 -sSf -o rustup.sh https://sh.rustup.rs 132 - sh rustup.sh -y --profile=minimal --default-toolchain $TOOLCHAIN 133 - . $HOME/.cargo/env 134 - cargo install cross --version 0.2.1 # cross 0.2.2 bumped the MSRV to 1.58.1 135 << : *TEST 136 before_cache_script: rm -rf $CARGO_HOME/registry/index 137 138# Tasks for Linux native builds 139task: 140 matrix: 141 - name: Linux aarch64 142 arm_container: 143 image: rust:1.56 144 env: 145 RUSTFLAGS: --cfg graviton -D warnings 146 TARGET: aarch64-unknown-linux-gnu 147 - name: Linux x86_64 148 container: 149 image: rust:1.56 150 env: 151 TARGET: x86_64-unknown-linux-gnu 152 - name: Linux x86_64 musl 153 container: 154 image: rust:1.56 155 env: 156 TARGET: x86_64-unknown-linux-musl 157 setup_script: 158 - rustup target add $TARGET 159 - rustup component add clippy 160 << : *TEST 161 before_cache_script: rm -rf $CARGO_HOME/registry/index 162 163task: 164 name: Rust Stable 165 container: 166 image: rust:latest 167 env: 168 TARGET: x86_64-unknown-linux-gnu 169 TOOLCHAIN: 170 setup_script: 171 - rustup target add $TARGET 172 - rustup component add clippy 173 << : *TEST 174 before_cache_script: rm -rf $CARGO_HOME/registry/index 175 176# Tasks for cross-compiling, but no testing 177task: 178 container: 179 image: rust:1.56 180 env: 181 BUILD: check 182 HOST: x86_64-unknown-linux-gnu 183 matrix: 184 # Cross claims to support Android, but when it tries to run Nix's tests it 185 # reports undefined symbol references. 186 - name: Android aarch64 187 env: 188 TARGET: aarch64-linux-android 189 - name: Android arm 190 env: 191 TARGET: arm-linux-androideabi 192 - name: Android armv7 193 env: 194 TARGET: armv7-linux-androideabi 195 - name: Android i686 196 env: 197 TARGET: i686-linux-android 198 - name: Android x86_64 199 env: 200 TARGET: x86_64-linux-android 201 - name: Linux arm-musleabi 202 env: 203 TARGET: arm-unknown-linux-musleabi 204 - name: Fuchsia x86_64 205 env: 206 TARGET: x86_64-fuchsia 207 - name: Illumos 208 env: 209 TARGET: x86_64-unknown-illumos 210 # Cross claims to support running tests on iOS, but it actually doesn't. 211 # https://github.com/rust-embedded/cross/issues/535 212 - name: iOS aarch64 213 env: 214 # cargo hack tries to invoke the iphonesimulator SDK for iOS 215 NOHACK: 1 216 TARGET: aarch64-apple-ios 217 - name: iOS x86_64 218 env: 219 # cargo hack tries to invoke the iphonesimulator SDK for iOS 220 NOHACK: 1 221 TARGET: x86_64-apple-ios 222 # Cross testing on powerpc fails with "undefined reference to renameat2". 223 # Perhaps cross is using too-old a version? 224 - name: Linux powerpc 225 env: 226 TARGET: powerpc-unknown-linux-gnu 227 # Cross claims to support Linux powerpc64, but it really doesn't. 228 # https://github.com/rust-embedded/cross/issues/441 229 - name: Linux powerpc64 230 env: 231 TARGET: powerpc64-unknown-linux-gnu 232 - name: Linux s390x 233 env: 234 TARGET: s390x-unknown-linux-gnu 235 - name: Linux x32 236 env: 237 TARGET: x86_64-unknown-linux-gnux32 238 - name: macOS x86_64 239 env: 240 TARGET: x86_64-apple-darwin 241 - name: NetBSD x86_64 242 env: 243 TARGET: x86_64-unknown-netbsd 244 setup_script: 245 - rustup target add $TARGET 246 - rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET 247 - rustup component add --toolchain $TOOLCHAIN clippy 248 << : *BUILD 249 before_cache_script: rm -rf $CARGO_HOME/registry/index 250 251task: 252 container: 253 image: rust:1.56 254 env: 255 BUILD: check 256 name: Redox x86_64 257 env: 258 HOST: x86_64-unknown-linux-gnu 259 TARGET: x86_64-unknown-redox 260 # Redox's MSRV policy is unclear. Until they define it, use nightly. 261 TOOLCHAIN: nightly 262 setup_script: 263 - rustup target add $TARGET 264 - rustup toolchain install $TOOLCHAIN --profile minimal --target $TARGET 265 - rustup component add --toolchain $TOOLCHAIN 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 TOOLCHAIN: nightly 277 ZFLAGS: -Zbuild-std 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 TOOLCHAIN: nightly 304 container: 305 image: rustlang/rust:nightly 306 setup_script: 307 - cargo update -Zminimal-versions 308 check_script: 309 - cargo check 310 before_cache_script: rm -rf $CARGO_HOME/registry/index 311 312# Tasks that checks if the code is formatted right using `cargo fmt` tool 313task: 314 name: Rust Formatter 315 container: 316 image: rust:latest 317 setup_script: rustup +$TOOLCHAIN component add rustfmt 318 test_script: $TOOL +$TOOLCHAIN fmt --all -- --check **/*.rs 319