Merge pull request #197 from matrix-org/dependabot/cargo/wasmtime-gte… #529
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: Check | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
rustfmt: | |
name: Check style | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Install toolchain | |
run: | | |
rustup toolchain install nightly | |
rustup default nightly | |
rustup component add rustfmt | |
- name: Check style | |
run: cargo fmt --all -- --check | |
clippy: | |
name: Run Clippy | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Install toolchain | |
run: | | |
rustup toolchain install 1.81.0 | |
rustup default 1.81.0 | |
rustup component add clippy | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Run Clippy | |
run: | | |
run_clippy () { | |
echo "::group::cargo clippy $@" | |
cargo clippy --bins --tests $@ -- -D warnings | |
echo "::endgroup::" | |
} | |
run_clippy --all-features | |
run_clippy --no-default-features | |
sed -e 's/#.*//' -e '/^\s*$/d' -e 's/\s\+/,/g' features.txt | while read -r FEATURES; do | |
run_clippy --no-default-features --features "${FEATURES}" | |
done | |
test: | |
name: Run test suite with Rust ${{ matrix.toolchain }} | |
needs: [rustfmt, clippy] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
continue-on-error: "${{ matrix.toolchain == 'beta' || matrix.toolchain == 'nightly' }}" | |
strategy: | |
fail-fast: false # Continue other jobs if one fails to help filling the cache | |
matrix: | |
toolchain: | |
- stable | |
- beta | |
- nightly | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Install toolchain | |
run: | | |
rustup toolchain install ${{ matrix.toolchain }} | |
rustup default ${{ matrix.toolchain }} | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Setup OPA | |
uses: open-policy-agent/setup-opa@v2 | |
with: | |
version: latest | |
- name: Build OPA bundles for test | |
run: make build-opa | |
- name: Test | |
run: cargo test --all-features | |
minimal-versions: | |
name: Run test suite with minimal versions | |
needs: [rustfmt, clippy] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Install toolchain | |
run: | | |
rustup toolchain install 1.76.0 # MSRV | |
rustup default 1.76.0 # MSRV | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Setup OPA | |
uses: open-policy-agent/setup-opa@v2 | |
with: | |
version: latest | |
- name: Build OPA bundles for test | |
run: make build-opa | |
- name: Install minimal versions | |
env: | |
RUSTC_BOOTSTRAP: "1" | |
run: | | |
cargo update -Z minimal-versions | |
- name: Test | |
run: cargo test --all-features --locked | |
coverage: | |
name: Code coverage | |
needs: [rustfmt, clippy] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout the code | |
uses: actions/checkout@v4 | |
- name: Install toolchain | |
run: | | |
rustup toolchain install stable | |
rustup default stable | |
- name: Setup Rust cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Setup OPA | |
uses: open-policy-agent/setup-opa@v2 | |
with: | |
version: latest | |
- name: Download grcov | |
run: | | |
mkdir -p "${HOME}/.local/bin" | |
curl -sL https://github.com/mozilla/grcov/releases/download/v0.8.13/grcov-x86_64-unknown-linux-gnu.tar.bz2 | tar jxf - -C "${HOME}/.local/bin" | |
echo "$HOME/.local/bin" >> $GITHUB_PATH | |
- name: Build OPA bundles for test | |
run: make build-opa | |
- name: Run test suite with profiling enabled | |
run: | | |
cargo test --all-features --no-fail-fast --tests | |
env: | |
RUSTFLAGS: "-Cinstrument-coverage" | |
LLVM_PROFILE_FILE: "cargo-test-%p-%m.profraw" | |
- name: Build grcov report | |
run: | | |
mkdir -p target/coverage | |
grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov | |
- name: Upload to codecov.io | |
uses: codecov/codecov-action@v5 | |
with: | |
files: target/coverage/*.lcov | |
token: ${{ secrets.CODECOV_TOKEN }} | |
tests-done: | |
name: Tests done | |
if: ${{ always() }} | |
needs: | |
- rustfmt | |
- clippy | |
- test | |
- coverage | |
- minimal-versions | |
runs-on: ubuntu-latest | |
steps: | |
- uses: matrix-org/done-action@v3 | |
with: | |
needs: ${{ toJSON(needs) }} |