Skip to content

Commit e58ec5c

Browse files
authored
Merge pull request #2299 from NNPDF/coverage_report
Prepare a coverage report in the CI
2 parents 2974c37 + 1c8b5bd commit e58ec5c

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

.github/workflows/all_tests_nnpdf.yml

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,15 @@ jobs:
3030
- name: Test n3fit and validphys
3131
shell: bash -l {0}
3232
run: |
33-
pytest --mpl --pyargs validphys n3fit --mpl-default-tolerance 18
33+
pytest --cov=${PWD} --cov-config=pyproject.toml --mpl --pyargs validphys n3fit --mpl-default-tolerance 18
34+
- name: Keep coverage file
35+
if: startsWith(matrix.python-version, '3.12')
36+
uses: actions/upload-artifact@v4
37+
with:
38+
include-hidden-files: true
39+
name: coverage-package-${{ matrix.os }}
40+
path: .coverage
41+
3442

3543
regression_tests:
3644
runs-on: ubuntu-latest
@@ -40,7 +48,13 @@ jobs:
4048
- name: Run regression tests
4149
shell: bash -l {0}
4250
run: |
43-
pytest extra_tests/regression_checks.py
51+
pytest --cov=${PWD} --cov-config=pyproject.toml extra_tests/regression_checks.py
52+
- name: Keep coverage file
53+
uses: actions/upload-artifact@v4
54+
with:
55+
include-hidden-files: true
56+
name: coverage-regression
57+
path: .coverage
4458

4559
conda_tests:
4660
strategy:
@@ -87,3 +101,22 @@ jobs:
87101
run: |
88102
cd n3fit/runcards/examples
89103
n3fit Basic_runcard.yml 4
104+
105+
full_coverage:
106+
needs: [run_package_tests, regression_tests]
107+
runs-on: ubuntu-latest
108+
steps:
109+
- uses: actions/checkout@v4
110+
- uses: ./.github/actions/install_conda_pip
111+
with:
112+
nnpdf-extras: ""
113+
- name: Install coverage
114+
run: pip install coverage
115+
- name: Download reports
116+
uses: actions/download-artifact@v4
117+
with:
118+
path: reports
119+
- name: Merge and show
120+
run: |
121+
coverage combine reports/**/.coverage
122+
coverage report -i

pyproject.toml

Lines changed: 18 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,19 @@ force_sort_within_sections = true
148149

149150
[tool.pytest.ini_options]
150151
addopts = "--disable-warnings"
152+
153+
[tool.coverage.run]
154+
omit = [
155+
"*/local*",
156+
"*/rule*",
157+
"deprecated_functions.py",
158+
"*/nnpdf_data/commondata/*",
159+
"*/nnpdf_data/filter_utils/*",
160+
"*test_*.py"
161+
]
162+
[tool.coverage.paths]
163+
cipaths = [ # In order to combine files from both the ubuntu and macos runners
164+
"./", # CI working directory
165+
"/Users/runner/work/nnpdf/nnpdf",
166+
"/home/runner/work/nnpdf/nnpdf"
167+
]

0 commit comments

Comments
 (0)