rework ci testing #362
Workflow file for this run
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: Rust | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
test: | |
name: Test on ${{ matrix.os }} using Rust ${{ matrix.rust }} with features '${{ matrix.cargo_features }}' | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
rust: [stable, nightly] | |
cargo_features: ['', 'alloc', 'default'] | |
steps: | |
- uses: hecrj/setup-rust-action@v2 | |
with: | |
rust-version: ${{ matrix.rust }} | |
targets: ${{ matrix.target }} | |
components: 'rustfmt, clippy' | |
- name: Install cargo tools | |
uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-hack,cargo-minimal-versions,cargo-fuzz | |
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default' | |
- uses: actions/checkout@v4 | |
- name: Install LLVM | |
if: matrix.os == 'windows-latest' | |
run: choco upgrade llvm -y | |
- name: Set clang path | |
if: matrix.os =='windows-latest' | |
run: echo "LIBCLANG_PATH=C:\Program Files\LLVM\bin" >> $GITHUB_ENV | |
shell: bash | |
- name: Cargo fmt | |
run: cargo +${{ matrix.rust }} fmt --all -- --check | |
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly' | |
- name: Cargo clippy | |
run: cargo +${{ matrix.rust }} clippy --all-targets --workspace --no-default-features --features "${{ matrix.cargo_features }}" | |
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly' && matrix.cargo_features == 'default' | |
- name: Test | |
run: cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}" --all-targets | |
- name: Minimal versions | |
# cargo-minimal-versions won't detach the path deps if we're using dev dependencies | |
# so we won't catch the case where we compile but fail tests because of path dependencies | |
run: | | |
cargo +${{ matrix.rust }} minimal-versions check --detach-path-deps --direct --workspace | |
cargo +${{ matrix.rust }} minimal-versions test --direct --workspace | |
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default' | |
- name: Updated versions | |
run: cargo update && cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}" | |
if: matrix.rust == 'stable' && matrix.cargo_features == 'default' | |
- name: Short Fuzz | |
run: | | |
cd fuzz || exit 1 | |
CFLAGS="-fsanitize=address -g -fno-omit-frame-pointer" | |
targets=( $(cargo metadata --format-version 1 --no-deps | jq -r ".packages[].targets[].name") ) | |
target_triple=$(cargo --version --verbose | grep 'host:' | cut -d ' ' -f 2) | |
for target in "${targets[@]}"; do | |
# https://github.com/rust-fuzz/cargo-fuzz/issues/355 | |
cargo +${{ matrix.rust }} fuzz run "$target" --target "${target_triple}" -- -max_total_time=10 | |
done | |
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default' && matrix.os == 'ubuntu-latest' | |
- name: Release Test | |
run: | | |
cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}" --release --all-targets | |
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default' | |