Merge pull request #433 from MTrab:dependabot/pip/ruff-0.0.289 #162
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Format code | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- master | |
jobs: | |
format: | |
name: Format with black and isort | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4.7.0 | |
with: | |
python-version: 3.11 | |
- name: Cache | |
uses: actions/cache@v3.3.2 | |
with: | |
path: ~/.cache/pip | |
key: pip-format | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip wheel | |
python -m pip install --upgrade black isort | |
- name: Pull again | |
run: git pull || true | |
- name: Run formatting | |
run: | | |
python -m isort -v --multi-line 3 --trailing-comma -l 88 --recursive . | |
python -m black -v . | |
- name: Commit files | |
run: | | |
if [ $(git diff HEAD | wc -l) -gt 30 ] | |
then | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config user.name "GitHub Actions" | |
git commit -m "Run formatting" -a || true | |
git push || true | |
fi |