Merge pull request #156 from Hallab7/feat/stream-insurance-governance #66
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: Test Coverage Check | |
| on: | |
| pull_request: | |
| branches: [ main, master ] | |
| push: | |
| branches: [ main, master ] | |
| env: | |
| CARGO_TERM_COLOR: always | |
| jobs: | |
| test-coverage: | |
| name: Test Coverage | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| components: rustfmt, clippy | |
| - name: Cache cargo registry | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Install cargo-tarpaulin | |
| run: cargo install cargo-tarpaulin --version 0.27.0 | |
| - name: Run tests with coverage | |
| run: cargo tarpaulin --workspace --all-targets --out Xml --output-dir target/coverage | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: target/coverage/cobertura.xml | |
| flags: unittests | |
| name: utility-drip-contracts | |
| fail_ci_if_error: false | |
| - name: Check coverage threshold | |
| run: | | |
| cargo tarpaulin --workspace --all-targets --out Json --output-dir target/coverage | |
| COVERAGE=$(cat target/coverage/tarpaulin.json | jq -r '.files | map(.coverage) | add / .files | length * 100') | |
| echo "Current coverage: $COVERAGE%" | |
| THRESHOLD=85 | |
| if (( $(echo "$COVERAGE < $THRESHOLD" | bc -l) )); then | |
| echo "❌ Coverage $COVERAGE% is below threshold $THRESHOLD%" | |
| exit 1 | |
| else | |
| echo "✅ Coverage $COVERAGE% meets threshold $THRESHOLD%" | |
| fi | |
| - name: Generate HTML coverage report | |
| run: cargo tarpaulin --workspace --all-targets --out Html --output-dir target/coverage | |
| - name: Upload coverage report | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: target/coverage/tarpaulin.html | |
| retention-days: 30 |