Initial Test Scaffolding #8
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
name: Code Coverage | |
on: | |
pull_request: | |
push: | |
branches: | |
- master | |
jobs: | |
build-and-test-with-coverage: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
- name: Install llvm tools | |
run: rustup component add llvm-tools-preview | |
- 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: Prepare for coverage | |
run: | | |
cargo llvm-cov clean --workspace | |
- name: Run tests with Coverage | |
run: | | |
# Run Unit Tests | |
cargo llvm-cov nextest --no-report --all | |
# Room for other test suites types to run here... | |
## Launch Node /w coverage - uncomment when E2E tests ready | |
# cargo llvm-cov run --no-report -- run > era_test_node_output.log 2>&1 & | |
# cd e2e-tests | |
# yarn install | |
# yarn build | |
# yarn test | |
- name: Generate Coverage Report | |
run: | | |
echo "TOTAL_COV=${cargo llvm-cov report --summary-only | grep 'TOTAL' | awk '{print $4}' }" >> $GITHUB_ENV | |
cargo llvm-cov report --html | |
- name: Upload coverage to GitHub Actions | |
uses: actions/[email protected] | |
with: | |
name: coverage | |
path: coverage | |
- name: Post coverage to PR | |
if: github.event_name == 'pull_request' | |
run: | | |
echo "Code coverage for this PR is: $TOTAL_COV" | |
- name: Find Comment | |
uses: peter-evans/find-comment@v2 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
body-includes: Coverage generated | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
Code coverage for this PR is: ${{ env.TOTAL_COV }} | |
edit-mode: replace | |
reactions: "eyes" | |
- name: Zip and Upload Coverage Report | |
uses: actions/[email protected] | |
with: | |
name: coverage-report | |
path: target/llvm-cov/html | |
- name: Stop the era_test_node | |
id: stop_node | |
if: always() | |
run: | | |
yarn dev:kill |