feat: add coverage badge and HTML report to GitHub Pages #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Run tests | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install UV | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| enable-cache: true | |
| python-version: ${{ matrix.python-version }} | |
| - run: uv sync --locked --all-extras --dev | |
| - name: Run tests with coverage | |
| if: matrix.python-version == '3.13' | |
| run: uv run pytest tests/ --cov=package_name --cov-report=html --cov-report=xml | |
| - name: Run tests without coverage | |
| if: matrix.python-version != '3.13' | |
| run: uv run pytest tests/ | |
| - name: Generate coverage badge | |
| if: matrix.python-version == '3.13' | |
| run: uv run genbadge coverage -i coverage.xml -o coverage-badge.svg | |
| - name: Upload coverage HTML report | |
| if: matrix.python-version == '3.13' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-report | |
| path: htmlcov/ | |
| - name: Upload coverage badge | |
| if: matrix.python-version == '3.13' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-badge | |
| path: coverage-badge.svg |