From 74aa5460e5180d217be94e79dfacb683829260bd Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Wed, 2 Sep 2026 13:24:51 +0100 Subject: [PATCH 1/4] CI: run SwiftFormat through hk Define shared check and fix hooks for SwiftFormat and run the locked hk command in CI while preserving GitHub Actions diagnostics. --- .github/workflows/ci.yml | 2 +- hk.pkl | 32 ++++++++++++++++++++++++++++++++ mise.lock | 34 ++++++++++++++++++++++++++++++++++ mise.toml | 1 + 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 hk.pkl diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46536be..ae2758d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: uses: jdx/mise-action@v3 - name: SwiftFormat Lint - run: mise exec -- swiftformat --lint . --reporter github-actions-log + run: mise exec --locked -- hk check --all apple: if: github.event_name != 'pull_request' || !contains(github.event.pull_request.title, '[skip ci]') diff --git a/hk.pkl b/hk.pkl new file mode 100644 index 0000000..bf16819 --- /dev/null +++ b/hk.pkl @@ -0,0 +1,32 @@ +amends "package://github.com/jdx/hk/releases/download/v1.57.0/hk@1.57.0#/Config.pkl" + +local linters = new Mapping { + ["swiftformat"] { + glob = "**/*.swift" + + check = new CommandSpec { + command = new Command { + argv = List("swiftformat", "--lint", "--reporter", "github-actions-log", "{{files}}") + } + effect = "read" + } + + fix = new CommandSpec { + command = new Command { + argv = List("swiftformat", "{{files}}") + } + effect = "write" + } + } +} + +hooks { + ["check"] { + steps = linters + } + + ["fix"] { + fix = true + steps = linters + } +} diff --git a/mise.lock b/mise.lock index 1df1a01..98666ec 100644 --- a/mise.lock +++ b/mise.lock @@ -1,5 +1,39 @@ # @generated - this file is auto-generated by `mise lock` https://mise.jdx.dev/dev-tools/mise-lock.html +[[tools.hk]] +version = "1.57.0" +backend = "aqua:jdx/hk" + +[tools.hk."platforms.linux-arm64"] +checksum = "sha256:af6768ba1e3041a988b6518bf8b6e8900dc6a2001208b3f548545fe7de4e6f22" +url = "https://github.com/jdx/hk/releases/download/v1.57.0/hk-aarch64-unknown-linux-gnu.tar.gz" +url_api = "https://api.github.com/repos/jdx/hk/releases/assets/536864258" + +[tools.hk."platforms.linux-arm64-musl"] +checksum = "sha256:969feeff543c2bd30281fdce43139fd0913cbf44385387b94b9411a72775c960" +url = "https://github.com/jdx/hk/releases/download/v1.57.0/hk-aarch64-unknown-linux-musl.tar.gz" +url_api = "https://api.github.com/repos/jdx/hk/releases/assets/536864262" + +[tools.hk."platforms.linux-x64"] +checksum = "sha256:71449da0187a957233e1cf08565ed3c85fe67cd8d5942a15bc231579e1c7e380" +url = "https://github.com/jdx/hk/releases/download/v1.57.0/hk-x86_64-unknown-linux-gnu.tar.gz" +url_api = "https://api.github.com/repos/jdx/hk/releases/assets/536864279" + +[tools.hk."platforms.linux-x64-musl"] +checksum = "sha256:e67b730e82e04e3e9b513f9063573a3fc29377ef3b61aa04cce7c9b9f4782b1e" +url = "https://github.com/jdx/hk/releases/download/v1.57.0/hk-x86_64-unknown-linux-musl.tar.gz" +url_api = "https://api.github.com/repos/jdx/hk/releases/assets/536864280" + +[tools.hk."platforms.macos-arm64"] +checksum = "sha256:7b10c00e1f1b51d3e43cd5e738cc5fd93bf3ec0b777505744ac37c8b1e171188" +url = "https://github.com/jdx/hk/releases/download/v1.57.0/hk-aarch64-apple-darwin.tar.gz" +url_api = "https://api.github.com/repos/jdx/hk/releases/assets/536864261" + +[tools.hk."platforms.windows-x64"] +checksum = "sha256:b5c4de9ec9e83790642564370c572b559f2b4ea38147ee8ea1f5b415967dab3f" +url = "https://github.com/jdx/hk/releases/download/v1.57.0/hk-x86_64-pc-windows-msvc.zip" +url_api = "https://api.github.com/repos/jdx/hk/releases/assets/536864259" + [[tools.swiftformat]] version = "0.63.0" backend = "github:nicklockwood/SwiftFormat" diff --git a/mise.toml b/mise.toml index 3b953c0..a4127cd 100644 --- a/mise.toml +++ b/mise.toml @@ -1,2 +1,3 @@ [tools] +hk = "1.57.0" swiftformat = "0" From 976734c663f003678779ba1df6f87d7559bf9d1f Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Wed, 2 Sep 2026 15:14:19 +0100 Subject: [PATCH 2/4] CI: rely on locked Mise environment Enable repository-level locked mode, select hk by major version, and invoke hk directly through the PATH configured by mise-action. --- .github/workflows/ci.yml | 2 +- mise.toml | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae2758d..6c63b82 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,7 +31,7 @@ jobs: uses: jdx/mise-action@v3 - name: SwiftFormat Lint - run: mise exec --locked -- hk check --all + run: hk check --all apple: if: github.event_name != 'pull_request' || !contains(github.event.pull_request.title, '[skip ci]') diff --git a/mise.toml b/mise.toml index a4127cd..41cd31c 100644 --- a/mise.toml +++ b/mise.toml @@ -1,3 +1,6 @@ +[settings] +locked = true + [tools] -hk = "1.57.0" +hk = "1" swiftformat = "0" From 6ff1544f6cd11682e80d387665ffc2d5d52bf800 Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Wed, 2 Sep 2026 15:48:45 +0100 Subject: [PATCH 3/4] CI: format Swift files before commit Run SwiftFormat through hk's pre-commit hook, protecting unstaged work with Git-backed stashing and staging formatter changes automatically. --- hk.pkl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hk.pkl b/hk.pkl index bf16819..3bc1777 100644 --- a/hk.pkl +++ b/hk.pkl @@ -21,6 +21,12 @@ local linters = new Mapping { } hooks { + ["pre-commit"] { + fix = true + stash = "git" + steps = linters + } + ["check"] { steps = linters } From a09acd1af3db9277ebc1137bb6fba22f66e9d70a Mon Sep 17 00:00:00 2001 From: David Roman <2538074+davdroman@users.noreply.github.com> Date: Wed, 2 Sep 2026 17:39:42 +0100 Subject: [PATCH 4/4] CI: scope locked Mise configuration Require a Mise version that supports config-scoped lock enforcement and document project tool and hook setup. --- README.md | 9 +++++++++ mise.toml | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index dc14438..856e022 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,15 @@ class MyClass: NSObject { } ``` +## Development + +Install [Mise](https://mise.jdx.dev/), then install the project tools and Git hooks: + +```sh +mise install +mise exec -- hk install --mise +``` + ## Credits This library is inspired by and builds upon the following projects: diff --git a/mise.toml b/mise.toml index 41cd31c..fb5c9ba 100644 --- a/mise.toml +++ b/mise.toml @@ -1,4 +1,6 @@ -[settings] +min_version = "2026.8.6" + +[tool_config] locked = true [tools]