-
Notifications
You must be signed in to change notification settings - Fork 2
48 lines (41 loc) · 1.13 KB
/
formatting_check.yml
File metadata and controls
48 lines (41 loc) · 1.13 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
name: Code Formatting Check
on:
pull_request:
paths:
- '**.py'
jobs:
autopep8-check:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.x
- name: Print Python version
run: python --version
- name: Install autopep8
run: pip install autopep8
- name: Print autopep8 version
run: autopep8 --version
- name: Check code formatting
run: |
FILES=$(find . -name "*.py")
echo "Files being checked:"
echo "$FILES"
echo "-----------------------------"
FORMAT_ISSUES=0
for file in $FILES; do
DIFF=$(autopep8 --diff $file)
if [[ ! -z "$DIFF" ]]; then
echo "Formatting issue detected in: $file"
echo "$DIFF"
echo "-----------------------------"
FORMAT_ISSUES=1
fi
done
if [[ $FORMAT_ISSUES -eq 1 ]]; then
echo "Code is not formatted properly in one or more files."
exit 1
fi