Skip to content

Commit 996f2bb

Browse files
Add linting workflow using Black for code formatting
1 parent d9cb24e commit 996f2bb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

.github/workflows/pre-commit.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: pre-commit
2+
3+
on: pull_request
4+
5+
jobs:
6+
black-format:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v3
10+
with:
11+
ref: ${{ github.ref }}
12+
- uses: actions/setup-python@v3
13+
- name: Install uv
14+
run: pip install uv
15+
- name: Run black via uv
16+
run: uvx black .
17+
- name: Commit and push changes
18+
if: !contains(github.event.head_commit.message , 'Apply black formatting')
19+
run: |
20+
git config --global user.name "github-actions[bot]"
21+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
22+
git add .
23+
git diff --cached --quiet || git commit -m "Apply black formatting"
24+
git push origin HEAD:${{ github.head_ref }}

0 commit comments

Comments
 (0)