Lint code #31
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
# Lint code and (optionally) apply fixes | |
name: Lint code | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
schedule: | |
- cron: 0 0 * * 1 # Every monday | |
workflow_dispatch: | |
jobs: | |
auto-update: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install pre-commit | |
run: pip install pre-commit | |
- name: Run autoupdate | |
run: pre-commit autoupdate | |
- name: Create a pull request with updated versions | |
uses: peter-evans/create-pull-request@v5 | |
with: | |
branch: update/pre-commit-hooks | |
title: 'chore(deps): update pre-commit hooks' | |
commit-message: 'chore(deps): update pre-commit hooks' | |
pre-commit: | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name != 'schedule' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install PDM | |
uses: pdm-project/setup-pdm@v3 | |
with: | |
python-version: '3.11' | |
cache: true | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
- name: Install dependencies | |
run: | | |
pdm install -G test,github-action | |
- name: Run pre-commit hooks | |
uses: pre-commit/action@v3.0.0 | |
- name: Apply fixes when present | |
uses: pre-commit-ci/lite-action@v1.0.1 | |
if: always() | |
with: | |
msg: 'chore(fmt): auto fixes from pre-commit hooks' |