Build(deps): bump pygments from 2.19.2 to 2.20.0 (#19) #82
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" ] | |
| permissions: | |
| contents: write | |
| jobs: | |
| # Job to check which files have changed | |
| check-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| python: ${{ steps.filter.outputs.python }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| # Pinned to SHA for security | |
| - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2 | |
| id: filter | |
| with: | |
| filters: | | |
| python: | |
| - '**.py' | |
| - 'requirements.in' | |
| - 'requirements.txt' | |
| - 'pyproject.toml' | |
| - '.github/workflows/ci.yml' | |
| test-matrix: | |
| needs: check-changes | |
| if: needs.check-changes.outputs.python == 'true' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"] | |
| fail-fast: false | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| allow-prereleases: true | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| if [ -f requirements.in ]; then | |
| pip install -r requirements.in | |
| elif [ -f requirements.txt ]; then | |
| pip install -r requirements.txt | |
| fi | |
| pip install pytest | |
| - name: Test with Pytest | |
| run: pytest tests/ | |
| - name: Record Success | |
| if: success() | |
| run: echo "${{ matrix.python-version }}" > python_version_${{ matrix.python-version }}.txt | |
| - name: Upload Success Artifact | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: passed-version-${{ matrix.python-version }} | |
| path: python_version_${{ matrix.python-version }}.txt | |
| finalize-updates: | |
| needs: test-matrix | |
| runs-on: ubuntu-latest | |
| if: always() && needs.test-matrix.result != 'skipped' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: artifacts | |
| pattern: passed-version-* | |
| merge-multiple: true | |
| - name: Determine Supported Range | |
| id: versions | |
| run: | | |
| if [ -z "$(ls -A artifacts)" ]; then | |
| echo "No versions passed! Failing job." | |
| exit 1 | |
| fi | |
| echo "Found artifact files:" | |
| ls -l artifacts/ | |
| cat artifacts/*.txt > all_versions.txt | |
| sort -V all_versions.txt -o sorted_versions.txt | |
| MIN_VER=$(head -n 1 sorted_versions.txt) | |
| MAX_VER=$(tail -n 1 sorted_versions.txt) | |
| echo "Calculated Range: $MIN_VER - $MAX_VER" | |
| echo "MIN_VER=$MIN_VER" >> $GITHUB_ENV | |
| echo "MAX_VER=$MAX_VER" >> $GITHUB_ENV | |
| - name: Set up Utility Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Update README | |
| run: python tools/update_readme.py "${{ env.MIN_VER }}" "${{ env.MAX_VER }}" | |
| - name: Set up Lowest Python (${{ env.MIN_VER }}) | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ env.MIN_VER }} | |
| allow-prereleases: true | |
| - name: Compile requirements.txt | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install pip-tools | |
| pip-compile requirements.in --output-file requirements.txt --resolver=backtracking | |
| - name: Set up Python for Linting | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Ruff Format & Fix | |
| run: | | |
| pip install ruff | |
| ruff check . --fix | |
| ruff format . | |
| - name: Verify Builder (PyInstaller) | |
| run: | | |
| pip install pyinstaller | |
| pip install -r requirements.txt | |
| python build.py | |
| - name: Construct Commit Message | |
| id: commit_msg | |
| run: | | |
| MSG="" | |
| # Check for README changes | |
| if ! git diff --quiet README.md; then | |
| MSG="$MSG update supported python versions (${{ env.MIN_VER }}-${{ env.MAX_VER }});" | |
| fi | |
| # Check for requirements changes | |
| if ! git diff --quiet requirements.txt; then | |
| MSG="$MSG update requirements.txt;" | |
| fi | |
| # Check for code changes (linting/formatting) | |
| if ! git diff --quiet -- . ':(exclude)README.md' ':(exclude)requirements.txt'; then | |
| MSG="$MSG fix linting/formatting;" | |
| fi | |
| # Clean up message | |
| if [ -z "$MSG" ]; then | |
| echo "HAS_CHANGES=false" >> $GITHUB_ENV | |
| else | |
| # Remove trailing semicolon | |
| MSG=${MSG%;} | |
| echo "COMMIT_MSG=chore: $MSG" >> $GITHUB_ENV | |
| echo "HAS_CHANGES=true" >> $GITHUB_ENV | |
| fi | |
| - name: Commit and Push changes | |
| if: ${{ env.HAS_CHANGES == 'true' }} | |
| env: | |
| REF_NAME: ${{ github.head_ref || github.ref_name }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add README.md requirements.txt | |
| # Recursive add for all python files (Comprehensive approach) | |
| git add "**/*.py" | |
| git commit -m "${{ env.COMMIT_MSG }}" | |
| git push origin HEAD:"$REF_NAME" |