-
Notifications
You must be signed in to change notification settings - Fork 57
76 lines (63 loc) · 1.93 KB
/
format_test.yml
File metadata and controls
76 lines (63 loc) · 1.93 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
65
66
67
68
69
70
71
72
73
74
75
76
name: Code Format Check
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
format-check:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install Python formatters
run: |
python -m pip install --upgrade pip
pip install black
- name: Install clang-format
run: |
sudo apt-get update
sudo apt-get install -y clang-format
- name: Check clang-format version
run: clang-format --version
- name: Check Black version
run: black --version
- name: Check git status before formatting
run: git status --porcelain
- name: Run make format
run: make format
- name: Check for formatting changes
id: format-check
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "changes=true" >> $GITHUB_OUTPUT
echo "❌ Files were modified by 'make format'"
echo ""
echo "Modified files:"
git status --porcelain
echo ""
echo "Diff:"
git diff
else
echo "changes=false" >> $GITHUB_OUTPUT
echo "✅ No formatting changes needed"
fi
- name: Display formatting instructions
if: steps.format-check.outputs.changes == 'true'
run: |
echo "❌ Code formatting check failed!"
echo ""
echo "To fix all formatting issues, run:"
echo ""
echo " make format"
echo ""
echo "Then commit and push your changes."
- name: Fail if formatting issues found
if: steps.format-check.outputs.changes == 'true'
run: |
echo "Code formatting issues detected. Please run 'make format' to fix them."
exit 1