From b9d127223446ef14a4a57ada9945a127b544ed39 Mon Sep 17 00:00:00 2001 From: Edwin Jose Date: Fri, 5 Dec 2025 20:30:48 -0500 Subject: [PATCH] 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. --- .github/workflows/autofix.yml | 64 +++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/autofix.yml diff --git a/.github/workflows/autofix.yml b/.github/workflows/autofix.yml new file mode 100644 index 00000000..4199e146 --- /dev/null +++ b/.github/workflows/autofix.yml @@ -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 +