Skip to content

Commit

Permalink
new coverage.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
salty-ivy committed May 7, 2024
1 parent 2134600 commit 2c071b7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 32 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# .github/workflows/coverage.yml
name: Post coverage comment

on:
workflow_run:
workflows: ["Tests"]
types:
- completed

jobs:
test:
name: Run tests & display coverage
runs-on: ubuntu-latest
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
permissions:
# Gives the action the necessary permissions for publishing new
# comments in pull requests.
pull-requests: write
# Gives the action the necessary permissions for editing existing
# comments (to avoid publishing multiple comments in the same PR)
contents: write
# Gives the action the necessary permissions for looking up the
# workflow that launched this workflow, and download the related
# artifact that contains the comment to be published
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 }}
32 changes: 0 additions & 32 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,38 +198,6 @@ jobs:
name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-sqlite
path: ".coverage.*"

coverage:
name: Check coverage.
runs-on: "ubuntu-latest"
needs: [sqlite, mysql, postgres]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
# Use latest, so it understands all syntax.
python-version: "3.11"

- run: python -m pip install --upgrade coverage[toml]

- name: Download coverage data.
uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true

- name: Combine coverage & check percentage
run: |
python -m coverage combine
python -m coverage html
python -m coverage report
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@v4
with:
name: html-report
path: htmlcov
if: ${{ failure() }}

lint:
runs-on: ubuntu-latest
strategy:
Expand Down

0 comments on commit 2c071b7

Please sign in to comment.