39 lines
947 B
YAML
39 lines
947 B
YAML
name: pre-commit
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
pull_request:
|
|
branches:
|
|
- pybind11
|
|
push:
|
|
branches:
|
|
- pybind11
|
|
|
|
jobs:
|
|
pre-commit:
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.10'
|
|
|
|
- name: Install pre-commit
|
|
run: python -m pip install pre-commit
|
|
|
|
- name: Run pre-commit on changed files
|
|
shell: bash
|
|
run: |
|
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
|
base_ref="${{ github.event.pull_request.base.sha }}"
|
|
elif [[ -n "${{ github.event.before }}" && ! "${{ github.event.before }}" =~ ^0+$ ]]; then
|
|
base_ref="${{ github.event.before }}"
|
|
else
|
|
base_ref="$(git rev-parse HEAD~1)"
|
|
fi
|
|
|
|
pre-commit run --show-diff-on-failure --color=always --from-ref "$base_ref" --to-ref "${{ github.sha }}"
|