⬆️ upgrade coverage workflow #16
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 Test and Benchmark | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize] | |
# Allow manual triggering | |
workflow_dispatch: | |
jobs: | |
benchmark: | |
name: Run tests and benchmarks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 1 | |
- name: Install Rust toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
- name: Setup rust cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "benchmark-cache" | |
cache-directories: | | |
~/.cargo/registry | |
~/.cargo/git | |
target | |
- name: Check formatting | |
run: cargo fmt --all -- --check | |
- name: Run clippy | |
run: cargo clippy --all-targets --all-features -- -D warnings | |
- name: Run tests | |
run: cargo test --all-features | |
- name: Run benchmarks | |
run: cargo bench | |
env: | |
CARGO_TERM_COLOR: always | |
- name: Upload benchmark results | |
uses: actions/upload-artifact@v3 | |
with: | |
name: benchmark-results-${{ github.sha }} | |
path: | | |
./target/criterion/**/*.json | |
./target/criterion/**/*.svg | |
if-no-files-found: error | |
retention-days: 90 | |
- name: Download previous benchmark data | |
uses: actions/download-artifact@v4 | |
continue-on-error: true | |
with: | |
path: prev-benchmark | |
name: benchmark-results-${{ github.event.before }} | |
- name: Store benchmark result | |
uses: benchmark-action/github-action-benchmark@v1 | |
with: | |
tool: "criterion" | |
output-file-path: target/criterion/**/new/*.json | |
alert-threshold: "150%" | |
- name: Check benchmark results | |
if: github.event_name == 'pull_request' | |
run: | | |
if [ -f prev-benchmark/bench_result.json ]; then | |
# Add custom benchmark comparison logic here | |
echo "Comparing benchmark results..." | |
fi | |
env: | |
CARGO_TERM_COLOR: always | |
RUST_BACKTRACE: 1 |