| 1 |
name: Post coverage comment |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_call: |
| 5 |
inputs: |
| 6 |
# this is the workflow run ID of the `CI.yml` workflow |
| 7 |
workflow_run_id: |
| 8 |
required: true |
| 9 |
type: string |
| 10 |
jobs: |
| 11 |
test: |
| 12 |
name: "Display code coverage" |
| 13 |
runs-on: ubuntu-latest |
| 14 |
permissions: |
| 15 |
pull-requests: write |
| 16 |
contents: write # needed to edit the comment vs opening multiple ones |
| 17 |
actions: read |
| 18 |
steps: |
| 19 |
- name: "Get the triggering workflow run details" |
| 20 |
id: get-run |
| 21 |
uses: octokit/request-action@b91aabaa861c777dcdb14e2387e30eddf04619ae |
| 22 |
with: |
| 23 |
route: GET /repos/"${REPO}"/actions/runs/"${WORKFLOW_RUN_ID}" |
| 24 |
env: |
| 25 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 |
REPO: ${{ github.repository }} |
| 27 |
WORKFLOW_RUN_ID: ${{ inputs.workflow_run_id }} |
| 28 |
|
| 29 |
# this needs the .coverage file so we download from the CI workflow artifacts |
| 30 |
- name: "Download coverage data 📥" |
| 31 |
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c |
| 32 |
with: |
| 33 |
pattern: coverage-data-* |
| 34 |
merge-multiple: true |
| 35 |
github-token: ${{ secrets.GITHUB_TOKEN }} |
| 36 |
run-id: ${{ inputs.workflow_run_id }} |
| 37 |
|
| 38 |
- name: "Check downloaded files" |
| 39 |
run: ls -R |
| 40 |
|
| 41 |
- name: "Post coverage comment 💬" |
| 42 |
uses: py-cov-action/python-coverage-comment-action@7188638f871f721a365d644f505d1ff3df20d683 # 3.38.0 |
| 43 |
with: |
| 44 |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 |
GITHUB_PR_RUN_ID: ${{ inputs.workflow_run_id }} |