Skip to content

Conversation

thomasleese
Copy link
Contributor

@thomasleese thomasleese commented Apr 15, 2025

This updates our linting set up to use hk as the tool runner for our various linters. hk is a new tool that is designed to run commands as part of a Git commit, and through that it can be used to run linting tools. It's a proposed alternative to pre-commit with some specific goals around running linters in parallel and being highly performant.

This is proposed as an alternative to #3001 to avoid the need to add Python to our project, specifically hk is provided as a binary and can be included in .tool-versions installed by Mise. On the other hand, compared to pre-commit, hk is a new project and not yet fully supported (there's a warning that things may change in each release on the project website), so we may choose to put this off until a time when hk becomes more mature.

This comes with similar advantages to pre-commit, such as having a standard approach to configuring our linting tools, and for those who wish to, it allows you to integrate the linting with git commit.

In this PR, I've converting our existing GitHub Actions workflow to a single linting workflow which calls hk check. This does mean we lose granularity of individual linters, and if we'd prefer to stick with our existing approach that can be done by using hk check --linter <linter>.

@misaka
Copy link
Contributor

misaka commented Apr 16, 2025

Worth noting, if we want the pre-commit hook enabled, I needed to run the install with --mise:

hk install --mise

Base automatically changed from v2.2.0-wip to main April 17, 2025 11:27
@thomasleese thomasleese added this to the v2.2.0 milestone Apr 20, 2025
@thomasleese thomasleese added the refactor Improving maintainability label Apr 20, 2025
@thomasleese thomasleese marked this pull request as ready for review April 22, 2025 11:17
This installs the tools `hk` and `pkl` which can be used to manage Git
hooks and run linters.
This configures `hk` to run the `rubocop` linter. To support this I've
had to make a couple of changes to `.rubocop.yml` to exclude
`db/schema.rb` when checking it individually.
This configures the `rufo` linter to run with `hk`.
This configures the `prettier` linter to run with `hk`.
This configures the Brakeman linter to run with `hk`.
This configures `terraform fmt` to run with `hk`.
This configures `tf_lint` to run with `hk`.
`hk` is a tool that runs linters so we can change our `bin/lint` script
to call `hk`.
This configures the "Lint" workflow to use `hk` instead of calling the
linters manually.
This moves a large block of content out of the `README.md` file and in
to its own file dedicated only to the release process. This should help
to keep the `README.md` file easier to read.
This moves a large block of content out of the `README.md` file and in
to its own file dedicated only to the branching strategy. This should
help to keep the `README.md` file easier to read.
To explain to new developers the linting tool we use, how to install it
and how to use it.
@tvararu tvararu temporarily deployed to mavis-pr-3412 April 24, 2025 11:10 Inactive
Copy link

@thomasleese thomasleese enabled auto-merge April 24, 2025 11:12
@thomasleese thomasleese merged commit 9370d08 into main Apr 24, 2025
12 checks passed
@thomasleese thomasleese deleted the hk branch April 24, 2025 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Improving maintainability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants