ci: stop rebuilding what has not changed #2210
Workflow file for this run
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
| # SPDX-FileCopyrightText: © 2025 Phala Network <dstack@phala.network> | |
| # | |
| # SPDX-License-Identifier: Apache-2.0 | |
| name: Prek checks | |
| on: | |
| push: | |
| branches: [ next, 'release/**' ] | |
| pull_request: | |
| branches: [ next, 'release/**' ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| prek: | |
| runs-on: ubuntu-latest | |
| env: | |
| RUSTUP_TOOLCHAIN: 1.92.0 | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@master | |
| with: | |
| toolchain: 1.92.0 | |
| components: rustfmt | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Install prek | |
| run: pip install prek | |
| - name: Run prek checks (PR) | |
| if: github.event_name == 'pull_request' | |
| run: prek run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }} --show-diff-on-failure | |
| - name: Run prek checks (push) | |
| if: github.event_name == 'push' | |
| env: | |
| BEFORE: ${{ github.event.before }} | |
| AFTER: ${{ github.event.after }} | |
| run: | | |
| # A push that creates a branch reports an all-zero "before", and a | |
| # force-push can name one this clone no longer has. Neither is a commit, | |
| # so the range would be invalid; check every file instead. | |
| if git rev-parse --verify --quiet "$BEFORE^{commit}" >/dev/null; then | |
| prek run --from-ref "$BEFORE" --to-ref "$AFTER" --show-diff-on-failure | |
| else | |
| echo "no usable base commit ($BEFORE); checking all files" | |
| prek run --all-files --show-diff-on-failure | |
| fi |