Skip to content

Commit

Permalink
Enable code coverage via codecov.io (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
cgohlke authored Jun 27, 2024
1 parent b16e7a4 commit edd2fa1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
11 changes: 11 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
codecov:
notify:
require_ci_to_pass: false
after_n_builds: 1
coverage:
status:
project:
default:
threshold: 0.1%
informational: true
comment: off
41 changes: 41 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Code coverage

on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:

jobs:
code_coverage:
name: Code coverage
runs-on: "ubuntu-latest"
strategy:
fail-fast: false
matrix:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Editable install
run: |
python -m pip install --upgrade pip
python -m pip install --editable .
python -m pip install -r requirements_dev.txt
python -m pip install -r requirements_numpy.txt
- name: Generate coverage report
run: |
pytest --cov=phasorpy --cov-report=xml tests
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
env_vars: OS,PYTHON
fail_ci_if_error: false
token: ${{ secrets.PHASORPY_CODECOV_TOKEN }}
verbose: true
8 changes: 4 additions & 4 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ thorougly.

Run the unit tests in the development environment::

$ python -m pytest -v
$ python -m pytest -v --cov=phasorpy --cov-report=html tests

All tests must pass.

PhasorPy strives to maintain near complete test coverage. The coverage report
is automatically generated during testing in the ``_htmlcov`` folder.
PhasorPy strives to maintain near complete code coverage. A coverage report
is generated during testing in the ``_htmlcov`` folder.

Configuration settings for pytest and other tools are in the
``pyproject.toml`` file.
Expand Down Expand Up @@ -232,7 +232,7 @@ standard.
Examples in docstrings must run and pass as
`doctests <https://docs.python.org/3/library/doctest.html>`_ ::

$ python -m pytest -v phasorpy
$ python -m pytest -v src/phasorpy

Examples in docstrings are meant to illustrate mere usage, not to
provide a testing framework.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ directory = "_htmlcov"
minversion = "7"
log_cli_level = "INFO"
xfail_strict = true
addopts = "-rfEXs --strict-config --strict-markers --cov=phasorpy --cov-report html --doctest-modules --doctest-glob=*.py --doctest-glob=*.rst"
addopts = "-rfEXs --strict-config --strict-markers --doctest-modules --doctest-glob=*.py --doctest-glob=*.rst"
doctest_optionflags = [
"NORMALIZE_WHITESPACE",
"ELLIPSIS",
Expand Down

0 comments on commit edd2fa1

Please sign in to comment.