Skip to content

Commit

Permalink
Code coverage comment configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Jul 21, 2024
1 parent 4e8e69c commit 014d32b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This is a follow up job that runs after the CI job has completed.
# It'll post a code coverage comment on pull requests.
name: Post Coverage Comment

on:
workflow_run:
workflows: ["Continuous Integration"]
types:
- completed

jobs:
test:
name: Post Coverage Comment
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
pull-requests: write
contents: write
actions: read
steps:
# !!! DO NOT run actions/checkout here, for security reasons !!!
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
- name: Post comment
uses: py-cov-action/python-coverage-comment-action@v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}
26 changes: 22 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
name: Test
name: Continuous Integration

on:
pull_request:
push:
branches:
- "main"

on: [push, pull_request]
env:
PYTEST_ADDOPTS: "--color=yes"

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Rye Python Setup
Expand All @@ -21,11 +29,21 @@ jobs:
make test
- name: Attach Code Coverage
uses: py-cov-action/[email protected]
with:
GITHUB_TOKEN: ${{ github.token }}

- name: Save Snapshot Report
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: snapshot-report-posting
path: snapshot_report.html
# TODO - fix file system ordering, see latest snapshot report

- name: Store Pull Request Comment
uses: actions/upload-artifact@v4
if: steps.coverage_comment.outputs.COMMENT_FILE_WRITTEN == 'true'
with:
# If you use a different name, update COMMENT_ARTIFACT_NAME accordingly
name: python-coverage-comment-action
# If you use a different name, update COMMENT_FILENAME accordingly
path: python-coverage-comment-action.txt

0 comments on commit 014d32b

Please sign in to comment.