test: add Shuttle-based concurrency tests #59
Workflow file for this run
This file contains hidden or 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: CI | |
| on: | |
| pull_request: | |
| merge_group: | |
| permissions: | |
| contents: read | |
| jobs: | |
| fmt: | |
| name: Cargo fmt | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@nightly | |
| with: | |
| components: rustfmt | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Run fmt check | |
| id: cargoFmt | |
| shell: bash | |
| run: cargo fmt --all -- --check | |
| clippy: | |
| name: Cargo clippy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Run clippy check | |
| id: cargoClippy | |
| shell: bash | |
| run: RUSTFLAGS="--cfg tokio_unstable" cargo clippy --workspace --all-features -- -D warnings | |
| build: | |
| name: Build | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| toolchain: | |
| # MSRV history: | |
| # 1.86 - trait upcasts (required) | |
| # 1.87 - `extend_from_string` | |
| # 1.88 - darling 0.23 | |
| # 1.91 - required for const TypeId::of | |
| - "1.91.0" # Current MSRV | |
| - stable | |
| - nightly | |
| flags: | |
| - "--all-features" | |
| - "--no-default-features" | |
| env: | |
| RUST_BACKTRACE: 1 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build | |
| uses: ./.github/actions/rust-build | |
| with: | |
| toolchain: ${{ matrix.toolchain }} | |
| flags: ${{ matrix.flags }} | |
| shuttle: | |
| name: Shuttle concurrency tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Run shuttle tests | |
| run: ./scripts/test-shuttle.sh | |
| docs-rs: | |
| name: Docs.rs Build Check | |
| runs-on: ubuntu-latest | |
| # Skipped on release branches: the packaged crate resolves siblings from | |
| # crates.io, so bumped-but-unpublished versions always fail here. | |
| if: ${{ !startsWith(github.head_ref, 'release-') && !startsWith(github.head_ref, 'release/') }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@nightly | |
| - uses: dtolnay/install@cargo-docs-rs | |
| - name: Check docs.rs build | |
| run: ./scripts/check-docsrs.sh | |
| fuzz: | |
| # Quick smoke test on PRs, should catch obvious regressions. | |
| name: Fuzz Smoke Test | |
| runs-on: ubuntu-latest | |
| env: | |
| RUST_BACKTRACE: 1 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@nightly | |
| - uses: Swatinem/rust-cache@v2 | |
| with: | |
| shared-key: fuzz-pr-${{ runner.os }} | |
| workspaces: | | |
| . -> target | |
| fuzz -> fuzz/target | |
| - name: Install cargo-fuzz | |
| uses: dtolnay/install@cargo-fuzz | |
| - name: Run fuzz_json | |
| run: cargo +nightly fuzz run fuzz_json -- -max_total_time=60 | |
| - name: Run fuzz_emf | |
| run: cargo +nightly fuzz run fuzz_emf -- -max_total_time=60 | |
| # Single aggregating check so branch protection only needs to require "CI Pass" | |
| # instead of naming every individual job. This job fails if any of its | |
| # dependencies failed or were cancelled; skipped jobs (e.g. docs-rs on release | |
| # branches) do not count as failures. | |
| value-consts: | |
| name: Value impl completeness | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| - uses: Swatinem/rust-cache@v2 | |
| - name: Check Value impls define SHAPE/UNIT and ValueWriter impls define values | |
| # This cfg strips the defaults off `Value::SHAPE`, `Value::UNIT`, and | |
| # `ValueWriter::values`, so impls have to state them. It covers what `cargo check` | |
| # compiles (lib/bin, not tests or examples), and only forces an explicit choice for | |
| # `values`, not a correct one: per-wrapper tests verify the forwarding itself. | |
| # | |
| # metrique-util is excluded from the full check because tokio-metrics | |
| # (pulled in by the tokio-metrics-bridge feature) has Value impls that | |
| # don't yet provide SHAPE/UNIT. RUSTFLAGS propagates to all crates | |
| # including dependencies, so we check metrique-util separately without | |
| # that feature. Remove this workaround once tokio-metrics adds the consts. | |
| run: | | |
| RUSTFLAGS="--cfg metrique_require_explicit_impls --cfg tokio_unstable" \ | |
| cargo check --workspace --all-features \ | |
| --exclude metrique-util | |
| RUSTFLAGS="--cfg metrique_require_explicit_impls --cfg tokio_unstable" \ | |
| cargo check -p metrique-util --features state,pending-sink,sysinfo-bridge | |
| ci-pass: | |
| name: CI Pass | |
| runs-on: ubuntu-latest | |
| needs: [fmt, clippy, build, shuttle, docs-rs, fuzz, value-consts] | |
| if: always() | |
| steps: | |
| - run: | | |
| if [[ "${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }}" == "true" ]]; then | |
| echo "One or more required jobs failed or were cancelled" | |
| exit 1 | |
| fi |