👷 Add pre-commit GitHub Action workflow (#4895)

Co-authored-by: pre-commit <github-actions@github.com>
This commit is contained in:
Sebastián Ramírez 2022-05-12 11:42:47 -05:00 committed by GitHub
parent 16f1d073db
commit 29df6b3e83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions

43
.github/workflows/autoformat.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Auto Format
on:
pull_request:
types: [opened, synchronize]
jobs:
autoformat:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.10'
- uses: actions/cache@v2
id: cache
with:
path: ${{ env.pythonLocation }}
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01
- name: Install Flit
if: steps.cache.outputs.cache-hit != 'true'
run: pip install flit
- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: flit install --symlink
- uses: actions/cache@v2
id: pre-commit-hooks-cache
with:
path: ~/.cache/pre-commit
key: ${{ runner.os }}-pre-commit-hooks-${{ hashFiles('.pre-commit-config.yaml') }}-v01
- name: Run pre-commit
run: pre-commit run --all-files
- name: Commit pre-commit changes
if: failure()
run: |
git config --global user.name "pre-commit"
git config --global user.email github-actions@github.com
git add --update
git commit -m "🎨 Format code with pre-commit"
git push

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB