Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: combined coverage report #238

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
55 changes: 46 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -59,10 +57,49 @@ jobs:
pip install tox
- name: Test
run: tox -e ${{ matrix.config[1] }}
- name: Coverage
if: matrix.config[1] == 'coverage'
run: |
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() }}
32 changes: 8 additions & 24 deletions .meta.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -16,7 +16,6 @@ with-future-python = true
use-flake8 = true
additional-envlist = [
"py39-datetime",
"combined-coverage",
]
testenv-deps = [
"datetime: DateTime",
Expand All @@ -31,33 +30,18 @@ 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.8"
coverage-command = "pytest --cov=src --cov=tests --cov-report= {posargs}"
coverage-basepython = "python3"
coverage-command = [
"coverage erase",
"coverage combine"
]
coverage-depends = "py36,py37,py38,py39,py39-datetime,py310,py311"
coverage-setenv = [
"COVERAGE_FILE=.coverage",
]

[coverage]
fail-under = 98.8
fail-under = 100.0

[isort]
additional-sources = "{toxinidir}/tests"
Expand Down
27 changes: 5 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ envlist =
py310
py311
docs
coverage
py39-datetime
combined-coverage
coverage

[testenv]
usedevelop = true
Expand All @@ -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
Expand Down Expand Up @@ -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 =
Expand All @@ -96,10 +78,11 @@ setenv =
COVERAGE_FILE=.coverage
commands =
mkdir -p {toxinidir}/parts/htmlcov
pytest --cov=src --cov=tests --cov-report= {posargs}
coverage erase
coverage combine
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
Expand Down