Skip to content

Commit 499f357

Browse files
authored
Merge pull request #667 from viccuad/add-coverage
ci: Add codecov support
2 parents d344f03 + 3bc9ba9 commit 499f357

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

.github/workflows/ci.yml

+36
Original file line numberDiff line numberDiff line change
@@ -84,3 +84,39 @@ jobs:
8484
with:
8585
command: clippy
8686
args: -- -D warnings
87+
88+
coverage:
89+
name: coverage
90+
runs-on: ubuntu-latest
91+
steps:
92+
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
93+
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
94+
with:
95+
profile: minimal
96+
toolchain: stable
97+
override: true
98+
- uses: taiki-e/install-action@5794068c211bc8f5f4514b7c3f03d6adbe66f1b7 # v2.26.18
99+
with:
100+
tool: cargo-tarpaulin
101+
- name: Generate unit-tests coverage
102+
run: make coverage-unit-tests
103+
- name: Upload unit-tests coverage to Codecov
104+
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1
105+
env:
106+
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
107+
with:
108+
name: unit-tests
109+
directory: coverage/unit-tests
110+
flags: unit-tests
111+
verbose: true
112+
- name: Generate integration-tests coverage
113+
run: make coverage-integration-tests
114+
- name: Upload unit-tests coverage to Codecov
115+
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1
116+
env:
117+
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
118+
with:
119+
name: integration-tests
120+
directory: coverage/integration-tests
121+
flags: integration-tests
122+
verbose: true

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@
22
bom-cargo.json
33
/bin
44
/registry
5+
6+
# coverage instrumentation:
7+
*.profraw

Makefile

+17
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,23 @@ unit-tests: fmt lint
3131
integration-tests: fmt lint
3232
cargo test --test '*'
3333

34+
.PHONY: coverage
35+
coverage: coverage-unit-tests coverage-integration-tests
36+
37+
.PHONY: coverage-unit-tests
38+
coverage-unit-tests:
39+
# integration-tests with llvm need +nightly. Hence, enable +nightly on
40+
# unit-tests, and use --skip-clean to not recompile on CI if not needed
41+
cargo tarpaulin --verbose --skip-clean --engine=llvm \
42+
--all-features --lib --bin --follow-exec \
43+
--out xml --out html --output-dir coverage/unit-tests
44+
45+
.PHONY: coverage-integration-tests
46+
coverage-integration-tests:
47+
cargo tarpaulin --verbose --skip-clean --engine=llvm \
48+
--all-features --test integration_test --follow-exec \
49+
--out xml --out html --output-dir coverage/integration-tests
50+
3451
.PHONY: clean
3552
clean:
3653
cargo clean

coverage/integration-tests/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

coverage/unit-tests/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Ignore everything in this directory
2+
*
3+
# Except this file
4+
!.gitignore

0 commit comments

Comments
 (0)