Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 Add pre-commit CI config #394

Merged
merged 11 commits into from
May 12, 2022
Next Next commit
👷 Add pre-commit GitHub Action workflow
  • Loading branch information
tiangolo committed May 12, 2022
commit 2c78206362066a6c35decc630492fec8f2e61bff
43 changes: 43 additions & 0 deletions .github/workflows/autoformat.yml
Original file line number Diff line number Diff line change
@@ -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.9'
- 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