65 lines
1.4 KiB
YAML
65 lines
1.4 KiB
YAML
name: format
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths:
|
|
- ".clang-format"
|
|
- ".pre-commit-config.yaml"
|
|
- "**/*.py"
|
|
- "pyproject.toml"
|
|
- "include/**"
|
|
- "src/**"
|
|
- "tests/**"
|
|
|
|
pull_request:
|
|
branches: [main]
|
|
paths:
|
|
- ".clang-format"
|
|
- ".pre-commit-config.yaml"
|
|
- "**/*.py"
|
|
- "pyproject.toml"
|
|
- "include/**"
|
|
- "src/**"
|
|
- "tests/**"
|
|
|
|
jobs:
|
|
check:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install uv
|
|
uses: astral-sh/setup-uv@v6
|
|
|
|
- name: Run check
|
|
id: precommit
|
|
run: |
|
|
uv venv
|
|
uv pip install pre-commit
|
|
uv run pre-commit run --all-files
|
|
continue-on-error: true
|
|
|
|
- name: Show diff on failure
|
|
if: steps.precommit.outcome == 'failure'
|
|
run: |
|
|
echo "❌ pre-commit found issues that it auto-fixed."
|
|
echo " Please run 'pre-commit run --all-files' locally,"
|
|
echo " commit the changes, and push again."
|
|
echo ""
|
|
echo "👇 The required changes are shown below:"
|
|
git diff
|
|
|
|
- name: Fail the job if pre-commit failed
|
|
if: steps.precommit.outcome == 'failure'
|
|
run: |
|
|
echo "pre-commit checks failed."
|
|
exit 1
|
|
|
|
- name: Auto correct
|
|
uses: huacnlee/autocorrect-action@main
|
|
with:
|
|
args: --lint ./docs
|