github jdx/hk v2.0.1
v2.0.1: Terragrunt shared-include validation, kubeconform directory options, and clearer hk test failures

3 hours ago

The Terragrunt builtins now catch errors in shared HCL files, kubeconform can be retargeted without breaking its bundled tests, and hk test explains itself when a step's filters exclude every file a test writes. Note that the Terragrunt builtins now require terragrunt 1.0.8 or newer.

Fixed

  • terragrunt_hcl_validate catches errors in shared HCL includes (#1371, @sassdavid). Previously the step ran --working-dir once per selected directory, so editing a shared file outside every unit directory (one reached only via include or read_terragrunt_config) validated nothing and passed. Both terragrunt_hcl_validate and terragrunt_hcl_fmt now run a single terragrunt process scoped with --filter; validate adds a directory filter and a reading= filter per selected file so unit configs and shared includes are both covered. On a 39-unit repository this cut fmt from 1650ms to 91ms and validate from 5680ms to 1475ms. Requires terragrunt 1.0.8+, the first release where --filter works on hcl fmt and hcl validate.
  • hk test reports when a step's filters exclude a test's files (#1373, @sassdavid). When a test omits files, hk derives them from the test's write keys and applies the step's glob/types/exclude/match_any filters. If nothing survived, the command still ran with an empty file list and failed in a tool-specific way (for example kubeconform complaining about stdin). The test now fails up front with the step's file filters excluded all N file(s) written by this test; set the test's files explicitly, or reset tests when overriding a builtin's glob. Tests that set files, write nothing, or belong to steps without filters are unaffected, and code= is now only printed when a command actually ran.
  • Pkl evaluator update: hk's bundled Pkl evaluator (pklr) moves from 2.0.1 to 2.0.4, which preserves lexical scope across object amendments and keeps field-pruned import views intact while evaluating object and mapping amendments (#1380, #1381).

Changed

  • kubeconform gains dirs, test_dir, and extra_excludes (#1372, @sassdavid). Replacing the builtin's glob to cover layouts such as Flux's apps/ or clusters/ used to filter away every file its own tests wrote, forcing users to delete the inherited tests block. The builtin now derives its glob, excludes, and test paths from three options; defaults are unchanged.

    steps {
      ["kubeconform"] = (Builtins.kubeconform) {
        dirs = List("apps", "clusters")          // List() selects every YAML file
        extra_excludes = List("**/custom.yaml")  // appended to the Helm/kustomize defaults
      }
    }

    Set test_dir when replacing glob outright so the bundled tests still write into a selected path. Prefer extra_excludes over exclude, which replaces the defaults and re-admits Helm templates/, values.yaml, and kustomization.yaml files.

Documentation

  • Global mise hook installation is now the recommended setup (#1376, @jdx). On Git 2.54+, hk install --global --mise installs the launcher once per machine, records mise's path at install time, and is a no-op in repositories without hk configuration. hk install --mise remains documented for repository-scoped installs on any supported Git version but needs mise on Git's runtime PATH. To switch scopes, run hk uninstall then hk install --global --mise. The mise postinstall = "hk install --mise" recipe is removed from the main setup flow.
  • Top-level steps is optional (#1370, @jdx). The v2 migration guide no longer reads as if moving steps to the top level is required; hook-only configurations and shared local mappings remain supported. The README, getting started, configuration, Pkl guides, and downloadable examples now use a single steps { ... } block, and staging guidance reflects that hk fix leaves changes unstaged unless --stage is passed.

Full Changelog: v2.0.0...v2.0.1

💚 Sponsor hk

hk is built and maintained by @jdx, an open source developer at entire.io, the title sponsor of his open source work.

If hk speeds up your pre-commit loop or makes linting less painful, please consider becoming an individual or company sponsor. Your support funds ongoing development and helps keep hk fast, free, and independent.

Don't miss a new hk release

NewReleases is sending notifications on new releases.