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: switched to source-based coverage #192

Merged
merged 2 commits into from
Nov 26, 2020
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
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ jobs:
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-
- name: Install llvm-tools
run: |
rustup component add llvm-tools-preview
- name: Download grcov
run: |
curl -L https://github.com/mozilla/grcov/releases/latest/download/grcov-linux-x86_64.tar.bz2 | tar jxf -
Expand All @@ -67,7 +70,7 @@ jobs:
export PATH=$PATH:.
make coverage-lcov COVERAGE_CACHE=1
Copy link
Member Author

@ErikBjare ErikBjare Nov 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johan-bjareholt Why is COVERAGE_CACHE set?

Edit: Nvm, I think I get it.

- name: Upload coverage files
run: bash <(curl -s https://codecov.io/bash);
run: bash <(curl -s https://codecov.io/bash) -f target/debug/lcov.info;

build-android:
name: Build for Android
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/target/
target
**/*.rs.bk
NDK
.cargo/config
*.zip
*.profraw
21 changes: 10 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,27 @@ endif
test:
cargo test


COV_CARGO_INCREMENTAL=0
COV_RUSTFLAGS="-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
COV_RUSTDOCFLAGS="-Cpanic=abort"

test-coverage:
ifndef COVERAGE_CACHE
# We need to remove build files in case a non-coverage test has been run
# before without RUST/CARGO flags needed for coverage
rm -rf target/debug
endif
rm -rf **/*.profraw
# Build and test
CARGO_INCREMENTAL=${COV_CARGO_INCREMENTAL} \
RUSTFLAGS=${COV_RUSTFLAGS} \
RUSTDOCFLAGS=${COV_RUSTDOCFLAGS} \
cargo test --verbose
env RUSTFLAGS="-Zinstrument-coverage" \
LLVM_PROFILE_FILE="grcov-%p-%m.profraw" \
cargo test --verbose

GRCOV_PARAMS=$(shell find . -name "grcov-*.profraw" -print) --binary-path=./target/debug/aw-server -s . --llvm --branch --ignore-not-existing

coverage-html: test-coverage
grcov ./target/debug/ -s . -t html --llvm --branch --ignore-not-existing -o ./target/debug/$@/
grcov ${GRCOV_PARAMS} -t html -o ./target/debug/$@/
rm -rf **/*.profraw

coverage-lcov: test-coverage
grcov ./target/debug/ -s . -t lcov --llvm --branch --ignore-not-existing -o ./target/debug/[email protected]
grcov ${GRCOV_PARAMS} -t lcov -o ./target/debug/lcov.info
rm -rf **/*.profraw

coverage: coverage-html

Expand Down