Skip to content

Commit 50228bd

Browse files
committed
test coverage reporting
1 parent f158d7f commit 50228bd

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

.github/workflows/all_tests_nnpdf.yml

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,14 @@ jobs:
2626
- name: Test n3fit and validphys
2727
shell: bash -l {0}
2828
run: |
29-
pytest --mpl --pyargs validphys n3fit --mpl-default-tolerance 18
29+
pytest --cov=${PWD} --cov-config=pyproject.toml --mpl --pyargs validphys n3fit --mpl-default-tolerance 18
30+
- name: Keep coverage file
31+
if: startsWith(matrix.python-version, '3.12')
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: coverage-package-${{ matrix.os }}
35+
path: .coverage
36+
3037

3138
regression_tests:
3239
runs-on: ubuntu-latest
@@ -36,7 +43,12 @@ jobs:
3643
- name: Run regression tests
3744
shell: bash -l {0}
3845
run: |
39-
pytest extra_tests/regression_checks.py
46+
pytest --cov=${PWD} --cov-config=pyproject.toml extra_tests/regression_checks.py
47+
- name: Keep coverage file
48+
uses: actions/upload-artifact@v4
49+
with:
50+
name: coverage-regression
51+
path: .coverage
4052

4153
conda_tests:
4254
strategy:
@@ -83,3 +95,21 @@ jobs:
8395
run: |
8496
cd n3fit/runcards/examples
8597
n3fit Basic_runcard.yml 4
98+
99+
full_coverage:
100+
runs-on: ubuntu-latest
101+
steps:
102+
- uses: actions/checkout@v4
103+
- uses: actions/setup-python@v5
104+
with:
105+
python-version: "3.12"
106+
- name: Install coverage
107+
run: pip install coverage
108+
- name: Download reports
109+
uses: actions/download-artifact@v4
110+
with:
111+
path: reports
112+
- name: Merge and show
113+
run: |
114+
coverage combine reports/**/.coverage
115+
coverage report

pyproject.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ seaborn = "*"
8484
# tests
8585
pytest = {version = "*", optional = true}
8686
pytest-mpl = {version = "*", optional = true}
87+
pytest-cov = {version = ">=6", optional = true}
8788
hypothesis = {version = "*", optional = true}
8889
# docs
8990
sphinxcontrib-bibtex = {version = "*", optional = true}
@@ -102,7 +103,7 @@ pymongo = {version = "<4", optional = true}
102103

103104
# Optional dependencies
104105
[tool.poetry.extras]
105-
tests = ["pytest", "pytest-mpl", "hypothesis"]
106+
tests = ["pytest", "pytest-mpl", "hypothesis", "pytest-cov"]
106107
docs = ["sphinxcontrib-bibtex", "sphinx-rtd-theme", "sphinx", "tabulate"]
107108
qed = ["fiatlux"]
108109
nolha = ["pdfflow", "lhapdf-management"]
@@ -148,3 +149,10 @@ force_sort_within_sections = true
148149

149150
[tool.pytest.ini_options]
150151
addopts = "--disable-warnings"
152+
153+
[tool.coverage.run]
154+
omit = [
155+
"deprecated_functions.py",
156+
"*/nnpdf_data/commondata/*",
157+
"*/nnpdf_data/filter_utils/*",
158+
]

0 commit comments

Comments
 (0)