Skip to content

Test Coverage

Test Coverage #188

Workflow file for this run

name: Test Coverage
on:
workflow_run:
workflows: ['CI']
types: [completed]
permissions:
actions: read
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test-coverage:
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' && github.event.workflow_run.head_branch == 'master'
steps:
- name: Resolve CI artifact metadata
id: artifact
uses: actions/github-script@v7
with:
script: |
const runId = context.payload.workflow_run.id;
const expectedName = `coverage-${context.payload.workflow_run.head_sha}`;
const artifacts = await github.paginate(github.rest.actions.listWorkflowRunArtifacts, {
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runId,
per_page: 100,
});
const coverageArtifact = artifacts.find((artifact) => artifact.name === expectedName);
if (coverageArtifact === undefined) {
core.setOutput('found', 'false');
core.setOutput('artifact_name', expectedName);
return;
}
core.setOutput('found', 'true');
core.setOutput('artifact_name', coverageArtifact.name);
- name: Skip when CI produced no coverage artifact
if: steps.artifact.outputs.found != 'true'
run: echo "No coverage artifact found for this CI run (likely non-runtime-only change)."
- name: Download coverage artifact from CI run
if: steps.artifact.outputs.found == 'true'
uses: dawidd6/action-download-artifact@v9
with:
run_id: ${{ github.event.workflow_run.id }}
name: ${{ steps.artifact.outputs.artifact_name }}
path: .
- name: Upload coverage reports to Codecov
if: steps.artifact.outputs.found == 'true'
uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4
with:
file: ./coverage/lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
verbose: true