summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Berman <Julian@GrayVines.com>2020-08-30 11:34:58 -0400
committerJulian Berman <Julian@GrayVines.com>2020-08-30 12:13:32 -0400
commit9f25fb301dd2804c3d596a1fb816332473abc6b2 (patch)
tree47b54101a9b1e74429923b74fd77359b48425f09
parenta951fc780f43728f22082f338ec54f7eefd9f9a5 (diff)
downloadjsonschema-9f25fb301dd2804c3d596a1fb816332473abc6b2.tar.gz
Be able to run coverage on all toxenvs.
Shifts coverage into an optional CLI wrapper that's dropped in only when enabled via an environment variable. This means any toxenv can now be wrapped into a coverage run by running e.g. `tox -e py38-format-coverage` instead of `tox -e py38-format-tests`. Credits to @nedbat and @The-Compiler.
-rw-r--r--.github/workflows/coverage.yml2
-rw-r--r--tox.ini33
2 files changed, 13 insertions, 22 deletions
diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml
index b43b57a..446daf7 100644
--- a/.github/workflows/coverage.yml
+++ b/.github/workflows/coverage.yml
@@ -20,6 +20,6 @@ jobs:
- name: Install tox
run: python -m pip install tox
- name: Collect & Upload Coverage
- run: python -m tox -e codecov
+ run: python -m tox -e pypy3-format-coverage
env:
CODECOV_TOKEN: 2b38dae1-41c4-4435-a29d-79a1299e5617
diff --git a/tox.ini b/tox.ini
index 3deb5a3..53a7e85 100644
--- a/tox.ini
+++ b/tox.ini
@@ -10,8 +10,14 @@ skipsdist = True
[testenv]
changedir = {envtmpdir}
+passenv = CODECOV* CI
setenv =
JSON_SCHEMA_TEST_SUITE = {toxinidir}/json
+
+ coverage,codecov: MAYBE_COVERAGE = coverage run -m
+ coverage,codecov: COVERAGE_RCFILE={toxinidir}/.coveragerc
+ coverage,codecov: COVERAGE_DEBUG_FILE={envtmpdir}/coverage-debug
+ coverage,codecov: COVERAGE_FILE={envtmpdir}/coverage-data
whitelist_externals =
mkdir
commands =
@@ -19,9 +25,14 @@ commands =
format: {envpython} -m pip install '{toxinidir}[format]'
format_nongpl: {envpython} -m pip install '{toxinidir}[format_nongpl]'
- tests: {envpython} -m twisted.trial {posargs:jsonschema}
+ tests,coverage: {envpython} -m {env:MAYBE_COVERAGE:} twisted.trial {posargs:jsonschema}
tests: {envpython} -m doctest {toxinidir}/README.rst
+ coverage: {envpython} -m coverage report --show-missing
+ coverage: {envpython} -m coverage html --directory={envtmpdir}/htmlcov
+ codecov: {envpython} -m coverage xml -o {envtmpdir}/coverage.xml
+ codecov: codecov --required --disable gcov --file {envtmpdir}/coverage.xml
+
perf: mkdir {envtmpdir}/benchmarks/
perf: {envpython} {toxinidir}/jsonschema/benchmarks/issue232.py --inherit-environ JSON_SCHEMA_TEST_SUITE --output {envtmpdir}/benchmarks/issue232.json
perf: {envpython} {toxinidir}/jsonschema/benchmarks/json_schema_test_suite.py --inherit-environ JSON_SCHEMA_TEST_SUITE --output {envtmpdir}/benchmarks/json_schema_test_suite.json
@@ -69,17 +80,6 @@ deps =
commands =
{envpython} -m flake8 {posargs} {toxinidir}/jsonschema {toxinidir}/docs
-[testenv:coverage]
-setenv =
- {[testenv]setenv}
- COVERAGE_DEBUG_FILE={envtmpdir}/coverage-debug
- COVERAGE_FILE={envtmpdir}/coverage-data
-commands =
- {envpython} -m pip install '{toxinidir}[format]'
- {envpython} -m coverage run --rcfile={toxinidir}/.coveragerc -m twisted.trial jsonschema
- {envpython} -m coverage report --rcfile={toxinidir}/.coveragerc --show-missing
- {envpython} -m coverage html --directory={envtmpdir}/htmlcov --rcfile={toxinidir}/.coveragerc {posargs}
-
[testenv:docs-html]
basepython = pypy3
commands = {envpython} -m sphinx -b html {toxinidir}/docs/ {envtmpdir}/build {posargs:-a -n -q -T -W}
@@ -115,12 +115,3 @@ deps =
doc8
pygments
pygments-github-lexers
-
-[testenv:codecov]
-passenv = CODECOV* CI
-setenv = {[testenv:coverage]setenv}
-commands =
- {envpython} -m pip install '{toxinidir}[format]'
- {envpython} -m coverage run --rcfile={toxinidir}/.coveragerc -m twisted.trial jsonschema
- {envpython} -m coverage xml -o {envtmpdir}/coverage.xml
- codecov --required --disable gcov --file {envtmpdir}/coverage.xml