Skip to content

Commit 3a4ccfe

Browse files
committed
Run coverage separately
1 parent 33ce8ab commit 3a4ccfe

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,23 @@ jobs:
150150
# - name: "Pylint Tests"
151151
# run: "poetry run pylint infrahub_sdk/"
152152
- name: "Unit Tests"
153-
run: "poetry run pytest tests/unit/"
153+
run: "poetry run pytest --cov infrahub_sdk tests/unit/"
154154
- name: "Upload coverage to Codecov"
155155
run: |
156156
codecov --flags python-${{ matrix.python-version }}
157157
env:
158158
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
159+
160+
# The pytest-cov plugin doesn't quite work with content that is
161+
# auto-imported by our own infrahub pytest plugin, this workaround
162+
# reports the missing lines
163+
- name: "Report coverage for pytest-plugin"
164+
if: matrix.python-version == '3.12'
165+
run: |
166+
source $(poetry env info --path)/bin/activate
167+
coverage run -m pytest tests/unit/pytest_plugin
168+
coverage report -m
169+
coverage xml
170+
codecov --flags python-filler-${{ matrix.python-version }}
171+
env:
172+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ filterwarnings = [
144144
"ignore:Module already imported so cannot be rewritten",
145145
"ignore:Deprecated call to",
146146
]
147-
addopts = "-vs --cov infrahub_sdk --cov-report term-missing --cov-report xml --dist loadscope"
147+
addopts = "-vs --cov-report term-missing --cov-report xml --dist loadscope"
148148

149149
[tool.mypy]
150150
pretty = true

0 commit comments

Comments
 (0)