Various improvements #31
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 | |
| permissions: | |
| actions: read | |
| contents: read | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| CARGO_NET_RETRY: 10 | |
| CARGO_TERM_COLOR: always | |
| CI: 1 | |
| RUSTUP_MAX_RETRIES: 10 | |
| RUST_BACKTRACE: short | |
| jobs: | |
| # Disabled until the crate is published to crates.io for the first time. | |
| # cargo-semver-checks needs a baseline version to compare against. | |
| # Re-enable after initial `cargo publish`. | |
| # | |
| # semver-checks: | |
| # name: Semver Checks | |
| # runs-on: ubuntu-24.04 | |
| # steps: | |
| # - uses: actions/checkout@v6 | |
| # - uses: obi1kenobi/cargo-semver-checks-action@v2 | |
| build-test: | |
| name: Build+Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| fetch-depth: 20 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache Dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| - name: cargo fmt (check) | |
| run: cargo fmt -- --check -l | |
| - name: Build | |
| run: cargo build | |
| - name: Test | |
| run: cargo test -- --nocapture --quiet | |
| - name: cargo clippy | |
| run: cargo clippy -- -D warnings | |
| msrv: | |
| name: MSRV | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Determine MSRV from Cargo.toml | |
| id: msrv | |
| run: | | |
| msrv=$(sed -n 's/^rust-version *= *"\(.*\)"/\1/p' Cargo.toml) | |
| if [ -z "$msrv" ]; then | |
| echo "::error::rust-version not found in Cargo.toml" | |
| exit 1 | |
| fi | |
| echo "version=$msrv" >> "$GITHUB_OUTPUT" | |
| - name: Install MSRV toolchain (${{ steps.msrv.outputs.version }}) | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: ${{ steps.msrv.outputs.version }} | |
| - name: Cache Dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| # Only build the library itself at MSRV — dev-dependencies may | |
| # legitimately require a newer Rust version. | |
| - name: Build (MSRV) | |
| run: cargo build --lib | |
| - name: Check (no-std, MSRV) | |
| run: cargo check --lib --no-default-features | |
| fuzz: | |
| name: Fuzz | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Install nightly toolchain | |
| uses: dtolnay/rust-toolchain@nightly | |
| - name: Install cargo-fuzz | |
| run: cargo install cargo-fuzz --locked | |
| - name: Cache Dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| with: | |
| workspaces: fuzz | |
| - name: Generate seed corpus | |
| run: cargo run --manifest-path fuzz/Cargo.toml --bin generate-corpus | |
| - name: Fuzz all targets (2 minutes each) | |
| run: | | |
| mkdir -p fuzz-logs | |
| for target in $(cargo +nightly fuzz list); do | |
| echo "--- Fuzzing $target (2 min) ---" | |
| cargo +nightly fuzz run "$target" -- -max_total_time=120 \ | |
| > "fuzz-logs/$target.log" 2>&1 \ | |
| && echo " $target: OK" \ | |
| || { echo "::error::Fuzzer $target failed"; cat "fuzz-logs/$target.log"; exit 1; } | |
| # Print final stats line | |
| tail -1 "fuzz-logs/$target.log" | |
| done | |
| working-directory: fuzz |