Add test coverage badge. #5
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
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # <-- REQUIRED: Allows the action to commit the badge SVG | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| # Fetch history for commit step | |
| with: | |
| fetch-depth: 0 # IMPORTANT: Ensures full history for committing changes | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies and coverage | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e . | |
| pip install coverage | |
| - name: Run tests and collect coverage | |
| run: coverage run --include="signifikante/*" -m unittest discover -s tests -v | |
| - name: Generate Coverage Badge 🖼️ | |
| # This action reads the .coverage file and creates coverage.svg | |
| uses: tj-actions/coverage-badge-py@v2 | |
| - name: Commit and Push Badge | |
| # Only commit the change if a badge file was created/updated | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: 'CI: update coverage badge' | |
| files: coverage.svg | |