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