Skip to content

CI: Replace pre-commit with prek#119150

Merged
Repiteo merged 1 commit into
godotengine:masterfrom
Repiteo:ci/prek
May 4, 2026
Merged

CI: Replace pre-commit with prek#119150
Repiteo merged 1 commit into
godotengine:masterfrom
Repiteo:ci/prek

Conversation

@Repiteo
Copy link
Copy Markdown
Contributor

@Repiteo Repiteo commented May 1, 2026

Prek is the latest in a line of toolkits written in Rust meant to serve as drop-in replacements for industry-standard tools. This time, it's a replacement for pre-commit itself, and a damn good one at that. Comparing this repo's action runs, prek's action from a clean base took ~14 seconds, while pre-commit's cached action took ~25 seconds

Prek was ~11 seconds faster without a cache than pre-commit with a cache

It truly is a drop-in replacement, as the tool reads from .pre-commit-config.yaml without issue. This means that users utilizing pre-commit directly may continue to do so at this time. It's entirely capable of reading from its own dedicated file—prek.toml—and supports unique configurations which aren't supported by pre-commit, but this PR aims to be as painless of a drop-in replacement as possible. It's unique options and dedicated file can be pursued in a followup, if desired

@Repiteo Repiteo added this to the 4.x milestone May 1, 2026
@Repiteo Repiteo requested a review from a team as a code owner May 1, 2026 19:01
Copy link
Copy Markdown
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested briefly, seems fine to me.

We need to update our documentation on how to set-up prek.
I was worried it would require users to have cargo to compile it, but it seems there's a lot of options (too many?) for binary installs: https://github.com/j178/prek#installation
We should figure out what to recommend for our contributors so the steps to set up prek aren't more complex than pre-commit (especially regarding having it in PATH). It seems it's provided as a pip package so pip install prek is at least something we can expect all contributors with a Python/SCons setup to be able to run.

@Repiteo Repiteo modified the milestones: 4.x, 4.7 May 4, 2026
@Repiteo Repiteo merged commit f4d14dd into godotengine:master May 4, 2026
20 checks passed
@Repiteo Repiteo deleted the ci/prek branch May 4, 2026 17:47
@Calinou
Copy link
Copy Markdown
Member

Calinou commented May 5, 2026

For future reference, these are the hook runtimes on my system with prek using prek run --all-files --verbose:

check that executables have shebangs.....................................Passed
- hook id: check-executables-have-shebangs
- duration: 0.01s
check that scripts with shebangs are executable..........................Passed
- hook id: check-shebang-scripts-are-executable
- duration: 0.11s
clang-format.............................................................Passed
- hook id: clang-format
- duration: 5.07s
clang-format-glsl........................................................Passed
- hook id: clang-format
- duration: 28.29s
ruff check...............................................................Passed
- hook id: ruff-check
- duration: 0.03s

  All checks passed!
ruff format..............................................................Passed
- hook id: ruff-format
- duration: 0.06s

  342 files left unchanged
mypy.....................................................................Passed
- hook id: mypy
- duration: 0.10s

  Success: no issues found in 131 source files
codespell................................................................Passed
- hook id: codespell
- duration: 0.51s
Validate files with jsonschema...........................................Passed
- hook id: check-jsonschema
- duration: 0.19s

  ok -- validation done
make-rst.................................................................Passed
- hook id: make-rst
- duration: 0.60s

  Checking for errors in the XML class reference...
  Generating the RST class reference...

  Generating the index file...

  286 code samples failed parity check. Use --verbose to get more information.

  No warnings or errors found in the class reference XML.
doc-status...............................................................Passed
- hook id: doc-status
- duration: 0.20s

  No classes suitable for printing!
validate-builders........................................................Passed
- hook id: validate-builders
- duration: 0.04s
validate-xml.............................................................Passed
- hook id: validate-xml
- duration: 0.46s
validate-codeowners......................................................Passed
- hook id: validate-codeowners
- duration: 0.10s
validate-includes........................................................Passed
- hook id: validate-includes
- duration: 0.10s
eslint...................................................................Passed
- hook id: eslint
- duration: 0.46s
jsdoc....................................................................Passed
- hook id: jsdoc
- duration: 0.15s

  Dry run... Okay!
svgo.....................................................................Passed
- hook id: svgo
- duration: 0.33s
copyright-headers........................................................Passed
- hook id: copyright-headers
- duration: 0.48s
header-guards............................................................Passed
- hook id: header-guards
- duration: 0.04s
file-format..............................................................Passed
- hook id: file-format
- duration: 0.20s
dotnet-format............................................................Passed
- hook id: dotnet-format
- duration: 49.78s

The two hooks that take the most time by a wide margin are dotnet-format, followed by clang-format-glsl. I wonder what we could do to speed those up, especially clang-format-glsl which is much slower than clang-format.

Regarding the installation process, pip install prek works well on my end.

The dotnet format hook prints a bunch of warnings in verbose mode:

Details

  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  sh: -c: line 1: syntax error near unexpected token `('
  sh: -c: line 1: `dotnet format modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests --include modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/AllWriteOnly_ScriptProperties.generated.cs modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/ExportedFields_ScriptPropertyDefVal.generated.cs modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/AbstractGenericNode(Of T)_ScriptProperties.generated.cs'
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  sh: -c: line 1: syntax error near unexpected token `('
  sh: -c: line 1: `dotnet format modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests --include modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/Foo.cs modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/Generic(Of T)_ScriptPath.generated.cs modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/GeneratedSources/GenericClass(Of T).NestedClass_ScriptMethods.generated.cs modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/ExportDiagnosticsTests.cs modules/mono/editor/Godot.NET.Sdk/Godot.SourceGenerators.Tests/TestData/Sources/OuterClassPartialModifierAnalyzer.GD0002.cs'
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
  Warnings were encountered while loading the workspace. Set the verbosity option to the 'diagnostic' level to log warnings.
PC specifications
  • CPU: AMD Ryzen 9 9950X3D
  • GPU: NVIDIA GeForce RTX 5090
  • RAM: 64 GB (2×32 GB DDR5-6000 CL30)
  • SSD: Solidigm P44 Pro 2 TB
  • OS: Linux (Fedora 43)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants