Add autofix workflow for Python code

Introduces a GitHub Actions workflow that runs on pushes to main and manual dispatch. The workflow syncs dependencies with uv, runs ruff for linting and formatting, and commits any fixes automatically.
This commit is contained in:
Edwin Jose 2025-12-05 20:30:48 -05:00
parent 7a2f33509d
commit b9d1272234

64
.github/workflows/autofix.yml vendored Normal file
View file

@ -0,0 +1,64 @@
name: Autofix (uv sync, ruff check & format)
on:
push:
branches:
- main
paths:
- 'pyproject.toml'
- '**/*.py'
workflow_dispatch:
jobs:
autofix:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Sync dependencies and update uv.lock
run: uv sync
- name: Install ruff
run: uv pip install ruff
- name: Run ruff check with fixes
run: ruff check --fix .
continue-on-error: true
- name: Run ruff format
run: ruff format .
- name: Check for changes
id: changes
run: |
if git diff --quiet; then
echo "changed=false" >> $GITHUB_OUTPUT
echo "No changes detected"
else
echo "changed=true" >> $GITHUB_OUTPUT
echo "Changes detected:"
git diff --stat
fi
- name: Commit and push changes
if: steps.changes.outputs.changed == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add -A
git commit -m "chore: autofix - uv sync, ruff check & format [skip ci]"
git push