Skip to content

Commit c1463a5

Browse files
authored
New coverage.yml for code coverage (#1912)
* new coverage.yml * match the job name * remove upload code coverage config
1 parent 2134600 commit c1463a5

File tree

2 files changed

+33
-49
lines changed

2 files changed

+33
-49
lines changed

.github/workflows/coverage.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# .github/workflows/coverage.yml
2+
name: Post coverage comment
3+
4+
on:
5+
workflow_run:
6+
workflows: ["Test"]
7+
types:
8+
- completed
9+
10+
jobs:
11+
test:
12+
name: Run tests & display coverage
13+
runs-on: ubuntu-latest
14+
if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success'
15+
permissions:
16+
# Gives the action the necessary permissions for publishing new
17+
# comments in pull requests.
18+
pull-requests: write
19+
# Gives the action the necessary permissions for editing existing
20+
# comments (to avoid publishing multiple comments in the same PR)
21+
contents: write
22+
# Gives the action the necessary permissions for looking up the
23+
# workflow that launched this workflow, and download the related
24+
# artifact that contains the comment to be published
25+
actions: read
26+
steps:
27+
# DO NOT run actions/checkout here, for security reasons
28+
# For details, refer to https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
29+
- name: Post comment
30+
uses: py-cov-action/python-coverage-comment-action@v3
31+
with:
32+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
33+
GITHUB_PR_RUN_ID: ${{ github.event.workflow_run.id }}

.github/workflows/test.yml

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,6 @@ jobs:
6666
DB_HOST: 127.0.0.1
6767
DB_PORT: 3306
6868

69-
- name: Upload coverage data
70-
uses: actions/upload-artifact@v4
71-
with:
72-
name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-mysql
73-
path: ".coverage.*"
7469

7570
postgres:
7671
runs-on: ubuntu-latest
@@ -144,12 +139,6 @@ jobs:
144139
DB_HOST: localhost
145140
DB_PORT: 5432
146141

147-
- name: Upload coverage data
148-
uses: actions/upload-artifact@v4
149-
with:
150-
name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.database }}
151-
path: ".coverage.*"
152-
153142
sqlite:
154143
runs-on: ubuntu-latest
155144
strategy:
@@ -192,44 +181,6 @@ jobs:
192181
DB_BACKEND: sqlite3
193182
DB_NAME: ":memory:"
194183

195-
- name: Upload coverage data
196-
uses: actions/upload-artifact@v4
197-
with:
198-
name: coverage-data-${{ matrix.python-version }}-${{ matrix.os }}-${{ matrix.arch }}-sqlite
199-
path: ".coverage.*"
200-
201-
coverage:
202-
name: Check coverage.
203-
runs-on: "ubuntu-latest"
204-
needs: [sqlite, mysql, postgres]
205-
steps:
206-
- uses: actions/checkout@v4
207-
- uses: actions/setup-python@v5
208-
with:
209-
# Use latest, so it understands all syntax.
210-
python-version: "3.11"
211-
212-
- run: python -m pip install --upgrade coverage[toml]
213-
214-
- name: Download coverage data.
215-
uses: actions/download-artifact@v4
216-
with:
217-
pattern: coverage-data-*
218-
merge-multiple: true
219-
220-
- name: Combine coverage & check percentage
221-
run: |
222-
python -m coverage combine
223-
python -m coverage html
224-
python -m coverage report
225-
226-
- name: Upload HTML report if check failed.
227-
uses: actions/upload-artifact@v4
228-
with:
229-
name: html-report
230-
path: htmlcov
231-
if: ${{ failure() }}
232-
233184
lint:
234185
runs-on: ubuntu-latest
235186
strategy:

0 commit comments

Comments
 (0)