chore: Cleanup CI #10
Workflow file for this run
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: Coverage | |
on: | |
# On push to common branches, this computes the coverage PRs will compared against | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
cancel-in-progress: true | |
jobs: | |
codecov: | |
# Improvement: Split single job into run tests, generate coverage, and upload to codecov. | |
name: Run coverage and upload to codecov | |
runs-on: ubuntu-20.04 | |
env: | |
CICOV: YES | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Nim | |
uses: "./.github/actions/install_nim" | |
with: | |
os: linux | |
cpu: amd64 | |
shell: bash | |
- name: Restore deps from cache | |
id: deps-cache | |
uses: actions/cache@v4 | |
with: | |
path: nimbledeps | |
key: nimbledeps-${{ hashFiles('.pinned') }} | |
- name: Install deps | |
if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }} | |
run: | | |
nimble install_pinned | |
- name: Install coverage tools and setup | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y lcov build-essential git curl | |
mkdir coverage | |
- name: Run coverage-enabled test suite | |
run: | | |
export NIMFLAGS="--lineDir:on --passC:-fprofile-arcs --passC:-ftest-coverage --passL:-fprofile-arcs --passL:-ftest-coverage" | |
nimble testnative | |
nimble testpubsub | |
nimble testfilter | |
- name: Run coverage | |
run: | | |
find nimcache -name *.c -delete | |
lcov --capture --directory nimcache --output-file coverage/coverage.info | |
shopt -s globstar | |
ls `pwd`/libp2p/{*,**/*}.nim | |
lcov --extract coverage/coverage.info `pwd`/libp2p/{*,**/*}.nim --output-file coverage/coverage.f.info | |
genhtml coverage/coverage.f.info --output-directory coverage/output | |
- name: Upload coverage to codecov | |
run: | | |
bash <(curl -s https://codecov.io/bash) -f coverage/coverage.f.info || echo "Codecov did not collect coverage reports" | |
# Alternatively, use the upload artifact action | |
# - uses: actions/upload-artifact@master | |
# with: | |
# name: coverage | |
# path: coverage |