From 05e6107b1dd5786adeb887212758989d202c7eb4 Mon Sep 17 00:00:00 2001 From: haraldmaida Date: Wed, 11 Jun 2025 06:23:05 +0200 Subject: [PATCH 1/2] chore: use llvm-cov instead of tarpaulin for code coverage --- .github/workflows/coverage.yml | 44 ++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index d087e38..3cda98f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -2,34 +2,36 @@ name: Coverage on: push: - branches: [ master ] pull_request: - branches: [ master ] -jobs: - coverage: - name: Coverage +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true - runs-on: ubuntu-latest +permissions: + contents: read +jobs: + code-coverage: + name: Code Coverage + runs-on: ubuntu-latest + env: + CARGO_TERM_COLOR: always steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install stable toolchain + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install toolchain uses: actions-rs/toolchain@v1 with: - profile: minimal toolchain: stable override: true - - - name: Run Tarpaulin - uses: actions-rs/tarpaulin@v0.1 - with: - timeout: 120 - args: '--ignore-tests --all-features --verbose' - - - name: Upload to codecov.io - uses: codecov/codecov-action@v1.0.2 + - name: Install cargo-llvm-cov + uses: taiki-e/install-action@cargo-llvm-cov + - name: Generate code coverage + run: cargo llvm-cov --all-features --workspace --codecov --output-path codecov.json --ignore-filename-regex "tests|test_dsl" + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v5 with: - token: ${{secrets.CODECOV_TOKEN}} + token: ${{ secrets.CODECOV_TOKEN }} + files: codecov.json + fail_ci_if_error: true From 0e5db6798ac80b5990397f0c952c23c9fcd4399e Mon Sep 17 00:00:00 2001 From: haraldmaida Date: Wed, 11 Jun 2025 06:32:01 +0200 Subject: [PATCH 2/2] chore: add fmt, clippy, msrv and doc to CI workflow --- .github/workflows/ci.yml | 183 +++++++++++++++++++++++++++++++-------- 1 file changed, 146 insertions(+), 37 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7e9c64..46c9149 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,53 +2,162 @@ name: CI on: push: - branches: [ master ] + branches: + - main pull_request: - branches: [ master ] -jobs: - test: - name: Test - Rust ${{matrix.rust}} - ${{matrix.os}} +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - rust: [stable, beta, 1.39.0] +env: + RUST_BACKTRACE: 1 + RUSTFLAGS: -Dwarnings - runs-on: ${{ matrix.os }} +permissions: + contents: read +jobs: + # Depends on all actions that are required for a "successful" CI run. + tests-pass: + name: all checks successful + runs-on: ubuntu-latest + needs: + - fmt + - clippy + - msrv + - doc + - test-all-features + - test-default-features steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Install ${{matrix.rust}} toolchain + - run: exit 0 + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install stable toolchain uses: actions-rs/toolchain@v1 with: - profile: minimal - toolchain: ${{matrix.rust}} + toolchain: stable override: true + - name: Run cargo clippy + uses: actions-rs/cargo@v1 + with: + command: clippy + args: --all-features + - uses: Swatinem/rust-cache@v2 - - name: Build - run: cargo build --verbose - - - name: Run tests - run: cargo test --verbose --no-fail-fast - - - name: Run tests --all-features - run: cargo test --all-features --verbose --no-fail-fast - - - name: Run tests --features "serde1" - run: cargo test --features "serde1" --verbose --no-fail-fast - - - name: Run tests --features "bigint" - run: cargo test --features "bigint" --verbose --no-fail-fast + fmt: + name: Rustfmt check + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install nightly toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + components: rustfmt + - run: cargo +nightly fmt --check --all + - uses: Swatinem/rust-cache@v2 - - name: Run tests --features "bigdecimal" - run: cargo test --features "bigdecimal" --verbose --no-fail-fast + test-all-features: + name: Run tests for all features + runs-on: ${{ matrix.os }} + needs: + - fmt + - clippy + - msrv + - doc + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - macos-latest + - windows-latest + rust: + - stable + - beta + - nightly + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ matrix.rust }} + override: true + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test + args: --all-features --no-fail-fast + - uses: Swatinem/rust-cache@v2 + + test-default-features: + name: Test with default features + runs-on: ubuntu-latest + needs: + - fmt + - clippy + - msrv + - doc + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + override: true + - name: Run cargo test + uses: actions-rs/cargo@v1 + with: + command: test --no-fail-fast + - uses: Swatinem/rust-cache@v2 - - name: Run tests --features "chrono" - run: cargo test --features "chrono" --verbose --no-fail-fast + msrv: + name: Build with MSRV + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Get current MSRV from Cargo.toml + id: current_msrv + run: | + msrv=$(cat Cargo.toml | grep rust-version | sed 's/.* = "//; s/"//') + echo "msrv=$msrv" >> $GITHUB_OUTPUT + - name: Install MSRV toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: ${{ steps.current_msrv.outputs.msrv }} + override: true + - name: Run cargo build + uses: actions-rs/cargo@v1 + with: + command: build + args: --all-features + env: + RUSTFLAGS: "" # remove -Dwarnings - - name: Run tests --features "regex" - run: cargo test --features "regex" --verbose --no-fail-fast + doc: + name: API Docs + runs-on: ubuntu-latest + steps: + - name: Checkout sources + uses: actions/checkout@v4 + - name: Install stable toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + override: true + - name: Run cargo doc + uses: actions-rs/cargo@v1 + with: + command: doc + args: --all-features --no-deps + - uses: Swatinem/rust-cache@v2