Skip to content

Commit 0d93c4b

Browse files
authored
Merge pull request #38 from kuchtact/add-codecov
Add Codecov
2 parents 029e152 + f4a6292 commit 0d93c4b

File tree

4 files changed

+58
-10
lines changed

4 files changed

+58
-10
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,19 @@ jobs:
2828
python: '3.9'
2929
nox_session: tests-3.9
3030

31-
- name: Tests, Python 3.11, macOS
31+
- name: Tests, Python 3.11, with code coverage, macOS
3232
os: macos-latest
3333
python: '3.11'
34-
nox_session: tests-3.11
34+
nox_session: tests-3.11(cov)
3535

3636
- name: Tests, Python 3.10, macOS
3737
os: macos-latest
3838
python: '3.9'
3939
nox_session: tests-3.9
4040

41-
- name: Documentation, Python 3.12, Ubuntu
41+
- name: Documentation, Python 3.11, Ubuntu
4242
os: ubuntu-latest
43-
python: '3.12'
43+
python: '3.11'
4444
nox_session: docs
4545

4646
steps:
@@ -67,10 +67,12 @@ jobs:
6767
run: python -m pip install --progress-bar off --upgrade nox
6868

6969
- name: Run tests
70-
run: nox -s ${{ matrix.nox_session }}
70+
run: nox -s '${{ matrix.nox_session }}'
7171

7272
- name: Upload coverage to codecov
7373
if: ${{ contains(matrix.nox_session,'cov') }}
74-
uses: codecov/codecov-action@v3
74+
uses: codecov/codecov-action@v4
7575
with:
7676
file: ./coverage.xml
77+
env:
78+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

codecov.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
codecov:
2+
notify:
3+
wait_for_ci: false
4+
require_ci_to_pass: false
5+
# coverage:
6+
# range: 90..98
7+
# status:
8+
# project:
9+
# default:
10+
# # Temporarily allow a greater project coverage threshold; see #2757
11+
# threshold: 0.9%
12+
# removed_code_behavior: adjust_base
13+
# patch:
14+
# default:
15+
# threshold: 0.5%
16+
# removed_code_behavior: adjust_base

mamba_environment.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ channels:
66
dependencies:
77
- python
88
- jupyter
9-
- numpy
9+
- numpy < 2
1010
- scipy
1111
- matplotlib
1212
- mdsplus
@@ -16,5 +16,6 @@ dependencies:
1616
- sphinx
1717
- pip
1818
- pip:
19-
- pytest
2019
- nox
20+
- pytest
21+
- pytest-cov

noxfile.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,42 @@ def install_environment(session, environment_path="mamba_environment.yml"):
2323
],
2424
silent=False,
2525
)
26+
session.run(
27+
*[
28+
session.venv_backend,
29+
"list",
30+
"--prefix",
31+
session.virtualenv.location,
32+
]
33+
)
34+
35+
36+
test_specifiers: list = [
37+
nox.param("run all tests", id="all"),
38+
nox.param("with code coverage", id="cov"),
39+
]
40+
41+
with_coverage: tuple[str, ...] = (
42+
"--cov=wipplpy",
43+
"--cov-report=xml",
44+
"--cov-config=pyproject.toml",
45+
"--cov-append",
46+
"--cov-report",
47+
"xml:coverage.xml",
48+
)
2649

2750

2851
@nox.session(python=supported_python_versions)
29-
def tests(session):
52+
@nox.parametrize("test_specifier", test_specifiers)
53+
def tests(session, test_specifier):
3054
"""Run tests with pytest."""
3155
install_environment(session)
32-
session.run("pytest")
56+
57+
options = []
58+
if test_specifier == "with code coverage":
59+
options += with_coverage
60+
61+
session.run("pytest", *options)
3362

3463

3564
@nox.session(python=maxpython)

0 commit comments

Comments
 (0)