Skip to content

Commit 383b3f1

Browse files
authored
chore: auto-fix fmt + clippy in PR CI instead of failing (#52)
Replace separate fmt-check and clippy jobs with a single lint-fix job that runs `make fix` and commits any changes back to the PR branch.
1 parent a1a1b41 commit 383b3f1

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

.github/workflows/pr.yml

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,38 +55,34 @@ jobs:
5555
- name: cargo test
5656
run: make test
5757

58-
fmt:
59-
name: cargo fmt check
58+
lint-fix:
59+
name: cargo fmt + clippy fix
6060
runs-on: spiceai-macos
6161
timeout-minutes: 60
6262
needs: changes
63-
if: needs.changes.outputs.rust == 'true'
63+
if: needs.changes.outputs.rust == 'true' && github.event_name == 'pull_request'
64+
permissions:
65+
contents: write
6466
steps:
6567
- uses: actions/checkout@v6
66-
67-
- name: Setup Rust toolchain
68-
uses: actions-rust-lang/setup-rust-toolchain@v1
6968
with:
70-
toolchain: 1.91
71-
cache: false # Using GHA cache is slower than re-installing
72-
73-
- name: cargo fmt check
74-
run: make fmt-check
75-
76-
clippy:
77-
name: cargo clippy
78-
runs-on: spiceai-macos
79-
timeout-minutes: 60
80-
needs: changes
81-
if: needs.changes.outputs.rust == 'true'
82-
steps:
83-
- uses: actions/checkout@v6
69+
ref: ${{ github.head_ref }}
70+
token: ${{ secrets.GITHUB_TOKEN }}
8471

8572
- name: Setup Rust toolchain
8673
uses: actions-rust-lang/setup-rust-toolchain@v1
8774
with:
8875
toolchain: 1.91
8976
cache: false # Using GHA cache is slower than re-installing
9077

91-
- name: cargo clippy
92-
run: make clippy
78+
- name: cargo fmt + clippy fix
79+
run: make fix
80+
81+
- name: Commit fixes
82+
run: |
83+
git diff --quiet && exit 0
84+
git config user.name "github-actions[bot]"
85+
git config user.email "github-actions[bot]@users.noreply.github.com"
86+
git add -A
87+
git commit -m "chore: auto-fix cargo fmt + clippy"
88+
git push

0 commit comments

Comments
 (0)