Skip to content

Commit

Permalink
Move coverage CI action to manual trigger (#1465)
Browse files Browse the repository at this point in the history
  • Loading branch information
anorth authored Oct 25, 2023
1 parent b2721f8 commit 1d0b348
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 42 deletions.
42 changes: 0 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,45 +50,3 @@ jobs:
BUILD_FIL_NETWORK: ${{ matrix.network }}
run: |
cargo run --locked -- -o output/builtin-actors.car
coverage:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checking out
uses: actions/checkout@v3
- name: Put LLVM tools into the PATH
run: echo "$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin" >> $GITHUB_PATH
- name: Install demangler
run: sudo apt-get install -y rustfilt
- name: Create coverage report
env:
# Make sure that each run of an executable creates a new profile file,
# with the default name they would override each other.
LLVM_PROFILE_FILE: "%m.profraw"
RUSTFLAGS: "-Cinstrument-coverage"
run: cargo test --workspace --exclude fil_builtin_actors_bundle
- name: Merge profiling data
# Do *not* use sparse output. It leads to more lines that are not taken
# into account at all
run: llvm-profdata merge --output=default.profdata $(find . -name '*.profraw')
- name: Create HTML coverage report
# The compiled files contain the coverage information. From running the
# tests we don't know what those files are called, hence use all files
# from the `./target/debug/deps` directory which don't have an extension.
run: |
OBJECT_OPTIONS=($(find ./target/debug/deps/* -name '*' -not -name '*\.*' -printf ' --object %p'))
# Create HTML report of this project, we don't care about coverage of
# dependencies
llvm-cov show --Xdemangler=rustfilt --show-expansions --show-line-counts-or-regions --ignore-filename-regex=".cargo|.rustup|/rustc|./tests/" --format=html --output-dir=./llvm-show --instr-profile=default.profdata ${OBJECT_OPTIONS[@]}
# Create file to be uploaded to codecov
llvm-cov export --ignore-filename-regex=".cargo|.rustup|/rustc|./tests" --format=lcov --instr-profile=default.profdata ${OBJECT_OPTIONS[@]} > lcov.info
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: llvm-show/*
- name: Upload coverage to Codecov
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
files: lcov.info
51 changes: 51 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Continuous integration

on: workflow_dispatch

env:
RUSTFLAGS: -Dwarnings
CARGO_INCREMENTAL: 0 # Speeds up the build (no cache) and reduces disk space!

jobs:
coverage:
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checking out
uses: actions/checkout@v3
- name: Put LLVM tools into the PATH
run: echo "$(rustc --print sysroot)/lib/rustlib/x86_64-unknown-linux-gnu/bin" >> $GITHUB_PATH
- name: Install demangler
run: sudo apt-get install -y rustfilt
- name: Create coverage report
env:
# Make sure that each run of an executable creates a new profile file,
# with the default name they would override each other.
LLVM_PROFILE_FILE: "%m.profraw"
RUSTFLAGS: "-Cinstrument-coverage"
run: cargo test --workspace --exclude fil_builtin_actors_bundle
- name: Merge profiling data
# Do *not* use sparse output. It leads to more lines that are not taken
# into account at all
run: llvm-profdata merge --output=default.profdata $(find . -name '*.profraw')
- name: Create HTML coverage report
# The compiled files contain the coverage information. From running the
# tests we don't know what those files are called, hence use all files
# from the `./target/debug/deps` directory which don't have an extension.
run: |
OBJECT_OPTIONS=($(find ./target/debug/deps/* -name '*' -not -name '*\.*' -printf ' --object %p'))
# Create HTML report of this project, we don't care about coverage of
# dependencies
llvm-cov show --Xdemangler=rustfilt --show-expansions --show-line-counts-or-regions --ignore-filename-regex=".cargo|.rustup|/rustc|./tests/" --format=html --output-dir=./llvm-show --instr-profile=default.profdata ${OBJECT_OPTIONS[@]}
# Create file to be uploaded to codecov
llvm-cov export --ignore-filename-regex=".cargo|.rustup|/rustc|./tests" --format=lcov --instr-profile=default.profdata ${OBJECT_OPTIONS[@]} > lcov.info
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: llvm-show/*
- name: Upload coverage to Codecov
uses: codecov/codecov-action@d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70 # v3.1.1
with:
files: lcov.info

0 comments on commit 1d0b348

Please sign in to comment.