Skip to content

Commit cf5b651

Browse files
authored
Update main.yml
1 parent e15f7b1 commit cf5b651

File tree

1 file changed

+17
-46
lines changed

1 file changed

+17
-46
lines changed

.github/workflows/main.yml

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,25 @@ on: [push, pull_request]
55
jobs:
66
format:
77
runs-on: ubuntu-latest
8-
8+
99
steps:
10-
- name: Checkout repository
11-
uses: actions/checkout@v2
12-
10+
- uses: actions/checkout@v3
11+
with:
12+
ref: ${{ github.head_ref }}
13+
1314
- name: Set up Python
14-
uses: actions/setup-python@v2
15+
uses: actions/setup-python@v3
1516
with:
1617
python-version: '3.x'
17-
18-
- name: Install yapf
19-
run: pip install yapf
20-
21-
- name: Run yapf on each file
22-
run: |
23-
python - <<EOF
24-
import subprocess
25-
26-
files = [
27-
'./files/__init__.py',
28-
'./files/file_manager.py',
29-
'./files/error_handler.py',
30-
'./main.py',
31-
'./connections/server.py',
32-
'./connections/client.py',
33-
'./connections/new_connection.py',
34-
'./connections/__init__.py',
35-
'./connections/connection_management.py',
36-
'./test.py',
37-
'./session/session_manager.py'
38-
]
39-
40-
for file in files:
41-
try:
42-
subprocess.run(['yapf', '--in-place', '--style=google', file], check=True)
43-
print(f"Formatted {file}")
44-
except subprocess.CalledProcessError as e:
45-
print(f"Skipping {file} due to yapf error: {e}")
46-
except Exception as e:
47-
print(f"Unexpected error occurred while formatting {file}: {e}")
48-
EOF
49-
18+
19+
- name: Install black
20+
run: pip install black
21+
22+
- name: Format with black
23+
run: black .
24+
5025
- name: Commit changes
51-
run: |
52-
git config --global user.name 'github-actions[bot]'
53-
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
54-
git add .
55-
git commit -m 'Auto-format Python code with yapf' || echo "No changes to commit"
56-
git push
57-
env:
58-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
uses: stefanzweifel/git-auto-commit-action@v4
27+
with:
28+
commit_message: "style: auto-format Python code with black"
29+
branch: ${{ github.head_ref }}

0 commit comments

Comments
 (0)