From dc3b8902c0a4d7427d721f97dd7fdfffc6e583d9 Mon Sep 17 00:00:00 2001 From: Ruda Porto Filgueiras Date: Sat, 15 Oct 2022 15:38:40 +0200 Subject: [PATCH 1/3] fix combined coverage report --- .meta.toml | 39 ++++++++++++++++----------------------- tox.ini | 27 ++++++--------------------- 2 files changed, 22 insertions(+), 44 deletions(-) diff --git a/.meta.toml b/.meta.toml index bb6c073..ed872c7 100644 --- a/.meta.toml +++ b/.meta.toml @@ -2,7 +2,7 @@ # https://github.com/zopefoundation/meta/tree/master/config/pure-python [meta] template = "pure-python" -commit-id = "b5df3766ff8923477f3d24729b19504f0c401a2e" +commit-id = "54e37f7de7149c0d4003e40bbe300d012a851ce7" [python] with-pypy = false @@ -16,7 +16,6 @@ with-future-python = true use-flake8 = true additional-envlist = [ "py39-datetime", - "combined-coverage", ] testenv-deps = [ "datetime: DateTime", @@ -31,33 +30,27 @@ testenv-commands = [ "pip list", "pytest --cov=src --cov=tests --cov-report= {posargs}", ] -testenv-additional = [ - "", - "[testenv:combined-coverage]", - "basepython = python3", - "allowlist_externals =", - " mkdir", - "deps =", - " coverage", - " -cconstraints.txt", - "setenv =", - " COVERAGE_FILE=.coverage", - "commands =", - " mkdir -p {toxinidir}/parts/htmlcov", - " coverage erase", - " coverage combine", - " coverage html", - " coverage report -m --fail-under=100", - "depends = py36,py37,py38,py39,py39-datetime,py310,py311,coverage", +coverage-basepython = "python3" +coverage-deps = [ + "coverage", + "-cconstraints.txt", + ] +coverage-command = [ + "mkdir -p {toxinidir}/parts/htmlcov", + "coverage combine", + "coverage html", + "coverage report -m --fail-under=100", ] -coverage-basepython = "python3.8" -coverage-command = "pytest --cov=src --cov=tests --cov-report= {posargs}" +coverage-depends = "py36,py37,py38,py39,py39-datetime,py310,py311" coverage-setenv = [ "COVERAGE_FILE=.coverage", ] +coverage-allowlist_externals = [ + "mkdir", + ] [coverage] -fail-under = 98.8 +fail-under = 100.0 [isort] additional-sources = "{toxinidir}/tests" diff --git a/tox.ini b/tox.ini index 3226a98..cbd1115 100644 --- a/tox.ini +++ b/tox.ini @@ -13,7 +13,6 @@ envlist = docs coverage py39-datetime - combined-coverage [testenv] usedevelop = true @@ -34,23 +33,6 @@ extras = test docs -[testenv:combined-coverage] -basepython = python3 -allowlist_externals = - mkdir -deps = - coverage - -cconstraints.txt -setenv = - COVERAGE_FILE=.coverage -commands = - mkdir -p {toxinidir}/parts/htmlcov - coverage erase - coverage combine - coverage html - coverage report -m --fail-under=100 -depends = py36,py37,py38,py39,py39-datetime,py310,py311,coverage - [testenv:lint] basepython = python3 skip_install = true @@ -83,7 +65,7 @@ commands = sphinx-build -b doctest -d docs/_build/doctrees docs docs/_build/doctest [testenv:coverage] -basepython = python3.8 +basepython = python3 allowlist_externals = mkdir deps = @@ -96,10 +78,13 @@ setenv = COVERAGE_FILE=.coverage commands = mkdir -p {toxinidir}/parts/htmlcov - pytest --cov=src --cov=tests --cov-report= {posargs} + mkdir -p {toxinidir}/parts/htmlcov + coverage combine + coverage html + coverage report -m --fail-under=100 coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest coverage html - coverage report -m --fail-under=98.8 + coverage report -m --fail-under=100.0 [coverage:run] branch = True From 95272c290cd27fc481d2c5a692d13ac4ed1618e3 Mon Sep 17 00:00:00 2001 From: Ruda Porto Filgueiras Date: Sat, 15 Oct 2022 15:53:24 +0200 Subject: [PATCH 2/3] fix: combined coverage report --- .github/workflows/tests.yml | 2 ++ .meta.toml | 15 +++------------ tox.ini | 6 ++---- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14244e4..6b95bd2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,10 +58,12 @@ jobs: python -m pip install --upgrade pip pip install tox - name: Test + if: matrix.config[1] != 'coverage' run: tox -e ${{ matrix.config[1] }} - name: Coverage if: matrix.config[1] == 'coverage' run: | + tox -e py36,py37,py38,py39,py39-datetime,py310,py311,coverage pip install coveralls coveralls --service=github env: diff --git a/.meta.toml b/.meta.toml index ed872c7..5f54a5a 100644 --- a/.meta.toml +++ b/.meta.toml @@ -31,23 +31,14 @@ testenv-commands = [ "pytest --cov=src --cov=tests --cov-report= {posargs}", ] coverage-basepython = "python3" -coverage-deps = [ - "coverage", - "-cconstraints.txt", - ] coverage-command = [ - "mkdir -p {toxinidir}/parts/htmlcov", - "coverage combine", - "coverage html", - "coverage report -m --fail-under=100", - ] + "coverage erase", + "coverage combine" +] coverage-depends = "py36,py37,py38,py39,py39-datetime,py310,py311" coverage-setenv = [ "COVERAGE_FILE=.coverage", ] -coverage-allowlist_externals = [ - "mkdir", - ] [coverage] fail-under = 100.0 diff --git a/tox.ini b/tox.ini index cbd1115..ec3a21e 100644 --- a/tox.ini +++ b/tox.ini @@ -11,8 +11,8 @@ envlist = py310 py311 docs - coverage py39-datetime + coverage [testenv] usedevelop = true @@ -78,10 +78,8 @@ setenv = COVERAGE_FILE=.coverage commands = mkdir -p {toxinidir}/parts/htmlcov - mkdir -p {toxinidir}/parts/htmlcov + coverage erase coverage combine - coverage html - coverage report -m --fail-under=100 coverage run -a -m sphinx -b doctest -d {envdir}/.cache/doctrees docs {envdir}/.cache/doctest coverage html coverage report -m --fail-under=100.0 From f3704f2c1929d94ae1361d3bd7c097f1b691a3c8 Mon Sep 17 00:00:00 2001 From: Ruda Porto Filgueiras Date: Sun, 16 Oct 2022 10:21:00 +0200 Subject: [PATCH 3/3] coverage: add new job to run after build Build job: - add upload artifact step after each test in the matrix. - update coveralls step to upload partial data. Converage job (new): - complete the coveralls in the coverage job. - add step to download all uploaded artifacts - add step to combine coverage data, create report and fail if not enough - add step to upload html report if coverage is not enough --- .github/workflows/tests.yml | 57 ++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6b95bd2..d55ec84 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -29,12 +29,10 @@ jobs: - ["3.10", "py310"] - ["3.11.0-rc.2", "py311"] - ["3.9", "docs"] - - ["3.9", "coverage"] - ["3.9", "py39-datetime"] exclude: - { os: windows, config: ["3.9", "lint"] } - { os: windows, config: ["3.9", "docs"] } - - { os: windows, config: ["3.9", "coverage"] } runs-on: ${{ matrix.os }}-latest if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name @@ -58,13 +56,50 @@ jobs: python -m pip install --upgrade pip pip install tox - name: Test - if: matrix.config[1] != 'coverage' run: tox -e ${{ matrix.config[1] }} - - name: Coverage - if: matrix.config[1] == 'coverage' - run: | - tox -e py36,py37,py38,py39,py39-datetime,py310,py311,coverage - pip install coveralls - coveralls --service=github - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload coverage artifact + uses: actions/upload-artifact@v2 + if: matrix.os != 'windows' + with: + name: coverage-data + path: .coverage.${{ matrix.config[1] }} + if-no-files-found: ignore + + coverage: + name: Combined coverage + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + # Use latest, so it understands all syntax. + python-version: "3.10" + - run: python -m pip install --upgrade coveralls coverage[toml] + + - name: Download coverage data. + uses: actions/download-artifact@v2 + with: + name: coverage-data + + - name: Indicate completion to coveralls.io + run: | + python -m coverage combine + coveralls --service=github + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Coverage report and fail if it's <100%. + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + python -m coverage html --skip-covered --skip-empty + python -m coverage report --fail-under=100 + + - name: Upload HTML report if check failed. + uses: actions/upload-artifact@v2 + with: + name: html-report + path: htmlcov + if: ${{ failure() }}