Generate test coverage report in CI (#111)

Fail if our test coverage goes down.
This commit is contained in:
Jonathan Lange 2018-02-20 11:34:38 +00:00 committed by GitHub
parent d5151b78b9
commit 0679cea91c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 2 deletions

5
.coveragerc Normal file
View File

@ -0,0 +1,5 @@
[run]
branch = True
include =
grafanalib/*.py
grafanalib/**/*.py

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ dist/
/.cache
.ensure-*
/.tox
/.coverage

View File

@ -1,4 +1,4 @@
.PHONY: all clean clean-deps lint test deps
.PHONY: all clean clean-deps lint test deps coverage
.DEFAULT_GOAL := all
# Boiler plate for bulding Docker containers.
@ -51,7 +51,7 @@ endif
images:
$(info $(IMAGE_NAMES))
all: $(UPTODATE_FILES) test lint
all: $(UPTODATE_FILES) test lint coverage
deps: setup.py .ensure-tox tox.ini
@ -65,6 +65,9 @@ lint: .ensure-flake8
test: .ensure-tox
$(TOX) --skip-missing-interpreters
coverage:
$(TOX) -e coverage
clean:
$(SUDO) docker rmi $(IMAGE_NAMES) >/dev/null 2>&1 || true
rm -rf $(UPTODATE_FILES)

10
tox.ini
View File

@ -10,3 +10,13 @@ envlist = py27, py34, py35, py36
commands = pytest --junitxml=junit-{envname}.xml
deps =
pytest
[testenv:coverage]
deps =
coverage
pytest
commands =
python -m coverage run --rcfile=.coveragerc -m pytest --strict --maxfail=1 --ff {posargs}
# Had 88% test coverage at time of introducing coverage ratchet.
# This number must only go up.
python -m coverage report --rcfile=.coveragerc --show-missing --fail-under=88