-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] update test coverage section, put up an example in CI
- Loading branch information
1 parent
a46682f
commit 803c75f
Showing
5 changed files
with
70 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
on: | ||
push: | ||
branches: [ main, auto, canary ] | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
name: Test coverage | ||
|
||
jobs: | ||
coverage: | ||
name: Collect test coverage | ||
runs-on: ubuntu-latest | ||
# nightly rust might break from time to time | ||
continue-on-error: true | ||
env: | ||
RUSTFLAGS: -D warnings | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
# By default actions/checkout checks out a merge commit. Check out the PR head instead. | ||
# https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit | ||
ref: ${{ github.event.pull_request.head.sha }} | ||
- uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: nightly | ||
override: true | ||
components: llvm-tools-preview | ||
- uses: Swatinem/rust-cache@c5ed9ba6b7e1bb8aff90d43acd2f0af4990fa57c | ||
|
||
- name: Install latest nextest release | ||
uses: taiki-e/install-action@nextest | ||
- name: Install cargo-llvm-cov | ||
uses: taiki-e/install-action@cargo-llvm-cov | ||
|
||
- name: Collect coverage data | ||
run: cargo llvm-cov nextest | ||
# TODO: generate HTML report and upload it | ||
# (requires https://github.com/taiki-e/cargo-llvm-cov/pull/144#issuecomment-1072736931 to be addressed) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Test coverage | ||
|
||
Test coverage support is provided by third-party tools that wrap around nextest. | ||
|
||
## llvm-cov | ||
|
||
[cargo-llvm-cov](https://github.com/taiki-e/cargo-llvm-cov) supports nextest. To generate llvm-cov data with nextest, run: | ||
|
||
``` | ||
cargo install cargo-llvm-cov | ||
cargo llvm-cov nextest | ||
``` | ||
|
||
### Using llvm-cov in GitHub Actions | ||
|
||
Install both nextest and llvm-cov in GitHub Actions, then run `cargo llvm-cov nextest`. | ||
|
||
```yaml | ||
- uses: taiki-e/install-action@cargo-llvm-cov | ||
- uses: taiki-e/install-action@nextest | ||
``` | ||
## Integrating nextest into coverage tools | ||
Most coverage tools work by setting a few environment variables such as `RUSTFLAGS` or `RUSTC_WRAPPER`. Nextest runs Cargo for the build, which will read those environment variables as usual. This means that it should generally be quite straightforward to integrate nextest into other coverage tools. | ||
|
||
> If you've integrated nextest into a coverage tool, feel free to [submit a pull request] with documentation. | ||
|
||
[submit a pull request]: https://github.com/nextest-rs/nextest/pulls |