Skip to content

ci: Benchmark with CodSpeed.io #589

ci: Benchmark with CodSpeed.io

ci: Benchmark with CodSpeed.io #589

Workflow file for this run

name: Continuous integration
on:
push:
branches:
- main
pull_request:
branches:
- main
merge_group:
types: [checks_requested]
workflow_dispatch: {}
env:
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: 0
MIRIFLAGS: '-Zmiri-permissive-provenance' # Required due to warnings in bitvec 1.0.1
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v0
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build docs
run: cargo doc --no-deps --all-features
env:
RUSTDOCFLAGS: "-Dwarnings"
miri:
# Not required, we can ignore it for the merge queue check.
if: github.event_name != 'merge_group'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install latest nightly
uses: dtolnay/rust-toolchain@nightly
with:
components: miri
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v0-nightly
- name: Run miri
run: cargo miri test
benches:
name: continuous benchmarking
# Not required, we can ignore it for the merge queue check.
if: github.event_name != 'merge_group'
runs-on: ubuntu-latest
permissions:
checks: write
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v0
- uses: cargo-bins/cargo-binstall@main
- name: Install cargo-codspeed
run: cargo binstall cargo-codspeed --force
- name: Override criterion with the CodSpeed harness
run: cargo add --dev codspeed-criterion-compat --rename criterion
- name: Build benchmarks
run: cargo codspeed build criterion_benches
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: "cargo codspeed run criterion_benches"
tests:
runs-on: ubuntu-latest
strategy:
matrix:
rust: ['1.75', stable, beta, nightly]
# workaround to ignore non-stable tests when running the merge queue checks
# see: https://github.community/t/how-to-conditionally-include-exclude-items-in-matrix-eg-based-on-branch/16853/6
isMerge:
- ${{ github.event_name == 'merge_group' }}
exclude:
- rust: '1.75'
isMerge: true
- rust: beta
isMerge: true
- rust: nightly
isMerge: true
name: tests (Rust ${{ matrix.rust }})
steps:
- uses: actions/checkout@v3
- id: toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Configure default rust toolchain
run: rustup override set ${{steps.toolchain.outputs.name}}
- uses: Swatinem/rust-cache@v2
with:
prefix-key: v0-rust-${{ matrix.rust }}
- name: Build with no features
run: cargo test --verbose --no-default-features --no-run
- name: Tests with no features
run: cargo test --verbose --no-default-features
- name: Build with all features
run: cargo test --verbose --all-features --no-run
- name: Tests with all features
run: cargo test --verbose --all-features
rs-semver-checks:
needs: [check]
if: ${{ github.event_name == 'pull_request' }}
uses: CQCL/hugrverse-actions/.github/workflows/rs-semver-checks.yml@main
secrets:
GITHUB_PAT: ${{ secrets.HUGRBOT_PAT }}
coverage:
if: github.event_name != 'merge_group'
needs: [tests, check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: mozilla-actions/[email protected]
- uses: dtolnay/rust-toolchain@nightly
with:
components: llvm-tools-preview
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Run tests with coverage instrumentation
run: |
cargo llvm-cov clean --workspace
cargo llvm-cov --doctests
- name: Generate coverage report
run: cargo llvm-cov report --codecov --output-path coverage.json
- name: Upload coverage to codecov.io
uses: codecov/codecov-action@v3
with:
files: coverage.json
name: ubuntu
token: ${{ secrets.CODECOV_TOKEN }}