Skip to content

Commit

Permalink
Add auto style code CI
Browse files Browse the repository at this point in the history
  • Loading branch information
rbonghi committed Jan 14, 2025
1 parent d281879 commit 19b7ec5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build-and-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,40 @@ env:
# https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions

jobs:
auto_style:
name: Auto style code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install autopep8
run: |
python -m pip install --upgrade pip
pip install flake8 autopep8
- name: Auto style code with autopep8
run: autopep8 --in-place --aggressive --aggressive --max-line-length 180 .
- name: Check for changes
run: |
if [[ `git status --porcelain` ]]; then
echo "There are changes after auto-styling the code."
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 "Auto style code with autopep8"
exit 1
else
echo "No changes detected."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build:
name: Test on python ${{ matrix.python-version }}
runs-on: ubuntu-latest
needs: [auto_style]
strategy:
# max-parallel: 1
matrix:
Expand Down

0 comments on commit 19b7ec5

Please sign in to comment.