Skip to content

Use pre-commit for testing style #8

Use pre-commit for testing style

Use pre-commit for testing style #8

Workflow file for this run

name: Suggest style upgrades
#on:
# schedule:
# - cron: "0 0 * * *"
on:
push:
branches:
- main
- 'version-**'
pull_request:
jobs:
update-style:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.11']
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
cache-dependency-path: |
setup.py
pyproject.toml
- name: Install pre-commit
run: pip install pre-commit
- name: Check for updates
run: pre-commit autoupdate
- name: Run style check
run: pre-commit run --all-files --show-diff-on-failure
continue-on-error: true
- name: Check for changes
id: check_for_changes
run: |
if git diff --quiet; then
echo "changes=false" >> "$GITHUB_ENV"
else
echo "changes=true" >> "$GITHUB_ENV"
fi
- name: Add changed files
if: ${{ env.changes == 'true' }}
run: |
git config user.name github_bot
git config user.email [email protected]
git checkout -b update_dependencies
git commit -a -m "Update style dependencies"
- name: Create pull request
if: ${{ env.changes == 'true' }}
run: gh pr create -B main -H update_dependencies --title 'Update style dependencies' --body "Created automatically by GHActions"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}