Skip to content

Commit

Permalink
Remove branch coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
lumisce committed May 1, 2021
1 parent 806c98c commit f86891a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 4 additions & 5 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,10 @@ jobs:
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }}
- name: Generate test result and coverage report
run: |
cargo install cargo2junit grcov rust-covfix;
cargo test --features coverage $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
cargo install cargo2junit grcov;
cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`;
grcov ccov.zip -s . -t lcov --llvm --branch --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info;
rust-covfix -o lcov_correct.info lcov.info;
grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info;
- name: Upload test results
uses: EnricoMi/publish-unit-test-result-action@v1
with:
Expand All @@ -53,5 +52,5 @@ jobs:
with:
# required for private repositories:
# token: ${{ secrets.CODECOV_TOKEN }}
files: ./lcov_correct.info
files: ./lcov.info
fail_ci_if_error: true
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,20 @@ Steps:
- Cache is stored at the end of the job on cache miss. Cache is not updated on cache hit.

2. Generate test results and code coverage data.
1. It installs [cargo2junit](https://github.com/johnterickson/cargo2junit) needed for formatting the test result and [grcov](https://github.com/mozilla/grcov) and [rust-covfix](https://github.com/Kogia-sima/rust-covfix) for code coverage.
1. It installs [cargo2junit](https://github.com/johnterickson/cargo2junit) needed for formatting the test result and [grcov](https://github.com/mozilla/grcov) for code coverage.
3. It runs `cargo test` in the nightly toolchain.
- `--features coverage` adds a `rust-covfix` feature that allows disabling inlining functions for code coverage. [Learn more.](https://github.com/Kogia-sima/rust-covfix#1-avoid-inlining-the-functions-optional)
- `$CARGO_OPTIONS` includes `CARGO_INCREMENTAL`, `RUSTFLAGS`, and `RUSTDOCFLAGS` options needed for code coverage.
- `-Z unstable-options --format json` formats the test result into json.
- ` | cargo2junit > results.xml` converts the json result into junit format for `EnricoMi/publish-unit-test-result-action` to understand and saves it as `results.xml`.
4. It generates code coverage data in lcov format through `grcov` saved as `lcov.info`.
5. It runs `rust-covfix` to fix incorrect Rust coverage data and saves the corrected data as `lcov_correct.info`.

3. Upload test results.
It uploads the test result (`results.xml`) through [EnricoMi/publish-unit-test-result-action@v1](https://github.com/EnricoMi/publish-unit-test-result-action).
- The action outputs the test result (**Test Results** added to a random workflow).
- For pull requests, the action adds a comment containing the test results.

4. Upload to CodeCov.
It uploads the code coverage result (`lcov_correct.info`) to CodeCov through [codecov/codecov-action@v1](https://github.com/codecov/codecov-action).
It uploads the code coverage result (`lcov.info`) to CodeCov through [codecov/codecov-action@v1](https://github.com/codecov/codecov-action).
- For pull requests, the actions adds a comment containing the code coverage report.
- For private repositories, add your token from CodeCov repository setting on GitHub Secrets and uncomment the line: `token: ${{ secrets.CODECOV_TOKEN }}`.

Expand Down

0 comments on commit f86891a

Please sign in to comment.