diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 46536be..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 -- swiftformat --lint . --reporter github-actions-log + run: hk check --all apple: if: github.event_name != 'pull_request' || !contains(github.event.pull_request.title, '[skip ci]') 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/hk.pkl b/hk.pkl new file mode 100644 index 0000000..3bc1777 --- /dev/null +++ b/hk.pkl @@ -0,0 +1,38 @@ +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 { + ["pre-commit"] { + fix = true + stash = "git" + steps = linters + } + + ["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..fb5c9ba 100644 --- a/mise.toml +++ b/mise.toml @@ -1,2 +1,8 @@ +min_version = "2026.8.6" + +[tool_config] +locked = true + [tools] +hk = "1" swiftformat = "0"