github action renovate #106
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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| pull_request: | |
| branches: | |
| - main | |
| - master | |
| env: | |
| LANG: "en_US.utf-8" | |
| LC_ALL: "en_US.utf-8" | |
| PYTHONIOENCODING: "UTF-8" | |
| jobs: | |
| test: | |
| name: Tests (Python ${{ matrix.python-version }}) | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y graphviz imagemagick | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Install just | |
| uses: extractions/setup-just@v2 | |
| with: | |
| just-version: "latest" | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Run tests with coverage | |
| run: | | |
| uv run coverage run --rcfile=config/coverage.pytest.ini -m pytest tests -c config/pytest.ini | |
| uv run coverage combine | |
| uv run coverage report --precision=2 | |
| uv run coverage xml | |
| - name: Upload coverage to Codecov | |
| uses: codecov/codecov-action@v4 | |
| with: | |
| file: ./coverage.xml | |
| fail_ci_if_error: false | |
| docs: | |
| name: Build and Deploy Documentation | |
| runs-on: ubuntu-latest | |
| needs: test | |
| # Only run on main/master branch pushes | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for git-changelog | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y graphviz imagemagick | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Install just | |
| uses: extractions/setup-just@v2 | |
| with: | |
| just-version: "latest" | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Build documentation | |
| run: just docs | |
| - name: Deploy to GitHub Pages | |
| uses: peaceiris/actions-gh-pages@v4 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| publish_dir: ./site | |
| cname: ${{ vars.DOCS_CNAME }} # Optional: set this in repository variables if you have a custom domain | |
| coverage-badge: | |
| name: Update Coverage Badge | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y graphviz imagemagick | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v4 | |
| with: | |
| version: "latest" | |
| - name: Install just | |
| uses: extractions/setup-just@v2 | |
| with: | |
| just-version: "latest" | |
| - name: Install dependencies | |
| run: uv sync | |
| - name: Generate coverage report | |
| run: | | |
| uv run coverage run --rcfile=config/coverage.pytest.ini -m pytest tests -c config/pytest.ini | |
| uv run coverage combine | |
| uv run coverage report --precision=2 > coverage_report.txt | |
| - name: Extract coverage percentage | |
| id: coverage | |
| run: | | |
| COVERAGE=$(grep "TOTAL" coverage_report.txt | awk '{print $4}' | sed 's/%//') | |
| echo "percentage=$COVERAGE" >> $GITHUB_OUTPUT | |
| - name: Create coverage badge | |
| uses: schneegans/dynamic-badges-action@v1.7.0 | |
| with: | |
| auth: ${{ secrets.GITHUB_TOKEN }} | |
| gistID: ${{ vars.COVERAGE_GIST_ID }} # Set this in repository variables | |
| filename: docutools-coverage.json | |
| label: Coverage | |
| message: ${{ steps.coverage.outputs.percentage }}% | |
| color: ${{ steps.coverage.outputs.percentage > 80 && 'green' || steps.coverage.outputs.percentage > 60 && 'yellow' || 'red' }} |