File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ # Ruff rewrites quote styles and capitalises docstrings without any help
2+ # from a person, so a contributor should never have to. This hands those
3+ # fixes to the autofix.ci app, which commits them to the pull request
4+ # branch, forks included. The existing lint gate still reports any
5+ # findings that ruff cannot fix.
6+ #
7+ # The filename and the workflow name are both fixed by autofix.ci, which
8+ # uses them to identify the workflow it trusts. Renaming either one stops
9+ # the app from accepting the patch.
10+ name : autofix.ci # needed to securely identify the workflow
11+
12+ on :
13+ pull_request :
14+ push :
15+ branches : [develop, master]
16+
17+ permissions :
18+ contents : read
19+
20+ concurrency :
21+ group : ${{ github.workflow }}-${{ github.ref }}
22+ cancel-in-progress : ${{ github.event_name == 'pull_request' }}
23+
24+ jobs :
25+ autofix :
26+ runs-on : ubuntu-latest
27+ timeout-minutes : 10
28+ steps :
29+ - uses : actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
30+ with :
31+ persist-credentials : false
32+ - uses : astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
33+ with :
34+ python-version : ' 3.13'
35+ - run : uvx --with tox-uv tox -e ruff-fix
36+ - uses : autofix-ci/action@c5b2d67aa2274e7b5a18224e8171550871fc7e4a # v1.3.4
Original file line number Diff line number Diff line change 4545 - uses : astral-sh/setup-uv@v8.2.0
4646 with :
4747 cache-suffix : lint
48+ - name : Apply Ruff fixes to pull requests
49+ if : github.event_name == 'pull_request'
50+ run : uvx --with tox-uv tox -e ruff-fix
4851 - run : uvx --with tox-uv tox -e lint
52+ env :
53+ RUFF_OUTPUT_FORMAT : >-
54+ ${{ github.event_name == 'pull_request' && 'github' || 'full' }}
4955
5056 type-check :
5157 runs-on : ubuntu-latest
Original file line number Diff line number Diff line change @@ -85,3 +85,16 @@ Lastly we test the types using `pyright`:
8585``` bash
8686$ pyright
8787```
88+
89+ ## Automatic formatting
90+
91+ Pull requests apply Ruff fixes before the lint check. With the autofix.ci
92+ app installed for this repository, those fixes are committed to the pull
93+ request branch, including forks. Findings Ruff cannot fix still fail CI.
94+ Push builds check the committed files without applying fixes.
95+
96+ Apply the same fixes locally with:
97+
98+ ``` console
99+ uvx --with tox-uv tox -e ruff-fix
100+ ```
Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ pass_env = COVERAGE_FILE
4646commands = pytest --cov-fail-under =0 {posargs}
4747
4848[testenv:lint]
49+ pass_env = RUFF_OUTPUT_FORMAT
4950runner = uv-venv-runner
5051dependency_groups = dev
5152commands =
@@ -85,3 +86,14 @@ uv_sync_locked = false
8586commands =
8687 coverage erase
8788 pytest --cov =python_utils --cov-report =term-missing --cov-fail-under =100
89+
90+
91+ [testenv:ruff-fix]
92+ labels = fix
93+ description = Apply the available Ruff fixes
94+ skip_install = true
95+ runner = uv-venv-runner
96+ dependency_groups = dev
97+ commands =
98+ ruff check --fix --exit-zero .
99+ ruff format .
You can’t perform that action at this time.
0 commit comments