Skip to content

Commit ffbbe17

Browse files
ci: integrate Codecov and pytest-cov
1 parent 9b1fc58 commit ffbbe17

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

.github/workflows/ci.yml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,19 @@ jobs:
1818
os: [ubuntu-latest, macos-latest, windows-latest]
1919
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
2020

21+
include:
22+
- os: ubuntu-latest
23+
python-version: "3.13"
24+
coverage: true
25+
2126
steps:
2227
- uses: actions/checkout@v4
2328

2429
- name: Set up Python
2530
uses: actions/setup-python@v5
2631
with:
2732
python-version: ${{ matrix.python-version }}
33+
2834
- name: Locate pip cache
2935
id: pip-cache
3036
shell: bash
@@ -36,15 +42,37 @@ jobs:
3642
path: ${{ steps.pip-cache.outputs.dir }}
3743
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
3844
restore-keys: ${{ runner.os }}-pip-
45+
3946
- name: Install dependencies
4047
run: |
4148
python -m pip install --upgrade pip
4249
python -m pip install ".[dev]"
4350
4451
- name: Run tests
52+
if: ${{ matrix.coverage != true }}
4553
run: pytest
4654

47-
# Run pre-commit only on Python 3.13 + ubuntu.
55+
- name: Run tests and collect coverage
56+
if: ${{ matrix.coverage == true }}
57+
run: |
58+
pytest \
59+
--cov=gitingest \
60+
--cov=server \
61+
--cov-branch \
62+
--cov-report=xml \
63+
--cov-report=term
64+
65+
- name: Upload coverage to Codecov
66+
if: ${{ matrix.coverage == true }}
67+
uses: codecov/codecov-action@v5
68+
with:
69+
token: ${{ secrets.CODECOV_TOKEN }}
70+
files: coverage.xml
71+
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
72+
name: codecov-${{ matrix.os }}-${{ matrix.python-version }}
73+
fail_ci_if_error: true
74+
verbose: true
75+
4876
- name: Run pre-commit hooks
4977
uses: pre-commit/action@v3.0.1
5078
if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<br>
1212
<!-- row 2 — quality & community -->
1313
<a href="https://github.com/coderamp-labs/gitingest/actions/workflows/ci.yml?query=branch%3Amain"><img src="https://github.com/coderamp-labs/gitingest/actions/workflows/ci.yml/badge.svg?branch=main" alt="CI"></a>
14+
<!-- <a href="https://codecov.io/gh/coderamp-labs/gitingest"><img src="https://codecov.io/gh/coderamp-labs/gitingest/graph/badge.svg" alt="Code Coverage"></a> -->
1415
<a href="https://github.com/astral-sh/ruff"><img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" alt="Ruff"></a>
1516
<a href="https://scorecard.dev/viewer/?uri=github.com/coderamp-labs/gitingest"><img src="https://api.scorecard.dev/projects/github.com/coderamp-labs/gitingest/badge" alt="OpenSSF Scorecard"></a>
1617
<br>

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ dev = [
4141
"pre-commit",
4242
"pytest",
4343
"pytest-asyncio",
44+
"pytest-cov",
4445
"pytest-mock",
4546
]
4647

requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ eval-type-backport
33
pre-commit
44
pytest
55
pytest-asyncio
6+
pytest-cov
67
pytest-mock

0 commit comments

Comments
 (0)