ci: integrate Codecov and pytest-cov (#405)

This commit is contained in:
Filip Christiansen 2025-07-13 16:44:01 +02:00 committed by GitHub
parent fa2e192c05
commit 03b015059c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 32 additions and 1 deletions

View file

@ -18,6 +18,11 @@ jobs:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
include:
- os: ubuntu-latest
python-version: "3.13"
coverage: true
steps:
- uses: actions/checkout@v4
@ -25,6 +30,7 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Locate pip cache
id: pip-cache
shell: bash
@ -36,15 +42,37 @@ jobs:
path: ${{ steps.pip-cache.outputs.dir }}
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
restore-keys: ${{ runner.os }}-pip-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install ".[dev]"
- name: Run tests
if: ${{ matrix.coverage != true }}
run: pytest
# Run pre-commit only on Python 3.13 + ubuntu.
- name: Run tests and collect coverage
if: ${{ matrix.coverage == true }}
run: |
pytest \
--cov=gitingest \
--cov=server \
--cov-branch \
--cov-report=xml \
--cov-report=term
- name: Upload coverage to Codecov
if: ${{ matrix.coverage == true }}
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage.xml
flags: ${{ matrix.os }}-py${{ matrix.python-version }}
name: codecov-${{ matrix.os }}-${{ matrix.python-version }}
fail_ci_if_error: true
verbose: true
- name: Run pre-commit hooks
uses: pre-commit/action@v3.0.1
if: ${{ matrix.python-version == '3.13' && matrix.os == 'ubuntu-latest' }}

View file

@ -11,6 +11,7 @@
<br>
<!-- row 2 — quality & community -->
<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>
<!-- <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> -->
<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>
<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>
<br>

View file

@ -42,6 +42,7 @@ dev = [
"pre-commit",
"pytest",
"pytest-asyncio",
"pytest-cov",
"pytest-mock",
]

View file

@ -3,4 +3,5 @@ eval-type-backport
pre-commit
pytest
pytest-asyncio
pytest-cov
pytest-mock