test #36
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build & Tests | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
- v0.6.x | |
permissions: read-all | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: -Dwarnings | |
RUSTDOCFLAGS: -Dwarnings | |
# `ZC_NIGHTLY_XXX` are flags that we add to `XXX` only on the nightly | |
# toolchain. | |
ZC_NIGHTLY_RUSTFLAGS: -Zrandomize-layout | |
ZC_NIGHTLY_MIRIFLAGS: "-Zmiri-symbolic-alignment-check -Zmiri-strict-provenance -Zmiri-backtrace=full" | |
jobs: | |
build_test: | |
runs-on: ubuntu-latest | |
strategy: | |
# By default, this is set to `true`, which means that a single CI job | |
# failure will cause all outstanding jobs to be canceled. This slows down | |
# development because it means that errors need to be encountered and | |
# fixed one at a time. | |
fail-fast: false | |
matrix: | |
# See `INTERNAL.md` for an explanation of these pinned toolchain | |
# versions. | |
toolchain: [ "msrv", "stable", "nightly" ] | |
target: [ | |
"i686-unknown-linux-gnu", | |
"x86_64-unknown-linux-gnu", | |
"arm-unknown-linux-gnueabi", | |
"aarch64-unknown-linux-gnu", | |
"powerpc-unknown-linux-gnu", | |
"powerpc64-unknown-linux-gnu", | |
"riscv64gc-unknown-linux-gnu", | |
"mips-unknown-linux-gnu", | |
"mips64-unknown-linux-gnuabi64", | |
"s390x-unknown-linux-gnu", | |
"wasm32-wasi" | |
] | |
features: [ "--no-default-features", "", "--features __internal_use_only_features_that_work_on_stable", "--all-features" ] | |
crate: [ "zerocopy", "zerocopy-derive" ] | |
exclude: | |
# Exclude any combination which uses a non-nightly toolchain but | |
# enables nightly features. | |
- toolchain: "msrv" | |
features: "--all-features" | |
- toolchain: "stable" | |
features: "--all-features" | |
# Exclude any combination for the zerocopy-derive crate which | |
# uses zerocopy features. | |
- crate: "zerocopy-derive" | |
features: "--no-default-features" | |
- crate: "zerocopy-derive" | |
features: "--features __internal_use_only_features_that_work_on_stable" | |
- crate: "zerocopy-derive" | |
features: "--all-features" | |
name: Build & Test (crate:${{ matrix.crate }}, toolchain:${{ matrix.toolchain }}, target:${{ matrix.target }}, features:${{ matrix.features }}) | |
steps: | |
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0 | |
# We use toolchain descriptors ("msrv", "stable", and "nightly") in the | |
# matrix. This step converts the current descriptor to a particular | |
# toolchain version by looking up the corresponding key in `Cargo.toml`. It | |
# sets the `ZC_TOOLCHAIN` environment variable for future steps to use. | |
# | |
# Note that all metadata is stored in zerocopy's `Cargo.toml` (the one at | |
# the repository root). zerocopy-derive is tested with the same versions, | |
# and we have another CI job (see below) that makes sure that the | |
# `package.rust_version` key in zerocopy-derive's `Cargo.toml` is the same | |
# as the one in zerocopy's `Cargo.toml`. This key indicates the crate's | |
# MSRV, and if this check weren't present, it would be possible for | |
# zerocopy-derive to be published with an earlier MSRV than the one we test | |
# for in CI - and thus potentially an MSRV that zerocopy-derive isn't | |
# actually compatible with. | |
- name: Set toolchain version | |
run: | | |
set -eo pipefail | |
function pkg-meta { | |
cargo metadata --format-version 1 | jq -r ".packages[] | select(.name == \"zerocopy\").$1" | |
} | |
case ${{ matrix.toolchain }} in | |
msrv) | |
ZC_TOOLCHAIN="$(pkg-meta rust_version)" | |
;; | |
stable) | |
ZC_TOOLCHAIN="$(pkg-meta 'metadata.ci."pinned-stable"')" | |
;; | |
nightly) | |
ZC_TOOLCHAIN="$(pkg-meta 'metadata.ci."pinned-nightly"')" | |
;; | |
*) | |
echo 'Unrecognized toolchain: ${{ matrix.toolchain }}' | tee -a $GITHUB_STEP_SUMMARY >&2 | |
exit 1 | |
;; | |
esac | |
echo "Found that the '${{ matrix.toolchain }}' toolchain is $ZC_TOOLCHAIN" | tee -a $GITHUB_STEP_SUMMARY | |
echo "ZC_TOOLCHAIN=$ZC_TOOLCHAIN" >> $GITHUB_ENV |