From 18f3bd24080bd6da0c3815d498d9290264bc0684 Mon Sep 17 00:00:00 2001 From: antonblr Date: Thu, 10 Feb 2022 15:49:01 -0800 Subject: [PATCH] Generate and upload code coverage --- .github/workflows/test.yaml | 21 ++++++++++++++++++--- codecov.yml | 6 ++++++ test-requirements.txt | 1 - tox.ini | 14 ++++---------- 4 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 codecov.yml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 0435b638c..57c2bd81b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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 @@ -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 diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 000000000..f1cc86973 --- /dev/null +++ b/codecov.yml @@ -0,0 +1,6 @@ +# reference: https://docs.codecov.io/docs/codecovyml-reference +coverage: + status: + patch: true + project: false +comment: false diff --git a/test-requirements.txt b/test-requirements.txt index 5e6aac088..80a5be1fd 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -9,7 +9,6 @@ mock>=2.0.0 sphinx>=1.4 # BSD recommonmark sphinx_markdown_tables -codecov>=1.4.0 pycodestyle autopep8 isort diff --git a/tox.ini b/tox.ini index 9c7e4b7e0..8a6bdac13 100644 --- a/tox.ini +++ b/tox.ini @@ -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 = @@ -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