name: Continuous Integration - Tests
on:
push:
paths:
- ".github/workflows/tests.yml"
- "**/Cargo.toml"
- "**/Cargo.lock"
- "**/*.rs"
pull_request:
paths:
- ".github/workflows/tests.yml"
- "**/Cargo.toml"
- "**/Cargo.lock"
- "**/*.rs"
workflow_dispatch:
concurrency:
group: tests-${{ github.ref_name }}
cancel-in-progress: true
env:
CODE_COVERAGE_REPORT_FOLDER: target/coverage
CODE_COVERAGE_REPORT_FILE: report.xml
jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Install Rust (stable)
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
components: llvm-tools-preview
- name: Install Brioche
uses: brioche-dev/setup-brioche@v1.5.0
- name: Install cargo-llvm-cov
run: brioche install -r cargo_llvm_cov
- name: Cache cargo registry + build
uses: actions/cache@v5.0.2
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/git/db
~/.cargo/registry/cache
~/.cargo/registry/index
target
key: unit-tests-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests and generate coverage reports
run: |
mkdir -p ${{ env.CODE_COVERAGE_REPORT_FOLDER }}
cargo llvm-cov --workspace --all-features --cobertura --output-path ${{ env.CODE_COVERAGE_REPORT_FOLDER }}/${{ env.CODE_COVERAGE_REPORT_FILE }}
- name: Upload coverage artifacts
uses: actions/upload-artifact@v6.0.0
with:
name: coverage
path: |
${{ env.CODE_COVERAGE_REPORT_FOLDER }}/${{ env.CODE_COVERAGE_REPORT_FILE }}
retention-days: 7
- name: Generate coverage summary
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: ${{ env.CODE_COVERAGE_REPORT_FOLDER }}/${{ env.CODE_COVERAGE_REPORT_FILE }}
indicators: false
bench-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
- name: Install Rust (stable)
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Cache cargo registry + build
uses: actions/cache@v5.0.2
with:
path: |
~/.cargo/.crates.toml
~/.cargo/.crates2.json
~/.cargo/bin
~/.cargo/git/db
~/.cargo/registry/cache
~/.cargo/registry/index
target
key: bench-tests-${{ hashFiles('**/Cargo.lock') }}
- name: Run tests
run: cargo bench --all-features