-
Notifications
You must be signed in to change notification settings - Fork 2
64 lines (52 loc) · 1.88 KB
/
code_formatter.yml
File metadata and controls
64 lines (52 loc) · 1.88 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: Code Formatter
on:
push:
branches:
- main
paths:
- '**/*.py'
- '.github/workflows/code_formatter.yml'
jobs:
format_code:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: pip install ruff
- name: Run Ruff Linter (with auto-fix)
run: ruff check $(git ls-files '*.py') --fix --target-version py310 --select ALL --no-preview || true
- name: Run Ruff Formatter
run: ruff format $(git ls-files '*.py') --target-version py310 --line-length 360 --no-preview || true
- name: Check for changes
id: changes
run: |
if git diff --quiet; then
echo "has_changes=false" >> "$GITHUB_OUTPUT"
else
echo "has_changes=true" >> "$GITHUB_OUTPUT"
fi
- name: Create Pull Request
if: steps.changes.outputs.has_changes == 'true'
uses: peter-evans/create-pull-request@v7
with:
commit-message: "style(ruff): automatic code formatting"
title: "🎨 Automatic Code Formatting"
body: |
This Pull Request was created automatically by GitHub Actions to apply unified code style standards.
🔧 Formatting performed using [`Ruff`](https://github.com/astral-sh/ruff):
> - Automatic style and linting fixes (`ruff check --fix`)
> - Formatter applied (`ruff format`)
✨ Changes only affect code style, program logic remains unchanged.
> Target Python version: **3.10**
branch: "formatter/${{ github.ref_name }}"
delete-branch: true