Skip to content

Add Flake8 configuration, bootstrap script, and formatting tools #8

Add Flake8 configuration, bootstrap script, and formatting tools

Add Flake8 configuration, bootstrap script, and formatting tools #8

Workflow file for this run

name: Format Python Files
on:
push:
branches:
- main # Trigger the workflow on pushes to the 'main' branch
pull_request:
branches:
- main # Trigger the workflow on pull requests to the 'main' branch
jobs:
format:
runs-on: ubuntu-latest # Use the latest Ubuntu runner
steps:
- name: Checkout code
uses: actions/checkout@v2 # Check out the code from the repository
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x' # Use the latest Python 3 version
- name: Install dependencies
run: |
pip install black isort autoflake autopep8 unimport # Install required formatting tools
- name: Run Black (Code Formatter)
run: |
echo "Running black..."
black **/*.py
echo "Black formatting completed."
- name: Run Isort (Import Sorting)
run: |
echo "Running isort..."
isort **/*.py
echo "Isort completed: Imports are now sorted."
- name: Run Autoflake (Remove Unused Imports and Variables)
run: |
echo "Running autoflake..."
autoflake --in-place --remove-all-unused-imports **/*.py
echo "Autoflake completed: Unused imports and variables have been removed."
- name: Run Autopep8 (PEP 8 Formatting)
run: |
echo "Running autopep8..."
autopep8 --in-place --aggressive **/*.py
echo "Autopep8 completed: Code formatted according to PEP 8."
- name: Run Unimport (Remove Unused Imports)
run: |
echo "Running unimport..."
unimport **/*.py
echo "Unimport completed: Unused imports have been removed."
- name: Commit changes
run: |
echo "Committing changes..."
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add .
git commit -m "Automated formatting by GitHub Actions"
git push
# Display success message at the end
- name: Success
run: echo "All formatting commands executed and changes pushed successfully!"