Skip to content

Commit 58d67b1

Browse files
committed
CI: Add CodeCov test coverage reporting
* Add pytest and pytest-cov to dev dependencies * Switch to relative path to local setup action
1 parent 033901e commit 58d67b1

File tree

4 files changed

+142
-7
lines changed

4 files changed

+142
-7
lines changed

.github/workflows/pytests.yml

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,38 @@ on:
66
- main
77
pull_request:
88

9+
910
jobs:
1011
test:
12+
name: Run tests and collect coverage
1113
runs-on: ubuntu-latest
1214
steps:
13-
- uses: actions/checkout@v4
14-
- uses: gardenlinux/python-gardenlinux-lib/.github/actions/setup@main
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 2
19+
20+
- name: Setup Gardenlinux
21+
uses: ./.github/actions/setup
22+
23+
- name: Install Poetry
24+
uses: snok/install-poetry@v1
25+
26+
- name: Install dependencies
27+
run: poetry install --with dev
28+
29+
- name: Prepare environment
30+
run: make install-test
31+
1532
- name: Run tests
16-
run: |
33+
run: |
1734
export GLOCI_REGISTRY_TOKEN="invalid"
18-
make test
35+
make test-coverage-ci
36+
37+
- name: Check for report
38+
run: test -f coverage.xml
39+
40+
- name: Upload results to Codecov
41+
uses: codecov/codecov-action@v5
42+
with:
43+
token: ${{ secrets.CODECOV_TOKEN }}

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ install-test: install-dev
4646
test: install-test
4747
$(POETRY) run pytest -k "not kms"
4848

49+
test-coverage: install-test
50+
$(POETRY) run pytest -k "not kms" --cov=gardenlinux --cov-report=xml tests/
51+
52+
test-coverage-ci: install-test
53+
$(POETRY) run pytest -k "not kms" --cov=gardenlinux --cov-report=xml --cov-fail-under=50 tests/
54+
4955
test-debug: install-test
5056
$(POETRY) run pytest -k "not kms" -vvv -s
5157

poetry.lock

Lines changed: 105 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pygments = "^2.19.1"
2626
bandit = "^1.8.3"
2727
black = "^25.1.0"
2828
moto = "^5.1.9"
29+
pytest = "^8.4.1"
30+
pytest-cov = "^6.2.1"
2931

3032
[tool.poetry.group.docs.dependencies]
3133
sphinx-rtd-theme = "^3.0.2"

0 commit comments

Comments
 (0)