feat: improve test coverage from 86.31% to 88.59% lines, 43.78% to 46… #139
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: [push, pull_request] | |
| jobs: | |
| basic-checks: | |
| runs-on: ubuntu-latest | |
| env: | |
| CARGO_TERM_COLOR: always | |
| RUSTFLAGS: "-C instrument-coverage" | |
| LLVM_PROFILE_FILE: "profraw/cargo-test-%p-%m.profraw" | |
| MONGODB_URI: ${{ secrets.MONGODB_URI }} | |
| DB_NAME_TEST: ${{ secrets.DB_NAME_TEST }} | |
| DB_NAME_PRODUCTION: ${{ secrets.DB_NAME_PRODUCTION }} | |
| DB_DISPOSABLE_EMAILS_COLLECTION: ${{ secrets.DB_DISPOSABLE_EMAILS_COLLECTION }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust and coverage tools | |
| uses: dtolnay/rust-toolchain@stable | |
| - name: Install grcov | |
| run: cargo install grcov | |
| - name: Cache dependencies | |
| uses: Swatinem/rust-cache@v2 | |
| - name: Build Project (Debug) | |
| run: cargo build --verbose | |
| - name: Build Project (Release) | |
| run: cargo build --release --verbose | |
| - name: Run Tests with Coverage | |
| run: | | |
| mkdir -p profraw | |
| cargo test --verbose | |
| # Generate coverage report | |
| grcov profraw/ \ | |
| --binary-path ./target/debug/deps/ \ | |
| -s . \ | |
| -t lcov \ | |
| --branch \ | |
| --ignore-not-existing \ | |
| --ignore '../*' \ | |
| --ignore "/*" \ | |
| --ignore 'target/*' \ | |
| --ignore 'src/main.rs' \ | |
| --ignore 'src/lib.rs' \ | |
| --ignore 'src/openapi.rs' \ | |
| -o coverage.lcov | |
| - name: Upload coverage reports to Codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| files: coverage.lcov | |
| - name: Check Formatting | |
| run: cargo fmt --all -- --check | |
| - name: Lint with Clippy | |
| run: cargo clippy -- -D warnings |