Skip to content

Commit 01c9265

Browse files
authored
CI: Add coverage diff reporting (#9)
2 parents 24d0b73 + bfafb9c commit 01c9265

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

.github/workflows/pytest.yml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
name: Pytest
22

33
on:
4-
- push
5-
- pull_request
4+
pull_request:
5+
push:
6+
branches:
7+
- "main"
68

79
jobs:
810
pytest:
911
runs-on: ubuntu-latest
12+
permissions:
13+
# Gives the action the necessary permissions for publishing new
14+
# comments in pull requests.
15+
pull-requests: write
16+
# Gives the action the necessary permissions for pushing data to the
17+
# python-coverage-comment-action branch, and for editing existing
18+
# comments (to avoid publishing multiple comments in the same PR)
19+
contents: write
1020
steps:
1121
- name: Check out code
1222
uses: actions/checkout@v3
@@ -28,8 +38,9 @@ jobs:
2838
- name: Run tests
2939
run: ./tests/run.sh
3040

31-
- name: Upload coverage report
32-
uses: actions/upload-artifact@v3
41+
- name: Coverage comment
42+
uses: py-cov-action/python-coverage-comment-action@v3
3343
with:
34-
name: coverage-report
35-
path: ./tests/coverage
44+
GITHUB_TOKEN: ${{ github.token }}
45+
MINIMUM_GREEN: 90
46+
MINIMUM_ORANGE: 80

pyproject.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ keywords = ["gam", "google"]
99
authors = [
1010
{ name = "Compiler LLC", email = "[email protected]" }
1111
]
12-
requires-python = ">=3.9"
12+
requires-python = ">=3.11"
1313
dependencies = [
1414
"advanced-gam-for-google-workspace @ git+https://github.com/taers232c/[email protected]#subdirectory=src"
1515
]
@@ -26,8 +26,8 @@ dev = [
2626
"pre-commit"
2727
]
2828
test = [
29+
"coverage",
2930
"pytest",
30-
"pytest-cov",
3131
"pytest-mock"
3232
]
3333

@@ -43,6 +43,11 @@ line-length = 127
4343
target-version = ['py311']
4444
include = '\.pyi?$'
4545

46+
[tool.coverage.run]
47+
branch = true
48+
relative_files = true
49+
source = ["compiler_admin"]
50+
4651
[tool.pyright]
4752
include = ["compiler_admin", "tests"]
4853

tests/run.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -eu
33

44
# run normal pytests, skip e2e tests
5-
pytest -m "not e2e" --cov=compiler_admin --cov-branch --import-mode=importlib
5+
coverage run -m pytest -m "not e2e"
66

77
# clean out old coverage results
88
rm -rf ./tests/coverage

tests/web.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env bash
2+
set -eu
3+
4+
python -m http.server -d ./tests/coverage

0 commit comments

Comments
 (0)