Merge pull request #695 from OtowoOrg/dependabot/docker/lukemathwalke… #423
This file contains hidden or 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: Pre-commit Hooks | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| concurrency: | |
| group: pre-commit-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| pre-commit: | |
| name: Pre-commit Hooks | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Rust | |
| uses: ./.github/actions/setup-rust | |
| with: | |
| cache-key: "pre-commit" | |
| components: "rustfmt clippy" | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.x" | |
| - name: Install pre-commit | |
| run: pip install pre-commit | |
| - name: Run pre-commit | |
| run: | | |
| if [[ "${{ github.event_name }}" == "pull_request" ]]; then | |
| BASE_SHA="${{ github.event.pull_request.base.sha }}" | |
| HEAD_SHA="${{ github.event.pull_request.head.sha }}" | |
| git fetch --no-tags origin "$BASE_SHA" "$HEAD_SHA" | |
| pre-commit run \ | |
| --from-ref "$BASE_SHA" \ | |
| --to-ref "$HEAD_SHA" \ | |
| --show-diff-on-failure | |
| else | |
| pre-commit run --all-files --show-diff-on-failure | |
| fi |