Skip to content

Cluster

Cluster #22

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