Skip to content

Commit da3a275

Browse files
authored
Enable codecov (#156)
1 parent b21692e commit da3a275

File tree

4 files changed

+62
-7
lines changed

4 files changed

+62
-7
lines changed

.github/workflows/tox.yml

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,21 @@ on:
1616

1717
jobs:
1818
build:
19-
name: ${{ matrix.name }}
19+
name: ${{ matrix.name || matrix.tox_env }}
2020
runs-on: ${{ matrix.os }}
2121
strategy:
2222
fail-fast: false
2323
matrix:
24+
os:
25+
- ubuntu-latest
26+
python-version:
27+
- 3.9
28+
tox_env:
29+
- lint
30+
- packaging
31+
cover:
32+
- false
2433
include:
25-
- os: ubuntu-latest
26-
python-version: 3.9
27-
tox_env: lint
28-
name: lint
2934
- os: ubuntu-latest
3035
python-version: 3.9
3136
tox_env: packaging
@@ -34,26 +39,32 @@ jobs:
3439
python-version: 3.6
3540
tox_env: py36
3641
name: py36
42+
cover: true
3743
- os: ubuntu-latest
3844
python-version: 3.7
3945
tox_env: py37
4046
name: py37
47+
cover: true
4148
- os: ubuntu-latest
4249
python-version: 3.8
4350
tox_env: py38
4451
name: py38
52+
cover: true
4553
- os: ubuntu-latest
4654
python-version: 3.9
4755
tox_env: py39
4856
name: py39
57+
cover: true
4958
- os: macOS-latest
5059
python-version: 3.6
5160
tox_env: py36
5261
name: py36-macos
62+
cover: true
5363
- os: macOS-latest
5464
python-version: 3.9
5565
tox_env: py39
5666
name: py39-macos
67+
cover: true
5768

5869
steps:
5970
- uses: actions/checkout@v2
@@ -64,8 +75,18 @@ jobs:
6475
- name: Install dependencies
6576
run: |
6677
python -m pip install -U pip
67-
pip install tox
78+
pip install tox coverage
6879
- name: Run tox -e ${{ matrix.tox_env }}
6980
run: |
7081
echo "${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }}"
7182
${{ matrix.PREFIX }} tox -e ${{ matrix.tox_env }}
83+
84+
- name: Upload coverage data
85+
uses: codecov/codecov-action@v2
86+
with:
87+
directory: .tox
88+
files: 'coverage-*.xml'
89+
name: ${{ matrix.tox_env }}
90+
fail_ci_if_error: true # optional (default = false)
91+
verbose: true # optional (default = false)
92+
if: ${{ matrix.cover }}

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
---
2+
ci:
3+
autoupdate_commit_msg: "chore: pre-commit autoupdate"
4+
autoupdate_schedule: monthly
5+
autofix_commit_msg: |
6+
chore: auto fixes from pre-commit.com hooks
7+
8+
for more information, see https://pre-commit.ci
9+
skip:
10+
# https://github.com/pre-commit-ci/issues/issues/55
11+
- codecov
212
repos:
13+
- repo: local
14+
hooks:
15+
- id: codecov
16+
name: Check codecov.yml
17+
# https://superuser.com/a/1587813/3004
18+
entry: >
19+
bash -c '[ $(
20+
curl --silent -o /dev/stderr -w "%{http_code}" -X POST --data-binary @codecov.yml https://codecov.io/validate
21+
) -eq 200 ]'
22+
language: system
23+
files: "codecov.yml"
24+
pass_filenames: false
325
- repo: https://github.com/PyCQA/isort
426
rev: 5.10.1
527
hooks:

codecov.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
codecov:
2+
notify:
3+
wait_for_ci: true
4+
require_ci_to_pass: true
5+
comment: false
6+
coverage:
7+
status:
8+
patch: false
9+
project:
10+
default:
11+
threshold: 0.5%

tox.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ setenv =
1111
PYTHONWARNINGS=error::FutureWarning
1212
# Aim to replace with below once other issues are fixed:
1313
# PYTHONWARNINGS=error
14+
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
1415
deps =
1516
mock
1617
pytest
1718
pytest-cov
1819
sitepackages = False
19-
commands = python -m pytest -ra --cov=ansi2html --no-cov-on-fail --cov-append
20+
commands = python -m pytest -ra --cov=ansi2html --no-cov-on-fail --cov-append --cov-report=xml:{toxworkdir}/coverage-{envname}.xml
2021

2122
[testenv:lint]
2223
description = Runs all linting tasks

0 commit comments

Comments
 (0)