Skip to content

Commit f5880d0

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

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

.github/workflows/ci.yml

Lines changed: 27 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,35 @@ 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-report=xml \
62+
--cov-report=term
63+
64+
- name: Upload coverage to Codecov
65+
if: ${{ matrix.coverage == true }}
66+
uses: codecov/codecov-action@v5
67+
with:
68+
files: coverage.xml
69+
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
70+
name: codecov-${{ matrix.os }}-${{ matrix.python-version }}
71+
fail_ci_if_error: true
72+
verbose: true
73+
4874
- name: Run pre-commit hooks
4975
uses: pre-commit/[email protected]
5076
if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }}

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)