-
Notifications
You must be signed in to change notification settings - Fork 591
executable file
·44 lines (41 loc) · 1.44 KB
/
lint.yml
File metadata and controls
executable file
·44 lines (41 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
name: Lint
on:
push:
branches: [main]
pull_request:
permissions:
contents: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
ref: ${{ github.event.pull_request.head.ref || github.ref_name }}
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit (autofix)
run: pre-commit run --all-files || true
- name: Commit fixes if any
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
run: |
git diff --quiet && exit 0
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "style: auto-fix lint (black + isort)"
git push
- name: Ensure lint leaves clean tree
run: |
git diff --quiet && exit 0
echo "Lint generated changes that could not be auto-pushed in this context."
echo "Please run 'pre-commit run --all-files' locally and push the fixes."
git --no-pager diff --name-only
exit 1