From 0212f16b1eef8d28c5149bcef1553aa795639151 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Mon, 3 Apr 2023 16:23:14 -0400 Subject: [PATCH 1/3] Adds a system-provided checkmake hook for pre-commit [Problems with pre-commit's invocation of `go install`][pc-gh2722] had me wanting more options for how to run hooks in case the automated installation fails. Since checkmake is available in at least Homebrew, it'd be nice to have a hook that can use a checkmake executable already installed in the system PATH. [pc-gh2722]: https://github.com/pre-commit/pre-commit/issues/2722 --- .pre-commit-hooks.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 9a8ef20..fdfb058 100755 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -4,3 +4,9 @@ language: golang pass_filenames: true types: [makefile] +- id: checkmake-system + name: Makefile linter/analyzer + entry: checkmake + language: system + types: [makefile] + pass_filenames: true From 8ccb84e1704a4f87a1823bc3426b5c86462ca650 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Mon, 3 Apr 2023 16:29:41 -0400 Subject: [PATCH 2/3] Add checkmake-system to README --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 50d08a1..d0c768e 100644 --- a/README.md +++ b/README.md @@ -64,17 +64,36 @@ repos. Simply add a `.pre-commit-config.yaml` to your repo's top-level directory ```yaml repos: - repo: https://github.com/mrtazz/checkmake.git + # Or another commit hash or version rev: 0.2.2 hooks: + # Use this hook to let pre-commit build checkmake in its sandbox - id: checkmake + # OR Use this hook to use a pre-installed checkmark executable + # - id: checkmake-system ``` -Then, run `pre-commit` as usual. For example: +There are two hooks available: + +- `checkmake` (Recommended) + + pre-commit will set up a Go environment from scratch to compile and run checkmake. + See the [pre-commit `golang` plugin docs](https://pre-commit.com/#golang) for more information. + +- `checkmake-system` + + pre-commit will look for `checkmake` on your `PATH`. + This hook requires you to install `checkmake` separately, e.g. with your package manager or [a prebuilt binary release](https://github.com/mrtazz/checkmake/releases). + Only recommended if it's permissible to require all repository users install `checkmake` manually. + +Then, run `pre-commit` as usual as a part of `git commit` or explicitly, for example: ```sh pre-commit run --all-files ``` +### pre-commit in GitHub Actions + You may also choose to run this as a GitHub Actions workflow. To do this, add a `.github/workflows/pre-commit.yml` workflow to your repo: From 8d51504ef76c7f396e4eed734c2ed84076e16c28 Mon Sep 17 00:00:00 2001 From: Colin Dean Date: Mon, 3 Apr 2023 18:43:49 -0400 Subject: [PATCH 3/3] Use main branch for checkmake to consume its own hook This could be risky but it's probably OK for how rare the repo is updated. --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8f30690..57d8cc3 100755 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ exclude: | )$ repos: - repo: https://github.com/mrtazz/checkmake.git - rev: 0.2.2 + rev: main hooks: - id: checkmake exclude: |