⬆️ Update 👷 GitHub Action codecov/codecov-action to 1e68e06 (#405) #1139
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: Code Coverage | |
on: | |
pull_request: | |
types: [opened, edited, synchronize] | |
push: | |
branches: main | |
jobs: | |
coverage: | |
name: Code Coverage | |
runs-on: ${{matrix.os}}-latest | |
strategy: | |
matrix: | |
os: [ubuntu, windows, macos] | |
permissions: | |
id-token: write | |
checks: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Authenticate GitHub CLI | |
run: echo ${{github.token}} | gh auth login --with-token | |
- name: Setup Rust Toolchain and Tools | |
uses: moonrepo/setup-rust@e013866c4215f77c925f42f60257dec7dd18836e # v1 | |
with: | |
bins: sccache, grcov, cargo-hack | |
channel: nightly | |
components: llvm-tools-preview | |
cache-target: coverage | |
- name: Setup Shared Cache Directory | |
shell: bash | |
run: | | |
declare path="${HOME}/.cache/sccache" | |
if test "${RUNNER_OS}" = "Windows"; then | |
path=$(cygpath --windows "${path}") | |
fi | |
echo "SCCACHE_DIR=${path}" >> "${GITHUB_ENV}" | |
- name: Restore sccache build artifacts | |
uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 | |
with: | |
restore-keys: ${{runner.os}}-nightly-coverage- | |
key: ${{runner.os}}-nightly-coverage-${{hashFiles('**/Cargo.lock')}} | |
path: ${{env.SCCACHE_DIR}} | |
- name: Run Tests (coverage) | |
run: cargo hack test --profile=coverage --feature-powerset | |
env: | |
LLVM_PROFILE_FILE: target/coverage/outcome-%p-%m.profraw | |
RUSTC_WRAPPER: sccache | |
RUSTDOCFLAGS: >- | |
-C instrument-coverage | |
-Zunstable-options | |
--persist-doctests ${{github.workspace}}/target/coverage | |
RUSTFLAGS: -C instrument-coverage | |
- name: Collect Coverage | |
run: >- | |
grcov ${{github.workspace}} | |
--binary-path ${{github.workspace}}/target/coverage | |
--output-path ${{github.workspace}}/coverage.info | |
--output-type lcov | |
--source-dir ${{github.workspace}} | |
--ignore "/*" | |
--ignore "C:/*" | |
--ignore "../*" | |
--ignore-not-existing | |
--branch | |
- name: Check coverage.info exists | |
run: test -f ${{github.workspace}}/coverage.info | |
- name: Upload Code Coverage | |
uses: codecov/codecov-action@1e68e06f1dbfde0e4cefc87efeba9e4643565303 # v5 | |
with: | |
fail_ci_if_error: true | |
use_oidc: true | |
directory: ${{github.workspace}} | |
files: coverage.info | |
- name: Upload Code Coverage Artifact | |
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4 | |
with: | |
name: ${{matrix.os}}-coverage.info | |
path: coverage.info | |
if-no-files-found: error |