Skip to content

Commit

Permalink
Fix coverage comment from forks (cfug#2193)
Browse files Browse the repository at this point in the history
When the coverage_comment workflow is triggered from a PR that
originates from a fork, then the workflow event does not contain the PR
number. But we need the PR number to attach the sticky coverage comment.
So workaround this by storing the PR number in the workflow artifact
that also contains the coverage result.
  • Loading branch information
kuhnroyal authored Apr 20, 2024
1 parent 5e724de commit a31f8d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/coverage_comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@ jobs:
workflow: tests.yml
workflow_conclusion: success
run_id: ${{ github.event.workflow_run.id }}
name: code-coverage-results.md
name: code-coverage-results
- name: Determine PR number
id: pr-number
run: |
PR_NUMBER=$(cat pr_number.txt)
echo "Found PR:$PR_NUMBER"
echo "value=$PR_NUMBER" >> $GITHUB_OUTPUT
- name: Add PR comment
uses: marocchino/sticky-pull-request-comment@v2
with:
number: ${{ github.event.workflow_run.pull_requests[0].number }}
number: ${{ steps.pr-number.outputs.value }}
recreate: true
path: code-coverage-results.md
9 changes: 7 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,14 @@ jobs:
with:
artifact_download_workflow_names: 'Verify packages abilities,coverage_baseline'
filename: 'coverage/cobertura.xml'
- name: '[Coverage] Write PR number to file'
if: ${{ matrix.sdk == 'stable' && github.actor != 'dependabot[bot]'}}
run: echo ${{ github.event.number }} > pr_number.txt
- name: '[Coverage] Upload'
if: ${{ matrix.sdk == 'stable' && github.actor != 'dependabot[bot]'}}
uses: actions/upload-artifact@v4
with:
name: code-coverage-results.md
path: code-coverage-results.md
name: code-coverage-results
path: |
code-coverage-results.md
pr_number.txt

0 comments on commit a31f8d7

Please sign in to comment.