Coverage #10644
Workflow file for this run
This file contains hidden or 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 that PRs will use for diff | |
| push: | |
| branches: | |
| - master | |
| pull_request: | |
| merge_group: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| codecov: | |
| name: Run coverage and upload to codecov | |
| runs-on: ubuntu-22.04 | |
| timeout-minutes: 55 | |
| env: | |
| NIMBLE_COMMIT: 9207e8b2bbdf66b5a4d1020214cff44d2d30df92 # v0.20.1 | |
| CICOV: YES | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Nim | |
| uses: "./.github/actions/install_nim" | |
| with: | |
| os: linux | |
| cpu: amd64 | |
| shell: bash | |
| nim_ref: v2.2.10 | |
| - name: Restore deps from cache | |
| id: deps-cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: | | |
| nimbledeps | |
| tests/nimbledeps | |
| # Keep this in sync with ci.yml's cache key so entries are | |
| # reusable. See ci.yml for the rationale on os/cpu/cc scoping. | |
| key: nimbledeps-linux-amd64-gcc-${{ hashFiles('.pinned', 'tests/.pinned') }} | |
| - name: Install deps | |
| if: ${{ steps.deps-cache.outputs.cache-hit != 'true' }} | |
| run: | | |
| nimble install_pinned | |
| cd tests && nimble install_pinned | |
| - name: Build prerequisites | |
| run: make nimble.paths tests/nimble.paths | |
| - name: Build prerequisites | |
| run: make nimble.paths | |
| - name: Restore build cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: nimcache | |
| key: ${{ github.ref_name }}-nimcache-coverage-linux-amd64-gcc-2.2.10 | |
| restore-keys: | | |
| master-nimcache-coverage-linux-amd64-gcc-2.2.10 | |
| - name: Setup coverage | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y lcov build-essential git curl | |
| mkdir coverage | |
| - name: Build test_all | |
| run: | | |
| NIMFLAGS="--nimcache:nimcache/test_all --lineDir:on --passC:-fprofile-arcs --passC:-ftest-coverage --passL:-fprofile-arcs --passL:-ftest-coverage --threads:on --skipUserCfg" | |
| nim c $NIMFLAGS ./tests/test_all | |
| - name: Run tests | |
| run: | | |
| ./tests/test_all | |
| - name: Run coverage | |
| run: | | |
| find nimcache -name *.c -delete | |
| lcov --capture --directory nimcache --output-file coverage/coverage.info | |
| lcov --extract coverage/coverage.info "${PWD}/libp2p/*" --output-file coverage/coverage.f.info | |
| genhtml coverage/coverage.f.info --ignore-errors source --output-directory coverage/output | |
| - name: Upload coverage to codecov | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| files: coverage/coverage.f.info | |
| fail_ci_if_error: true | |
| token: ${{ secrets.CODECOV_TOKEN }} |