Skip to content

Commit

Permalink
Generate and upload code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
antonblr authored and yliaog committed Feb 14, 2022
1 parent 649c5fe commit 115a970
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 14 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ on: [ push, pull_request ]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
python-version: ["3.6", "3.7", "3.8", "3.10"]
include:
- python-version: "3.9"
use_coverage: 'coverage'

steps:
- uses: actions/checkout@v2
Expand All @@ -31,5 +33,18 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install Tox and any other packages
run: pip install tox
- name: Run Tox

- name: Test without coverage
if: "! matrix.use_coverage"
run: tox -e py # Run tox using the version of Python in `PATH`

- name: Test with coverage
if: "matrix.use_coverage"
run: tox -e py-coverage

- name: Upload coverage to Codecov
if: "matrix.use_coverage"
uses: codecov/codecov-action@v2
with:
fail_ci_if_error: true
verbose: true
6 changes: 6 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# reference: https://docs.codecov.io/docs/codecovyml-reference
coverage:
status:
patch: true
project: false
comment: false
1 change: 0 additions & 1 deletion test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ mock>=2.0.0
sphinx>=1.4 # BSD
recommonmark
sphinx_markdown_tables
codecov>=1.4.0
pycodestyle
autopep8
isort
14 changes: 4 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ deps = -r{toxinidir}/test-requirements.txt
-r{toxinidir}/requirements.txt
commands =
python -V
!functional: pytest -vvv -s --ignore=kubernetes/e2e_test
!functional: pytest -vvv -s {env:_TOX_COVERAGE_RUN:} --ignore=kubernetes/e2e_test
functional: {toxinidir}/scripts/kube-init.sh pytest -vvv -s []
coverage: python -m coverage xml
setenv =
coverage: _TOX_COVERAGE_RUN=--cov=kubernetes/watch --cov=kubernetes/config

[testenv:docs]
commands =
Expand All @@ -21,12 +24,3 @@ commands =
[testenv:update-pycodestyle]
commands =
{toxinidir}/scripts/update-pycodestyle.sh

[testenv:coverage]
commands =
python -V
pytest --cov=kubernetes/watch --cov=kubernetes/config kubernetes/watch kubernetes/config

[testenv:codecov]
commands =
codecov

0 comments on commit 115a970

Please sign in to comment.