Skip to content

Commit d653f8c

Browse files
committed
Add workflow to report coverage on push to main
Signed-off-by: Marcel Guzik <[email protected]>
1 parent 6ea7bd4 commit d653f8c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

.github/workflows/head_coverage.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Upload code coverage report every time there is a push to the main branch.
2+
#
3+
# Codecov guides suggest uploading coverage for push and pull_request events.
4+
# pull-request-checks.yml only runs on PRs though, and when coverage upload only
5+
# happens there, it has an effect of codecov patch reports not picking up the
6+
# latest HEAD and displaying coverage changes that have already been made in
7+
# previous PRs. To fix this, we upload report every time we push to main, which
8+
# also happens when a PR gets merged.
9+
10+
name: Upload HEAD coverage
11+
12+
on:
13+
push:
14+
branches:
15+
- main
16+
17+
env:
18+
CARGO_TERM_COLOR: always
19+
20+
jobs:
21+
head-coverage:
22+
name: Upload HEAD coverage
23+
runs-on: ubuntu-20.04
24+
env:
25+
RUSTFLAGS: -D warnings
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
30+
- name: Enable toolchain via github action
31+
uses: dtolnay/rust-toolchain@stable
32+
with:
33+
components: llvm-tools-preview
34+
35+
- name: Enable cache
36+
uses: Swatinem/rust-cache@v2
37+
38+
- name: cargo install cargo-llvm-cov
39+
uses: taiki-e/install-action@cargo-llvm-cov
40+
41+
- name: cargo llvm-cov
42+
run: cargo llvm-cov --no-fail-fast --locked --all-features --all-targets --codecov --output-path codecov.json
43+
44+
# https://github.com/rust-lang/cargo/issues/6669
45+
- name: cargo test --doc
46+
run: cargo test --locked --all-features --doc
47+
48+
- name: Upload to codecov.io
49+
uses: codecov/codecov-action@v3
50+
with:
51+
fail_ci_if_error: true

0 commit comments

Comments
 (0)