Cleanup repository: improve .gitignore and remove coverage files #3
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: Tests and Coverage | |
| on: | |
| push: | |
| branches: [ master, main ] | |
| pull_request: | |
| branches: [ master, main ] | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| pip install pytest pytest-cov coverage coverage-badge faker | |
| - name: Run tests with coverage | |
| run: | | |
| python -m pytest --cov=autobasedoc --cov-report=xml --cov-report=term-missing | |
| - name: Generate coverage badge | |
| if: matrix.python-version == '3.12' | |
| run: | | |
| coverage-badge -o coverage.svg | |
| - name: Upload coverage to Codecov | |
| if: matrix.python-version == '3.12' | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: true | |
| - name: Commit coverage badge | |
| if: matrix.python-version == '3.12' && github.ref == 'refs/heads/master' | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| git add coverage.svg | |
| git diff --staged --quiet || git commit -m "Update coverage badge" | |
| git push |