Skip to content

Commit

Permalink
add codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
fabien-marty committed May 31, 2023
1 parent 09e28d3 commit a2b62ff
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
2 changes: 2 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[run]
omit = fnv_c/ext/build.py
7 changes: 6 additions & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
invoke lint --no-fix
- name: Run tests
run: |
invoke test
invoke test --coverage
- name: Make API docs
if: matrix.python-version == '3.7'
run: |
Expand All @@ -46,6 +46,11 @@ jobs:
with:
name: apidoc
path: apihtml/
- name: Upload coverage reports to Codecov
if: matrix.python-version == '3.7' && github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

githubpages:
runs-on: ubuntu-latest
Expand Down
4 changes: 4 additions & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ certifi==2023.5.7
cffi==1.15.1
charset-normalizer==3.1.0
click==8.1.3
coverage==7.2.7
docutils==0.20.1
dunamai==1.17.0
idna==3.4
Expand All @@ -28,6 +29,9 @@ pluggy==1.0.0
pycparser==2.21
Pygments==2.15.1
pytest==7.3.1
pytest-cov==4.1.0
pytest-cover==3.0.0
pytest-coverage==0.0
readme-renderer==37.3
requests==2.31.0
requests-toolbelt==1.0.0
Expand Down
15 changes: 13 additions & 2 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ def _clean_apidoc(c):
c.run("rm -Rf apihtml")


def _clean_coverage(c):
c.run("rm -Rf htmlcov")


@task
def clean(c):
"""Clean the repository"""
Expand All @@ -18,6 +22,7 @@ def clean(c):
c.run("find . -type d -name __pycache__ -exec rm -Rf {} \\; 2>/dev/null || true")
c.run("rm -Rf dist build")
_clean_apidoc(c)
_clean_coverage(c)


@task(help={"fix": "try to automatically fix the code (default)"})
Expand Down Expand Up @@ -45,10 +50,16 @@ def lint(c, fix=True):
lint_black(c, fix=fix)


@task()
@task(help={"coverage": "compute coverage"})
def test(c, coverage=False):
"""Execute unit tests"""
c.run("pytest .")
if coverage:
_clean_coverage(c)
c.run(
f"pytest --cov-config=.coveragerc --no-cov-on-fail --cov={PACKAGE} --cov-report=term --cov-report=html --cov-report=xml ."
)
else:
c.run("pytest .")


@task
Expand Down

0 comments on commit a2b62ff

Please sign in to comment.