Skip to content

Initial Test Scaffolding #4

Initial Test Scaffolding

Initial Test Scaffolding #4

Workflow file for this run

name: Code Coverage
on:
pull_request:
push:
branches:
- master
jobs:
build-and-test:
runs-on: ubuntu-latest
env:
RUSTFLAGS: -C opt-level=3 -D warnings -C instrument-coverage
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: Setup grcov
env:
GRCOV_VERSION: 0.8.18
run: |
wget https://github.com/mozilla/grcov/releases/download/v${GRCOV_VERSION}/grcov-x86_64-unknown-linux-gnu.tar.bz2
tar xvf grcov-x86_64-unknown-linux-gnu.tar.bz2
chmod +x grcov
- name: Build and Test
run: |
# Temp step to install deps
apt-get update && apt-get install --assume-yes apt-utils --no-install-recommends pkg-config libssl-dev libsasl2-dev llvm-dev libclang-6.0-dev clang-6.0
cargo build --release --all
# - name: Clean-up possible coverage generated during builds
# run: |
# rm default_*.profraw
- name: Run tests
run: |
cargo test
- name: Run E2E tests
run: |
yarn
yarn dev:start
cd e2e-tests
yarn build
yarn test
- name: Retrieve coverage
id: coverage
run: |
mkdir -p /tmp/profiles
find . -name \*.profraw -exec mv {} /tmp/profiles/ \;
mv /tmp/profiles profiles
du -sh profiles
./grcov profiles/ -s ./ --binary-path ./target/release/ -t html --branch --ignore-not-existing --ignore "target/release/build/*" -o coverage/ --llvm 2>&1 | tee grcov.log
echo "total_percent=$(grep -o '[0-9\.]*%' coverage/html/coverage.json)" >> $GITHUB_ENV
- 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_PERCENT"
env:
TOTAL_PERCENT: ${{ env.total_percent }}
- name: Find Comment
uses: peter-evans/find-comment@v2
id: find-comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Code coverage for this PR is:'
- name: Post coverage to PR
if: github.event_name == 'pull_request'
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Code coverage for this PR is: ${{ env.total_percent }}
reactions: 'eyes'
- name: Stop the era_test_node
id: stop_node
if: always()
run: |
yarn dev:kill