diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f4bc1935..caa7ca73 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -29,7 +29,7 @@ repos: additional_dependencies: [black==24.*] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.15.13" + rev: "v0.15.14" hooks: - id: ruff-check args: ["--fix", "--show-fixes"] @@ -67,7 +67,7 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/crate-ci/typos - rev: "v1.46.2" + rev: "v1.46.3" hooks: - id: typos exclude: ^Gemfile\.lock$ diff --git a/docs/pages/guides/gha_basic.md b/docs/pages/guides/gha_basic.md index 387c7c36..a161cd96 100644 --- a/docs/pages/guides/gha_basic.md +++ b/docs/pages/guides/gha_basic.md @@ -53,13 +53,28 @@ you use a develop branch, you probably will want to include that. You can also specify specific branches for pull requests instead of running on all PRs (will run on PRs targeting those branches only). -## Pre-commit +## Prek / Pre-commit -If you use [pre-commit](https://pre-commit.com) (and you should), and you don't -want to / can't use [pre-commit.ci](https://pre-commit.ci) yet, then this is a -job that will check pre-commit for you: +If you use [prek][] or [pre-commit][] in CI, you can run it directly in GitHub +Actions. Prek is a faster Rust rewrite of pre-commit that supports most real +world usage and supports the same configuration and hooks. -{% raw %} +{% tabs runner %} {% tab prek Prek %} + +Prek can run using the official action: + +```yaml +lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + - uses: j178/prek-action@v2 +``` + +{% endtab %} {% tab pre-commit Pre-commit %} + +Pre-commit can run using the official action: ```yaml lint: @@ -73,7 +88,7 @@ lint: - uses: pre-commit/action@v3.0.1 ``` -{% endraw %} +{% endtab %} {% endtabs %} If you do use [pre-commit.ci](https://pre-commit.ci), but you need this job to run a manual check, like check-manifest, then you can keep it but just use @@ -757,6 +772,10 @@ changelog: -[gh-changelog]: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes +[pre-commit]: https://pre-commit.com +[prek]: https://github.com/j178/prek +[gh-changelog]: https://docs.github.com/en/repositories/releasing-projects + + diff --git a/docs/pages/guides/style.md b/docs/pages/guides/style.md index 97beb53c..9f4878e7 100644 --- a/docs/pages/guides/style.md +++ b/docs/pages/guides/style.md @@ -17,7 +17,15 @@ custom_title: Style and static checks to check code style. The original, `pre-commit`, has support for more languages, but `prek` is a faster Rust rewrite that supports most real world usage. -{% tabs runner %} {% tab pre-commit Pre-commit %} +{% tabs runner %} {% tab prek Prek %} + +Prek can be installed through `brew` (macOS) or `pipx/uv` (anywhere). There are +two modes to use it locally; you can check manually with `prek run` (changes +only) or `prek run -a` (all). You can omit the `run`, as well; such as +`prek -a`. You can also run `prek install` to add checks as a git pre-commit +hook. + +{% endtab %} {% tab pre-commit Pre-commit %} Pre-commit can be installed through `brew` (macOS) or `pipx/uv` (anywhere). There are two modes to use it locally; you can check manually with @@ -28,14 +36,6 @@ gets its name). Pre-commit's setup is much slower than prek, but you can install `pre-commit-uv` with pre-commit to speed up the setup time quite a bit. -{% endtab %} {% tab prek Prek %} - -Prek can be installed through `brew` (macOS) or `pipx/uv` (anywhere). There are -two modes to use it locally; you can check manually with `prek run` (hanges -only) or `prek run -a` (all). You can omit the `run`, as well; such as -`prek -a`. You can also run `prek install` to add checks as a git pre-commit -hook. - {% endtab %} {% endtabs %} Local runs (with `-a`) are the standard way to use it. That will run all the @@ -47,8 +47,6 @@ a custom pre-commit hook before; it's quite elegant and does not add or commit the changes, it just makes the changes and allows you to check and add them. You can always override the hook with `-n`. -[pre-commit]: https://pre-commit.com - {% rr PC100 %} Here is a minimal `.pre-commit-config.yaml` file with some handy options: @@ -158,7 +156,7 @@ Here is the snippet to add the formatter to your `.pre-commit-config.yml` ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.15.13" + rev: "v0.15.14" hooks: # id: ruff-check would go here if using both - id: ruff-format @@ -188,7 +186,7 @@ Here is the snippet to add Black to your `.pre-commit-config.yml`: ```yaml - repo: https://github.com/psf/black-pre-commit-mirror - rev: "26.5.0" + rev: "26.5.1" hooks: - id: black ``` @@ -248,7 +246,7 @@ pre-commit hook. ```yaml - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.15.13" + rev: "v0.15.14" hooks: - id: ruff-check args: ["--fix", "--show-fixes"] @@ -804,7 +802,7 @@ integration. ```yaml - repo: https://github.com/crate-ci/typos - rev: "v1.46.2" + rev: "v1.46.3" hooks: - id: typos args: [] @@ -1047,6 +1045,8 @@ You also might like the following hook, which cleans Jupyter outputs: [schemastore]: https://schemastore.org [typos]: https://github.com/crate-ci/typos [typos-ref]: https://github.com/crate-ci/typos/blob/master/docs/reference.md +[pre-commit]: https://pre-commit.com +[prek]: https://prek.j178.dev diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index 5733aafe..9fc31d37 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: args: [--prose-wrap=always] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: "v0.15.13" + rev: "v0.15.14" hooks: - id: ruff-check args: ["--fix"]