Skip to content

Publish Code Coverage Results #779

Publish Code Coverage Results

Publish Code Coverage Results #779

name: Publish Code Coverage Results
on:
workflow_run:
workflows: ["Receive Pull Request"]
types:
- completed
jobs:
publish-test-results:
name: Publish Code Coverage Results
runs-on: ubuntu-latest
# the build-and-test job might be skipped, we don't need to run this job then
if: >
${{ github.event.workflow_run.event == 'pull_request' &&
( github.event.workflow_run.conclusion == 'success' ||
github.event.workflow_run.conclusion == 'failure' ) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: 'Download artifact'
uses: actions/download-artifact@v4
with:
name: coverage-reports
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Set Coverage Report Paths
id: coverage-paths
run: |
readarray -d '' coveragePathArray < <(find . -name "coverage.cobertura.xml" -print0)
coveragePaths=$(printf -- "-r %s " "${coveragePathArray[@]}")
echo "COVERAGE_REPORT_PATHS=$coveragePaths" >> $GITHUB_OUTPUT
- name: Publish Code Coverage Results
run: |
auth="--project-token ${{ secrets.CODACY_PROJECT_TOKEN }}"
bash <(curl -Ls https://coverage.codacy.com/get.sh) report $auth \
--commit-uuid ${{ github.event.workflow_run.head_sha }} \
${{ steps.coverage-paths.outputs.COVERAGE_REPORT_PATHS }} --partial &&\
bash <(curl -Ls https://coverage.codacy.com/get.sh) final $auth