311 lines
10 KiB
YAML
Raw Normal View History

2020-12-14 21:50:24 +00:00
name: Tests
on:
push:
branches: master
pull_request:
branches: master
schedule:
- cron: "0 12 * * 1"
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: "-Dwarnings"
jobs:
check-doc:
name: Docs, deadlinks, minimal dependencies
2020-12-14 21:50:24 +00:00
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly # Needed for -Z minimal-versions and doc_cfg
- name: Install precompiled cargo-deadlinks
run: |
export URL=$(curl -s https://api.github.com/repos/deadlinks/cargo-deadlinks/releases/latest | jq -r '.assets[] | select(.name | contains("cargo-deadlinks-linux")) | .browser_download_url')
wget -O /tmp/cargo-deadlinks $URL
chmod +x /tmp/cargo-deadlinks
mv /tmp/cargo-deadlinks ~/.cargo/bin
- uses: Swatinem/rust-cache@v2
- name: Generate Docs
env:
RUSTDOCFLAGS: --cfg docsrs
run: cargo deadlinks -- --features=custom,std
- run: |
cargo generate-lockfile -Z minimal-versions
cargo test --features=custom,std
2020-12-14 21:50:24 +00:00
# TODO: add aarch64-based macOS runner when it's supported by Github Actions
2020-12-14 21:50:24 +00:00
main-tests:
name: Tier 1 Test
2020-12-14 21:50:24 +00:00
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
toolchain: [nightly, beta, stable, 1.36]
# Only Test macOS on stable to reduce macOS CI jobs
include:
- os: macos-latest
toolchain: stable
2020-12-14 21:50:24 +00:00
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
2020-12-14 21:50:24 +00:00
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
2020-12-14 21:50:24 +00:00
- run: cargo test
- run: cargo test --features=std
- run: cargo test --features=custom # custom should do nothing here
2020-12-14 21:50:24 +00:00
- if: ${{ matrix.toolchain == 'nightly' }}
run: cargo test --benches
2020-12-14 21:50:24 +00:00
linux-tests:
name: Linux Test
2020-12-14 21:50:24 +00:00
runs-on: ubuntu-latest
strategy:
matrix:
target: [
x86_64-unknown-linux-musl,
i686-unknown-linux-gnu,
i686-unknown-linux-musl,
]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
2020-12-14 21:50:24 +00:00
with:
targets: ${{ matrix.target }}
- name: Install multilib
# update is needed to fix the 404 error on install, see:
# https://github.com/actions/virtual-environments/issues/675
run: |
sudo apt-get update
sudo apt-get install gcc-multilib
- uses: Swatinem/rust-cache@v2
- run: cargo test --target=${{ matrix.target }} --features=std
ios-tests:
name: iOS Simulator Test
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: x86_64-apple-ios
- name: Download cargo-dinghy
run: |
VERSION=0.6.2
URL="https://github.com/sonos/dinghy/releases/download/${VERSION}/cargo-dinghy-macos-${VERSION}.tgz"
curl -L $URL | tar -xz --strip-components=1 -C ~/.cargo/bin
cargo dinghy --version
- name: Setup Simulator
run: |
RUNTIME_ID=$(xcrun simctl list runtimes | grep iOS | cut -d ' ' -f 7 | tail -1)
SIM_ID=$(xcrun simctl create My-iphone7 com.apple.CoreSimulator.SimDeviceType.iPhone-7 $RUNTIME_ID)
xcrun simctl boot $SIM_ID
echo "device=$SIM_ID" >> $GITHUB_ENV
- uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo dinghy -d ${{ env.device }} test
2020-12-14 21:50:24 +00:00
windows-tests:
name: Windows Test
2020-12-14 21:50:24 +00:00
runs-on: windows-latest
strategy:
matrix:
toolchain: [
stable-x86_64-gnu,
stable-i686-gnu,
stable-i686-msvc,
]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
2020-12-14 21:50:24 +00:00
with:
toolchain: ${{ matrix.toolchain }}
- uses: Swatinem/rust-cache@v2
- run: cargo test --features=std
2020-12-14 21:50:24 +00:00
cross-tests:
name: Cross Test
runs-on: ubuntu-latest
2020-12-14 21:50:24 +00:00
strategy:
matrix:
target: [
aarch64-unknown-linux-gnu,
aarch64-linux-android,
mips-unknown-linux-gnu,
wasm32-unknown-emscripten,
]
2020-12-14 21:50:24 +00:00
steps:
- uses: actions/checkout@v3
- name: Install precompiled cross
run: |
2022-01-29 18:48:38 +03:00
export URL=$(curl -s https://api.github.com/repos/cross-rs/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url')
wget -O /tmp/binaries.tar.gz $URL
tar -C /tmp -xzf /tmp/binaries.tar.gz
mv /tmp/cross ~/.cargo/bin
- uses: Swatinem/rust-cache@v2
2020-12-14 21:50:24 +00:00
- name: Test
run: cross test --no-fail-fast --target=${{ matrix.target }} --features=std
2020-12-14 21:50:24 +00:00
macos-link:
name: macOS ARM64 Build/Link
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: aarch64-apple-darwin, aarch64-apple-ios
- uses: Swatinem/rust-cache@v2
- run: cargo test --no-run --target=aarch64-apple-darwin --features=std
- run: cargo test --no-run --target=aarch64-apple-ios --features=std
cross-link:
name: Cross Build/Link
2020-12-14 21:50:24 +00:00
runs-on: ubuntu-latest
strategy:
matrix:
target: [
sparcv9-sun-solaris,
x86_64-unknown-illumos,
x86_64-unknown-freebsd,
x86_64-unknown-netbsd,
]
steps:
- uses: actions/checkout@v3
- name: Install precompiled cross
run: |
2022-01-29 18:48:38 +03:00
export URL=$(curl -s https://api.github.com/repos/cross-rs/cross/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-unknown-linux-gnu.tar.gz")) | .browser_download_url')
wget -O /tmp/binaries.tar.gz $URL
tar -C /tmp -xzf /tmp/binaries.tar.gz
mv /tmp/cross ~/.cargo/bin
- uses: Swatinem/rust-cache@v2
- name: Build Tests
run: cross test --no-run --target=${{ matrix.target }} --features=std
web-tests:
name: Web Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- name: Install precompiled wasm-bindgen-test-runner
run: |
export VERSION=$(cargo metadata --format-version=1 | jq -r '.packages[] | select ( .name == "wasm-bindgen" ) | .version')
wget -O /tmp/binaries.tar.gz https://github.com/rustwasm/wasm-bindgen/releases/download/$VERSION/wasm-bindgen-$VERSION-x86_64-unknown-linux-musl.tar.gz
tar -C /tmp -xzf /tmp/binaries.tar.gz --strip-components=1
mv /tmp/wasm-bindgen-test-runner ~/.cargo/bin
- uses: Swatinem/rust-cache@v2
- name: Test (Node)
run: cargo test --target=wasm32-unknown-unknown --features=js
- name: Test (Firefox)
env:
GECKODRIVER: /usr/bin/geckodriver
run: cargo test --target=wasm32-unknown-unknown --features=js,test-in-browser
- name: Test (Chrome)
env:
CHROMEDRIVER: /usr/bin/chromedriver
run: cargo test --target=wasm32-unknown-unknown --features=js,test-in-browser
- name: Test (custom getrandom)
run: cargo test --target=wasm32-unknown-unknown --features=custom
wasm64-tests:
name: wasm64 Build/Link
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly # Need to build libstd
with:
components: rust-src
- uses: Swatinem/rust-cache@v2
- name: Build and Link tests (build-std)
# This target is Tier 3, so we have to build libstd ourselves.
# We currently cannot run these tests because wasm-bindgen-test-runner
# does not yet support memory64.
run: cargo test --no-run -Z build-std=std,panic_abort --target=wasm64-unknown-unknown --features=js
wasi-tests:
name: WASI Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasi
- name: Install precompiled wasmtime
run: |
export URL=$(curl -s https://api.github.com/repos/bytecodealliance/wasmtime/releases/latest | jq -r '.assets[] | select(.name | contains("x86_64-linux.tar.xz")) | .browser_download_url')
wget -O /tmp/binaries.tar.xz $URL
tar -C /tmp -xf /tmp/binaries.tar.xz --strip-components=1
mv /tmp/wasmtime ~/.cargo/bin
- uses: Swatinem/rust-cache@v2
- run: cargo test --target wasm32-wasi
build-tier2:
name: Tier 2 Build
runs-on: ubuntu-latest
strategy:
matrix:
target: [
2020-12-14 21:50:24 +00:00
x86_64-fuchsia,
x86_64-unknown-redox,
x86_64-fortanix-unknown-sgx,
]
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
2020-12-14 21:50:24 +00:00
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
2020-12-14 21:50:24 +00:00
- name: Build
run: cargo build --target=${{ matrix.target }} --features=std
2020-12-14 21:50:24 +00:00
build-tier3:
name: Tier 3 Build
2020-12-14 21:50:24 +00:00
runs-on: ubuntu-latest
strategy:
matrix:
# Supported tier 3 targets without libstd support
target: [
x86_64-unknown-hermit,
x86_64-wrs-vxworks,
aarch64-kmc-solid_asp3,
armv6k-nintendo-3ds,
riscv32imc-esp-espidf,
]
include:
# Supported tier 3 targets without libstd support
- target: x86_64-unknown-openbsd
features: ["std"]
- target: x86_64-unknown-dragonfly
features: ["std"]
- target: x86_64-unknown-haiku
features: ["std"]
# Unsupported tier 3 targets to test the rdrand feature
- target: x86_64-unknown-uefi
features: ["rdrand"]
- target: x86_64-unknown-l4re-uclibc
features: ["rdrand"]
2020-12-14 21:50:24 +00:00
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@nightly # Required to build libcore
2020-12-14 21:50:24 +00:00
with:
components: rust-src
- uses: Swatinem/rust-cache@v2
- run: cargo build -Z build-std=${{ contains(matrix.features, 'std') && 'std' || 'core'}} --target=${{ matrix.target }} --features="${{ join(matrix.features, ',') }}"
2020-12-14 21:50:24 +00:00
clippy-fmt:
name: Clippy + rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: dtolnay/rust-toolchain@stable
2020-12-14 21:50:24 +00:00
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
2020-12-14 21:50:24 +00:00
- name: clippy
run: cargo clippy --all --features=custom,std
2020-12-14 21:50:24 +00:00
- name: fmt
run: cargo fmt --all -- --check