|
| 1 | +name: Coverage |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request_target: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +env: |
| 12 | + CARGO_TERM_COLOR: always |
| 13 | + |
| 14 | +jobs: |
| 15 | + report: |
| 16 | + name: Report |
| 17 | + environment: coverage |
| 18 | + runs-on: ubuntu-latest |
| 19 | + env: |
| 20 | + CARGO_INCREMENTAL: "0" |
| 21 | + RUSTFLAGS: "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests" |
| 22 | + RUSTDOCFLAGS: "-Z profile -C codegen-units=1 -C inline-threshold=0 -C link-dead-code -C overflow-checks=off -C panic=abort -Z panic_abort_tests" |
| 23 | + |
| 24 | + steps: |
| 25 | + - id: checkout_push |
| 26 | + if: github.event_name == 'push' |
| 27 | + name: Checkout Repository (Push) |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - id: checkout_pull_request_target |
| 31 | + if: github.event_name == 'pull_request_target' |
| 32 | + name: Checkout Repository (Pull Request Target) |
| 33 | + uses: actions/checkout@v4 |
| 34 | + with: |
| 35 | + ref: "refs/pull/${{ github.event.pull_request.number }}/head" |
| 36 | + |
| 37 | + - id: setup |
| 38 | + name: Setup Toolchain |
| 39 | + uses: dtolnay/rust-toolchain@stable |
| 40 | + with: |
| 41 | + toolchain: nightly |
| 42 | + components: llvm-tools-preview |
| 43 | + |
| 44 | + - id: cache |
| 45 | + name: Enable Workflow Cache |
| 46 | + uses: Swatinem/rust-cache@v2 |
| 47 | + |
| 48 | + - id: tools |
| 49 | + name: Install tools |
| 50 | + uses: taiki-e/install-action@v2 |
| 51 | + with: |
| 52 | + tool: grcov,cargo-llvm-cov,nextest |
| 53 | + |
| 54 | + - id: print |
| 55 | + name: Print Coverage Report |
| 56 | + run: cargo llvm-cov nextest |
| 57 | + |
| 58 | + - id: report |
| 59 | + name: Generate Coverage Report |
| 60 | + |
| 61 | + |
| 62 | + - id: upload |
| 63 | + name: Upload Coverage Report |
| 64 | + uses: codecov/codecov-action@v3 |
| 65 | + with: |
| 66 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 67 | + files: ${{ steps.coverage.outputs.report }} |
| 68 | + verbose: true |
| 69 | + fail_ci_if_error: true |
0 commit comments