Skip to content

Commit

Permalink
Generate test coverage report in CI (weaveworks#111)
Browse files Browse the repository at this point in the history
Fail if our test coverage goes down.
  • Loading branch information
jml authored Feb 20, 2018
1 parent d5151b7 commit 0679cea
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[run]
branch = True
include =
grafanalib/*.py
grafanalib/**/*.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ dist/
/.cache
.ensure-*
/.tox
/.coverage
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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

Expand All @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0679cea

Please sign in to comment.