github jdx/hk v2.1.0
v2.1.0: Glob imports in hk.pkl, reliable config cache invalidation, and new kube-linter and dotnet format builtins

2 hours ago

hk.pkl can now assemble steps from a glob of Pkl files with the expression form of import*, and hk's config cache finally notices when glob-matched or transitively imported modules change. Three new builtin capabilities land for Kubernetes manifests, .NET projects, and EditorConfig fixes, plus fixes for typos under custom shells and pre-push crashing on unexpected stdin.

Added

  • Glob imports in hk configuration (#1423, @jdx). The expression form import*("generated/*.pkl") now evaluates; hk previously rejected it at parse time with unexpected token in expression: KwImportStar, which kept projects that generate step definitions on hk 1.x. The declaration form import* "generated/*.pkl" as generated continues to work. Support comes from upgrading hk's bundled Pkl evaluator to pklr 3.0.

    local generated = import*("generated/*.pkl")
    
    hooks {
      ["check"] {
        steps = new Mapping<String, Step> {
          for (_, mod in generated) {
            ...mod.STEPS
          }
        }
      }
    }

    Each matched file exports its own STEPS: Mapping<String, Config.Step>. See the new "Import many files at once" section in the Pkl introduction docs.

  • Builtins.kube_linter (#1394, @zeitlinger). Runs kube-linter lint --fail-if-no-objects-found on plain Kubernetes manifests in conventional k8s, kubernetes, manifests, deploy, and deployments directories, excluding Helm templates/, values*.yaml, and kustomization.yaml. It checks deployment policy rather than schemas, so it complements kubeconform; native .kube-linter.yaml / .kube-linter.yml config is discovered automatically. Override glob for other layouts. Helm charts are out of scope and there is no fix command because the tool has none.

  • Builtins.dotnet_format (#1393, @zeitlinger). Checks and fixes C# and Visual Basic formatting with dotnet format, passing hk's selected files via --include and relying on dotnet's project/solution discovery in the working directory. Set dir = "src/app" for a nested project or solution and use separate steps for independent directories. The step is exclusive and both commands declare a write effect because restore can touch obj/. Requires .NET SDK 6+ and trusted project code, as with running dotnet format directly.

    steps {
      ["dotnet-format"] = Builtins.dotnet_format
    }
  • editorconfig-checker can now fix (#1397, @lucacome). The builtin gains a fix command using editorconfig-checker --fix when version = "4" (the default); version 3 remains check-only.

Fixed

  • Config cache picks up import changes it used to miss (#1422, @jdx). hk keyed its cached module-graph analysis on the root hk.pkl alone, so adding or removing a file matched by an import* glob, or an imported module gaining a new import, was ignored until you edited hk.pkl or ran hk cache clear. The analysis now records glob patterns and a digest of every source in the graph and re-validates both before reuse. No settings or config changes are needed; caches from older hk versions are not reused. #1423 also fixes untracked-import detection so a remote module loaded with an expression-form import(...), with its URI on a following line, or after a comment is no longer mistakenly served from the shared cache.
  • typos no longer reports success on failure under custom shells (#1398, @zeitlinger). With a shell that does not enable errexit (for example shell = "sh -c"), a failing typos run such as an unreadable or invalid typos.toml could fall through to the empty-output success path. The builtin now preserves the command's exit status. The default hk shell was already unaffected.
  • pre-push warns on malformed stdin instead of panicking (#1352, @connormharris). When hk inherits a non-terminal stdin, for example inside a while read branch loop, lines that are not <local ref> <local sha> <remote ref> <remote sha> crashed with index out of bounds. Such lines are now skipped with Ignoring malformed stdin line "...": <reason>, and the two SHA fields must be full 40- or 64-character lowercase hashes.

New Contributors

Full Changelog: v2.0.1...v2.1.0

💚 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.