From 7bacca9b625c2a658470afd99a0bf0aa0b4f1dbb Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sun, 11 Jan 2026 14:17:10 -0500 Subject: [PATCH] Use prek in documentation and CI (#22505) ## Summary AFAIK, many of us on the team are using prek now. It seems appropriate to modify the docs to formalize it. --- .devcontainer/post-create.sh | 2 +- .github/actionlint.yaml | 2 +- .github/renovate.json5 | 4 ++-- .github/workflows/ci.yaml | 18 +++++++++--------- .pre-commit-config.yaml | 4 ++-- CLAUDE.md | 2 +- CONTRIBUTING.md | 10 +++++----- crates/ty/CONTRIBUTING.md | 8 ++++---- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.devcontainer/post-create.sh b/.devcontainer/post-create.sh index 0a81beacfd..31e22a56d7 100755 --- a/.devcontainer/post-create.sh +++ b/.devcontainer/post-create.sh @@ -5,4 +5,4 @@ rustup component add clippy rustfmt cargo install cargo-insta cargo fetch -pip install maturin pre-commit +pip install maturin prek diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index 13f2d069d8..370f903f43 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -1,4 +1,4 @@ -# Configuration for the actionlint tool, which we run via pre-commit +# Configuration for the actionlint tool, which we run via prek # to verify the correctness of the syntax in our GitHub Actions workflows. self-hosted-runner: diff --git a/.github/renovate.json5 b/.github/renovate.json5 index c6a8b29a76..0ba62bd5d1 100644 --- a/.github/renovate.json5 +++ b/.github/renovate.json5 @@ -76,9 +76,9 @@ enabled: false, }, { - groupName: "pre-commit dependencies", + groupName: "prek dependencies", matchManagers: ["pre-commit"], - description: "Weekly update of pre-commit dependencies", + description: "Weekly update of prek dependencies", }, { groupName: "NPM Development dependencies", diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 39d00aba76..cfa99b6e4e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -769,8 +769,8 @@ jobs: - name: "Remove wheels from cache" run: rm -rf target/wheels - pre-commit: - name: "pre-commit" + prek: + name: "prek" runs-on: ${{ github.repository == 'astral-sh/ruff' && 'depot-ubuntu-22.04-16' || 'ubuntu-latest' }} timeout-minutes: 10 steps: @@ -784,17 +784,17 @@ jobs: - uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0 with: node-version: 24 - - name: "Cache pre-commit" + - name: "Cache prek" uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1 with: - path: ~/.cache/pre-commit - key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} - - name: "Run pre-commit" + path: ~/.cache/prek + key: prek-${{ hashFiles('.pre-commit-config.yaml') }} + - name: "Run prek" run: | echo '```console' > "$GITHUB_STEP_SUMMARY" - # Enable color output for pre-commit and remove it for the summary - # Use --hook-stage=manual to enable slower pre-commit hooks that are skipped by default - SKIP=cargo-fmt uvx --python="${PYTHON_VERSION}" pre-commit run --all-files --show-diff-on-failure --color=always --hook-stage=manual | \ + # Enable color output for prek and remove it for the summary + # Use --hook-stage=manual to enable slower hooks that are skipped by default + SKIP=cargo-fmt uvx prek run --all-files --show-diff-on-failure --color always --hook-stage manual | \ tee >(sed -E 's/\x1B\[([0-9]{1,2}(;[0-9]{1,2})*)?[mGK]//g' >> "$GITHUB_STEP_SUMMARY") >&1 exit_code="${PIPESTATUS[0]}" echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a22d266fed..2b1888e58c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -119,8 +119,8 @@ repos: - id: actionlint stages: # This hook is disabled by default, since it's quite slow. - # To run all hooks *including* this hook, use `uvx pre-commit run -a --hook-stage=manual`. - # To run *just* this hook, use `uvx pre-commit run -a actionlint --hook-stage=manual`. + # To run all hooks *including* this hook, use `uvx prek run -a --hook-stage=manual`. + # To run *just* this hook, use `uvx prek run -a actionlint --hook-stage=manual`. - manual args: - "-ignore=SC2129" # ignorable stylistic lint from shellcheck diff --git a/CLAUDE.md b/CLAUDE.md index fd0b794b5d..9fece77e27 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -65,7 +65,7 @@ When working on ty, PR titles should start with `[ty]` and be tagged with the `t - All changes must be tested. If you're not testing your changes, you're not done. - Get your tests to pass. If you didn't run the tests, your code does not work. - Follow existing code style. Check neighboring files for patterns. -- Always run `uvx pre-commit run -a` at the end of a task. +- Always run `uvx prek run -a` at the end of a task. - Avoid writing significant amounts of new code. This is often a sign that we're missing an existing method or mechanism that could help solve the problem. Look for existing utilities first. - Avoid falling back to patterns that require `panic!`, `unreachable!`, or `.unwrap()`. Instead, try to encode those constraints in the type system. - Prefer let chains (`if let` combined with `&&`) over nested `if let` statements to reduce indentation and improve readability. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1851d45199..435e75612b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,12 +53,12 @@ cargo install cargo-insta You'll need [uv](https://docs.astral.sh/uv/getting-started/installation/) (or `pipx` and `pip`) to run Python utility commands. -You can optionally install pre-commit hooks to automatically run the validation checks +You can optionally install hooks to automatically run the validation checks when making a commit: ```shell -uv tool install pre-commit -pre-commit install +uv tool install prek +prek install ``` We recommend [nextest](https://nexte.st/) to run Ruff's test suite (via `cargo nextest run`), @@ -85,7 +85,7 @@ and that it passes both the lint and test validation checks: ```shell cargo clippy --workspace --all-targets --all-features -- -D warnings # Rust linting RUFF_UPDATE_SCHEMA=1 cargo test # Rust testing and updating ruff.schema.json -uvx pre-commit run --all-files --show-diff-on-failure # Rust and Python formatting, Markdown and Python linting, etc. +uvx prek run -a # Rust and Python formatting, Markdown and Python linting, etc. ``` These checks will run on GitHub Actions when you open your pull request, but running them locally @@ -381,7 +381,7 @@ Commit each step of this process separately for easier review. - Often labels will be missing from pull requests they will need to be manually organized into the proper section - Changes should be edited to be user-facing descriptions, avoiding internal details - - Square brackets (eg, `[ruff]` project name) will be automatically escaped by `pre-commit` + - Square brackets (eg, `[ruff]` project name) will be automatically escaped by `prek` Additionally, for minor releases: diff --git a/crates/ty/CONTRIBUTING.md b/crates/ty/CONTRIBUTING.md index 06de712bfc..6633a7a7cf 100644 --- a/crates/ty/CONTRIBUTING.md +++ b/crates/ty/CONTRIBUTING.md @@ -34,12 +34,12 @@ cargo install cargo-insta You'll need [uv](https://docs.astral.sh/uv/getting-started/installation/) (or `pipx` and `pip`) to run Python utility commands. -You can optionally install pre-commit hooks to automatically run the validation checks +You can optionally install hooks to automatically run the validation checks when making a commit: ```shell -uv tool install pre-commit -pre-commit install +uv tool install prek +prek install ``` We recommend [nextest](https://nexte.st/) to run ty's test suite (via `cargo nextest run`), @@ -66,7 +66,7 @@ and that it passes both the lint and test validation checks: ```shell cargo clippy --workspace --all-targets --all-features -- -D warnings # Rust linting cargo test # Rust testing -uvx pre-commit run --all-files --show-diff-on-failure # Rust and Python formatting, Markdown and Python linting, etc. +uvx prek run -a # Rust and Python formatting, Markdown and Python linting, etc. ``` These checks will run on GitHub Actions when you open your pull request, but running them locally