Skip to content

Commit

Permalink
Ci Update: Use v2 runners and grcov (frequency-chain#1794)
Browse files Browse the repository at this point in the history
# Goal
The goal of this PR is to get Code Coverage results reporting using the
internal runners (faster, and more consistent results).

Result:
https://app.codecov.io/gh/LibertyDSNP/frequency/tree/ci-update%2Fcode-cov-grcov/

# Discussion
- grcov reads the results a bit different than llvm-cov, but llvm cov
was always running out of memory
- Lots of exclusions to get better results, but most of them are the
same as from llvm-cov
  • Loading branch information
wilwade authored Dec 5, 2023
1 parent c4258d1 commit bd32d04
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
57 changes: 48 additions & 9 deletions .github/workflows/common/codecov/action.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,59 @@
name: Run Generation of Code Coverage
description: Runs cargo llvm-cov
description: Runs cargo grcov
inputs:
code-cov-token:
description: "codecov token"
required: true
runs:
using: "composite"
steps:
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Install grcov
shell: bash
run: cargo +nightly-2023-07-13 install grcov
- name: Build
shell: bash # Limited to 12 threads max
run: cargo +nightly-2023-07-13 build -j 12 --features frequency-lint-check
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort"
- name: Test
shell: bash # Limited to 12 threads max
run: cargo +nightly-2023-07-13 test -j 12 --features frequency-lint-check
env:
CARGO_INCREMENTAL: '0'
RUSTFLAGS: "-Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort"
RUSTDOCFLAGS: "-Cpanic=abort"
# There are a lot of things ignored here to make it all work
# See the grcov docs for more information
# excl rpc traits, and error enums
# Only one of excl start and stop are allowed.
- name: Generate code coverage
shell: bash
run: |
cargo llvm-cov -v --no-fail-fast --workspace --lcov --output-path lcov.info \
--ignore-filename-regex "^.*\/(node\/|runtime\/|mock\.rs|weights(\.rs)?|benchmarking\.rs|runtime-api/src/lib\.rs).*$" \
--exclude "frequency,frequency-cli,frequency-runtime,frequency-service" \
--features frequency-lint-check
grcov . -s . --binary-path ./target/debug/ -t lcov \
--ignore-not-existing \
--excl-start '(pub enum Error<T> \{|#\[rpc\()' \
--excl-stop '\s*}$' \
--ignore "target/*" \
--ignore "node/*" \
--ignore "runtime/*" \
--ignore "**/*weights.rs" \
--ignore "**/benchmark*.rs" \
--ignore "**/*tests.rs" \
--ignore "**/tests/*.rs" \
--ignore "**/*mock.rs" \
--ignore "**/*runtime-api/src/lib.rs" \
--ignore "*github.com*" \
--ignore "*libcore*" \
--ignore "*rustc*" \
--ignore "*liballoc*" \
--ignore "*cargo*" \
-o ./target/debug/lcov.info
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4.0.0-beta.3
with:
files: lcov.info
token: ${{inputs.code-cov-token}}
files: ./target/debug/lcov.info
fail_ci_if_error: false # optional (default = false)
verbose: true # optional (default = false)
6 changes: 3 additions & 3 deletions .github/workflows/merge-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ jobs:

calc-code-coverage:
name: Merge - Calculate Code Coverage
# This job currently fails on EKS runners and must be run on standalone until
# https://www.pivotaltracker.com/story/show/185045668 is resolved.
runs-on: [self-hosted, Linux, X64, build, v1]
runs-on: [self-hosted, Linux, X64, build, v2]
container: ghcr.io/libertydsnp/frequency/ci-base-image:1.0.0
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Generate and Upload Code Coverage
id: codecov
uses: ./.github/workflows/common/codecov
with:
code-cov-token: ${{ secrets.CODECOV_TOKEN }}

publish-ci-base-image:
needs: changes
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/verify-pr-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,16 +263,16 @@ jobs:
needs: changes
if: needs.changes.outputs.rust == 'true'
name: Calculate Code Coverage
# This job currently fails on EKS runners and must be run on standalone until
# https://www.pivotaltracker.com/story/show/185045668 is resolved.
runs-on: [self-hosted, Linux, X64, build, v1]
runs-on: [self-hosted, Linux, X64, build, v2]
container: ghcr.io/libertydsnp/frequency/ci-base-image:1.0.0
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Generate and Upload Code Coverage
id: codecov
uses: ./.github/workflows/common/codecov
with:
code-cov-token: ${{ secrets.CODECOV_TOKEN }}

# Workaround to handle skipped required check inside matrix
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks
Expand Down

0 comments on commit bd32d04

Please sign in to comment.