Skip to content

Commit d127e53

Browse files
authored
Add codecov (#16)
* Add coverage to Makefile * Add coverage to tests workflow * Add .codecov.yml * Configure action * Add codecov badge to README * Require diff changes, remove unittest tag
1 parent 75dbe61 commit d127e53

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed

.codecov.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
precision: 2
6+
round: down
7+
range: "70...100"
8+
9+
status:
10+
project: yes
11+
patch: yes
12+
changes: no
13+
14+
comment:
15+
layout: "reach, diff, flags, files"
16+
behavior: default
17+
require_changes: true # if true: only post the comment if coverage changes
18+
require_base: no # [yes :: must have a base report to post]
19+
require_head: yes # [yes :: must have a head report to post]
20+
branches: null # branch names that can post comment

.github/workflows/tests.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,14 @@ jobs:
2222
python -m pip install --upgrade pip
2323
pip install -r requirements.txt
2424
pip install -r requirements-dev.txt
25-
- name: pytest
25+
- name: Run tests and generate reports
2626
run: make test
27+
- name: Upload coverage to Codecov
28+
uses: codecov/codecov-action@v1
29+
if: matrix.python-version == 3.7
30+
with:
31+
token: ${{ secrets.CODECOV_TOKEN }}
32+
file: ./coverage.xml
33+
name: codecov-umbrella
34+
yml: ./.codecov.yml
35+
fail_ci_if_error: true

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ black: # Format code in-place using black.
6969

7070
.PHONY: test
7171
test: # Test code using pytest.
72-
pytest -v littlemcmc tests --doctest-modules --html=testing-report.html --self-contained-html
72+
pytest -v littlemcmc tests --doctest-modules --html=testing-report.html --self-contained-html --cov=./ --cov-report=xml
7373

7474
.PHONY: lint
7575
lint: blackstyle pylintstyle pydocstyle mypytypes # Lint code using black, pylint, pydocstyle and mypy.
@@ -79,7 +79,7 @@ check: lint test # Both lint and test code. Runs `make lint` followed by `make
7979

8080
.PHONY: clean
8181
clean: # Clean project directories.
82-
rm -rf dist/ site/ littlemcmc.egg-info/ pip-wheel-metadata/ __pycache__/ testing-report.html
82+
rm -rf dist/ site/ littlemcmc.egg-info/ pip-wheel-metadata/ __pycache__/ coverage.xml
8383
find littlemcmc/ tests/ -type d -name "__pycache__" -exec rm -rf {} +
8484
find littlemcmc/ tests/ -type d -name "__pycache__" -delete
8585
find littlemcmc/ tests/ -type f -name "*.pyc" -delete

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
![Tests Status](https://github.com/eigenfoo/littlemcmc/workflows/tests/badge.svg)
44
![Lint Status](https://github.com/eigenfoo/littlemcmc/workflows/lint/badge.svg)
5-
![License](https://img.shields.io/github/license/eigenfoo/littlemcmc)
5+
[![Coverage Status](https://codecov.io/gh/eigenfoo/littlemcmc/branch/master/graph/badge.svg)](https://codecov.io/gh/eigenfoo/littlemcmc)
6+
[![License](https://img.shields.io/github/license/eigenfoo/littlemcmc)](https://github.com/eigenfoo/littlemcmc/blob/master/LICENSE.littlemcmc.txt)
67

78
> littlemcmc     /lɪtəl ɛm si ɛm si/     _noun_
89
>

0 commit comments

Comments
 (0)