Skip to content

Commit

Permalink
correctly specify all binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
yaahc authored and dconnolly committed Dec 2, 2020
1 parent a930337 commit f4b1cd2
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 17 deletions.
26 changes: 20 additions & 6 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,43 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2

- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
override: true
profile: minimal
components: llvm-tools-preview

- name: Install rustfilt symbol demangler
run: cargo install rustfilt
run: |
cargo install rustfilt
- name: Rerun tests for coverage
run: cargo test
env:
RUSTFLAGS: -Zinstrument-coverage
RUSTFLAGS: -Zinstrument-coverage -C link-dead-code -C debuginfo=2
LLVM_PROFILE_FILE: "${{ github.workspace }}/test.%p.profraw"
ZEBRA_SKIP_NETWORK_TESTS: 1
run: |
cargo test
cargo test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > filenames.txt
- name: Merge coverage data
run: $(rustc --print target-libdir)/../bin/llvm-profdata merge --sparse test.*.profraw -o test.profdata
run: |
$(rustc --print target-libdir)/../bin/llvm-profdata merge test.*.profraw -o test.profdata
- name: Generate detailed html coverage report for github artifact
run: $(rustc --print target-libdir)/../bin/llvm-cov show -format=html -ignore-filename-regex=".*/.cargo/registry/.*" -ignore-filename-regex=".*/.cargo/git/.*" -ignore-filename-regex=".*/.rustup/.*" -Xdemangler=rustfilt -show-instantiations -output-dir=./coverage -instr-profile=./test.profdata $(find target/debug/deps -type f -perm -u+x ! -name '*.so')
run: |
$(rustc --print target-libdir)/../bin/llvm-cov show -format=html -ignore-filename-regex=".*/.cargo/registry/.*" -ignore-filename-regex=".*/.cargo/git/.*" -ignore-filename-regex=".*/.rustup/.*" -Xdemangler=rustfilt -show-instantiations -output-dir=./coverage -instr-profile=./test.profdata $(printf -- "-object %s " $(cat filenames.txt))
- uses: actions/upload-artifact@v2
with:
name: coverage
path: ./coverage

- name: Generate lcov coverage report for codecov
run: $(rustc --print target-libdir)/../bin/llvm-cov export -format=lcov -instr-profile=test.profdata $(find target/debug/deps -type f -perm -u+x ! -name '*.so') > "lcov.info"
run: |
$(rustc --print target-libdir)/../bin/llvm-cov export -format=lcov -instr-profile=test.profdata $(printf -- "-object %s " $(cat filenames.txt)) > "lcov.info"
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Cargo files
/target/
/coverage-target/
# Firebase caches (?)
.firebase/
# Emacs detritus
Expand Down
28 changes: 17 additions & 11 deletions zebra-utils/coverage
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,28 @@
set -e
set -o xtrace

rm -rf ./target/
mkdir -p ./target/coverage
ZEBRA_SKIP_NETWORK_TESTS=1 LLVM_PROFILE_FILE="${PWD}/target/coverage/test.%p.profraw" RUSTFLAGS="-Zinstrument-coverage" cargo test
$(rustc --print target-libdir)/../bin/llvm-profdata merge --sparse ./target/coverage/test.*.profraw -o ./target/coverage/test.profdata
export CARGO_TARGET_DIR="coverage-target"

rm -rf ./target/coverage/html/
# This one works and shows all the details I want in the CLI
$(rustc --print target-libdir)/../bin/llvm-cov show \
rm -rf ./"$CARGO_TARGET_DIR"/coverage
mkdir -p ./$CARGO_TARGET_DIR/coverage
export ZEBRA_SKIP_NETWORK_TESTS=1
export LLVM_PROFILE_FILE="${PWD}/$CARGO_TARGET_DIR/coverage/test.%m.profraw"
export RUSTFLAGS="-Zinstrument-coverage -C link-dead-code -C debuginfo=2"
cargo +nightly test --no-run --message-format=json | jq -r "select(.profile.test == true) | .filenames[]" | grep -v dSYM - > ./$CARGO_TARGET_DIR/files.txt
cargo +nightly test
$(rustc +nightly --print target-libdir)/../bin/llvm-profdata merge --sparse ./$CARGO_TARGET_DIR/coverage/test.*.profraw -o ./$CARGO_TARGET_DIR/coverage/test.profdata

rm -rf ./$CARGO_TARGET_DIR/coverage/html/

$(rustc +nightly --print target-libdir)/../bin/llvm-cov show \
-format=html \
-Xdemangler=rustfilt \
-show-instantiations \
-output-dir=./target/coverage/html \
-output-dir=./$CARGO_TARGET_DIR/coverage/html \
-ignore-filename-regex=".*/.cargo/registry/.*" \
-ignore-filename-regex=".*/.cargo/git/.*" \
-ignore-filename-regex=".*/.rustup/.*" \
-instr-profile=./target/coverage/test.profdata \
$(find target/ -type f -perm -u+x ! -name '*.so')
-instr-profile=./$CARGO_TARGET_DIR/coverage/test.profdata \
$(printf -- "-object %s " $(cat ./$CARGO_TARGET_DIR/files.txt))

xdg-open ./target/coverage/html/index.html
xdg-open ./$CARGO_TARGET_DIR/coverage/html/index.html

0 comments on commit f4b1cd2

Please sign in to comment.