Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add codecov support #667

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,39 @@ jobs:
with:
command: clippy
args: -- -D warnings

coverage:
name: coverage
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@1e31de5234b9f8995739874a8ce0492dc87873e2 # v4.0.0
- uses: actions-rs/toolchain@16499b5e05bf2e26879000db0c1d13f7e13fa3af # v1.0.7
with:
profile: minimal
toolchain: stable
override: true
- uses: taiki-e/install-action@5794068c211bc8f5f4514b7c3f03d6adbe66f1b7 # v2.26.18
with:
tool: cargo-tarpaulin
- name: Generate unit-tests coverage
run: make coverage-unit-tests
- name: Upload unit-tests coverage to Codecov
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
with:
name: unit-tests
directory: coverage/unit-tests
flags: unit-tests
verbose: true
- name: Generate integration-tests coverage
run: make coverage-integration-tests
- name: Upload unit-tests coverage to Codecov
uses: codecov/codecov-action@e0b68c6749509c5f83f984dd99a76a1c1a231044 # v4.0.1
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_ORG_TOKEN }}
with:
name: integration-tests
directory: coverage/integration-tests
flags: integration-tests
verbose: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
bom-cargo.json
/bin
/registry

# coverage instrumentation:
*.profraw
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,23 @@ unit-tests: fmt lint
integration-tests: fmt lint
cargo test --test '*'

.PHONY: coverage
coverage: coverage-unit-tests coverage-integration-tests

.PHONY: coverage-unit-tests
coverage-unit-tests:
# integration-tests with llvm need +nightly. Hence, enable +nightly on
# unit-tests, and use --skip-clean to not recompile on CI if not needed
cargo tarpaulin --verbose --skip-clean --engine=llvm \
--all-features --lib --bin --follow-exec \
--out xml --out html --output-dir coverage/unit-tests

.PHONY: coverage-integration-tests
coverage-integration-tests:
cargo tarpaulin --verbose --skip-clean --engine=llvm \
--all-features --test integration_test --follow-exec \
--out xml --out html --output-dir coverage/integration-tests

.PHONY: clean
clean:
cargo clean
Expand Down
4 changes: 4 additions & 0 deletions coverage/integration-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions coverage/unit-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
Loading