xref: /webrtc/.github/workflows/grcov.yml (revision 97b16774)
1name: coverage
2
3on:
4  push:
5    branches: [ master ]
6  pull_request:
7    branches: [ master ]
8
9concurrency:
10  group: ${{ github.workflow }}-${{ github.ref }}
11  cancel-in-progress: true
12
13env:
14  CARGO_TERM_COLOR: always
15
16jobs:
17  grcov:
18    name: Coverage
19    runs-on: ${{ matrix.os }}
20    strategy:
21      matrix:
22        os:
23          - ubuntu-latest
24        toolchain:
25          - nightly
26        cargo_flags:
27          - "--all-features"
28    steps:
29      - name: Checkout source code
30        uses: actions/checkout@v2
31
32      - name: Install Rust
33        uses: actions-rs/toolchain@v1
34        with:
35          profile: minimal
36          toolchain: ${{ matrix.toolchain }}
37          override: true
38
39      - name: Install grcov
40        uses: actions-rs/install@v0.1
41        with:
42          crate: grcov
43          version: latest
44          use-tool-cache: true
45
46      - name: Test
47        uses: actions-rs/cargo@v1
48        with:
49          command: test
50          args: --all --no-fail-fast ${{ matrix.cargo_flags }}
51        env:
52          CARGO_INCREMENTAL: "0"
53          RUSTFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort -Cdebug-assertions=off'
54          RUSTDOCFLAGS: '-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort -Cdebug-assertions=off'
55
56      - name: Generate coverage data
57        id: grcov
58        # uses: actions-rs/grcov@v0.1
59        run: |
60          grcov target/debug/ \
61              --branch \
62              --llvm \
63              --source-dir . \
64              --output-path lcov.info \
65              --ignore='/**' \
66              --ignore='C:/**' \
67              --ignore='../**' \
68              --ignore-not-existing \
69              --excl-line "#\\[derive\\(" \
70              --excl-br-line "#\\[derive\\(" \
71              --excl-start "#\\[cfg\\(test\\)\\]" \
72              --excl-br-start "#\\[cfg\\(test\\)\\]" \
73              --commit-sha ${{ github.sha }} \
74              --service-job-id ${{ github.job }} \
75              --service-name "GitHub Actions" \
76              --service-number ${{ github.run_id }}
77      - name: Upload coverage as artifact
78        uses: actions/upload-artifact@v2
79        with:
80          name: lcov.info
81          # path: ${{ steps.grcov.outputs.report }}
82          path: lcov.info
83
84      - name: Upload coverage to codecov.io
85        uses: codecov/codecov-action@v1
86        with:
87          # file: ${{ steps.grcov.outputs.report }}
88          file: lcov.info
89          fail_ci_if_error: true
90