Skip to content

Commit c6c6102

Browse files
committed
ci: measure test coverage and add Codecov badge
1 parent 2f0a330 commit c6c6102

3 files changed

Lines changed: 43 additions & 0 deletions

File tree

‎.github/workflows/coverage.yml‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Coverage
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
coverage:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
17+
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
18+
with:
19+
# 3.10 is the real floor, see test.yml
20+
python-version: "3.10"
21+
- name: Install dependencies
22+
run: |
23+
pip install -r requirements.txt
24+
pip install pytest pytest-cov
25+
- name: Run tests with coverage
26+
run: |
27+
pytest --cov=main --cov-report=xml --cov-report=term-missing main_test.py
28+
- name: Upload coverage to Codecov
29+
uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
30+
with:
31+
files: ./coverage.xml
32+
flags: unittests
33+
name: codecov-umbrella
34+
# Hard-fail on push to main so a broken upload is visible; on PRs the
35+
# report is informational and a flaky upload should not block review.
36+
fail_ci_if_error: ${{ github.event_name == 'push' }}

‎.gitignore‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,9 @@ venv/
22
.venv/
33
__pycache__/
44
result.txt
5+
6+
# pytest-cov
7+
.coverage
8+
.coverage.*
9+
coverage.xml
10+
htmlcov/

‎README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![GitHub marketplace](https://img.shields.io/badge/Marketplace-commit--check--action-blue)](https://github.com/marketplace/actions/commit-check-action)
66
[![commit-check](https://img.shields.io/badge/commit--check-enabled-brightgreen?logo=Git&logoColor=white&color=%232c9ccd)](https://github.com/commit-check/commit-check)
77
[![slsa-badge](https://slsa.dev/images/gh-badge-level3.svg?color=blue)](https://github.com/commit-check/commit-check-action/blob/a2873ca0482dd505c93fb51861c953e82fd0a186/action.yml#L59-L69)
8+
[![codecov](https://codecov.io/gh/commit-check/commit-check-action/branch/main/graph/badge.svg?token=G3R0LFO0YF)](https://codecov.io/gh/commit-check/commit-check-action)
89

910
A GitHub Action for checking commit message formatting, branch naming, committer name, email, commit signoff, and more.
1011

0 commit comments

Comments
 (0)