Skip to content

Commit ec28a1a

Browse files
Use autofix.ci to apply Ruff formatting
Grant the workflow read-only contents permission and add steps to run ruff format on changed files, then hand any working-tree changes to autofix.ci/action to auto-apply formatting with a commit. Keep the Ruff lint step as a non-auto-fixing check (--no-fix) to avoid unsafe safe-classified fixes like F401 that can break side-effect imports. Include explanatory comments about the autofix.ci setup and behavior.
1 parent bfc2378 commit ec28a1a

1 file changed

Lines changed: 27 additions & 4 deletions

File tree

.github/workflows/lint-backend.yml

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ concurrency:
1414
group: lint-backend-${{ github.ref }}
1515
cancel-in-progress: true
1616

17+
# autofix.ci's GitHub App handles writes to the PR branch independently of
18+
# the workflow token, so the job itself only needs read access. Setup:
19+
# install https://github.com/apps/autofix-ci on the repo (free for public
20+
# repos) and enable auto-apply in the autofix.ci dashboard.
21+
permissions:
22+
contents: read
23+
1724
jobs:
1825
lint:
1926
name: Ruff and mypy on changed files
@@ -55,13 +62,29 @@ jobs:
5562
# Pass as a single space-separated string to subsequent steps.
5663
echo "files=${files[*]}" >> "$GITHUB_OUTPUT"
5764
58-
- name: Ruff (auto-fix dry run + format check)
65+
- name: Ruff format (in-place)
66+
if: steps.changed.outputs.files != ''
67+
run: uv run ruff format ${{ steps.changed.outputs.files }}
68+
69+
# Hands any working-tree changes from the previous step to autofix.ci.
70+
# In auto-apply mode the App pushes a commit back to the PR branch;
71+
# the action exits non-zero on the run that produced the diff, then
72+
# the App's commit triggers a fresh CI cycle that passes.
73+
- name: Apply ruff format autofix via autofix.ci
74+
if: steps.changed.outputs.files != ''
75+
uses: autofix-ci/action@v1.3.1
76+
with:
77+
commit-message: "style: ruff format (auto)"
78+
79+
- name: Ruff lint (no autofix)
5980
if: steps.changed.outputs.files != ''
6081
run: |
61-
# `--no-fix` reports the same set of issues that `--fix` would
62-
# apply, so the developer sees what to run locally to clean up.
82+
# Lint violations still fail the build. Auto-fixing lint
83+
# ("ruff check --fix") is intentionally NOT enabled here —
84+
# safe-classified fixes still include things like F401 (unused
85+
# imports), which can break side-effect imports used by the
86+
# connector registration pattern.
6387
uv run ruff check --no-fix --output-format=github ${{ steps.changed.outputs.files }}
64-
uv run ruff format --check ${{ steps.changed.outputs.files }}
6588
6689
- name: Mypy
6790
if: steps.changed.outputs.files != ''

0 commit comments

Comments
 (0)