Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Measure test coverage #344

Merged
merged 1 commit into from
May 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/pythontest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,32 @@ on:

jobs:
build:

runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade tox

- name: Test
run: tox -e py3
run: tox -e py3 -- --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
fail_ci_if_error: false

- name: Upload pytest test results
uses: actions/upload-artifact@v2
with:
Expand Down
19 changes: 19 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ envlist = lint,py3
deps =
importlib-resources; python_version < '3.9'
pytest
pytest-cov
commands =
pytest {posargs} tests

Expand All @@ -19,13 +20,31 @@ commands =
flake8 src tests

[pytest]
addopts = --cov=nidm --no-cov-on-fail
filterwarnings =
error
# <https://github.com/sensein/etelemetry-client/pull/44>
ignore:.*pkg_resources:DeprecationWarning
# <https://github.com/PythonCharmers/python-future/issues/246>
ignore:the imp module is deprecated:DeprecationWarning

[coverage:run]
branch = True
parallel = True

[coverage:paths]
source =
src
.tox/**/site-packages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need both src and .tox paths here? i.e. which is one is really in use or really both while running tox testing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point of this config setting is to get coverage to treat paths installed under .tox as though they were actually the equivalent paths under src.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, not yet sure how/why that would do it but I will just trust you on this ;)


[coverage:report]
precision = 2
show_missing = True
exclude_lines =
pragma: no cover
if TYPE_CHECKING:
\.\.\.

[flake8]
doctests = True
exclude = .*/,build/,dist/,test/data,venv/
Expand Down