-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhk.pkl
More file actions
83 lines (71 loc) · 2.94 KB
/
hk.pkl
File metadata and controls
83 lines (71 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*
* SPDX-FileCopyrightText: 2025 Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
*
* * Licensed under the [Plain MIT License](LICENSE.md)
*/
amends "package://github.com/jdx/hk/releases/download/v1.2.0/hk@1.2.0#/Config.pkl"
import "package://github.com/jdx/hk/releases/download/v1.2.0/hk@1.2.0#/Builtins.pkl"
local linters = new Mapping<String, Step> {
["cargo_deny"] = new Step {
workspace_indicator = "Cargo.toml"
glob = "Cargo.lock"
check = "cargo deny --all-features --manifest-path {{ workspace_indicator }} -f json -L warn check --audit-compatible-output --exclude-dev --hide-inclusion-graph | jq -e '.[].vulnerabilities | length == 0' || exit 1"
}
["cargo_fmt"] = Builtins.cargo_fmt
["cargo_clippy"] = Builtins.cargo_clippy
["cargo_check"] = Builtins.cargo_check
["cargo_test"] = new Step {
workspace_indicator = "Cargo.toml"
glob = "src/**/*.rs"
check = "cargo nextest --manifest-path {{ workspace_indicator }} run --all-features --no-fail-fast"
env = new Mapping<String, String> {
["RUST_BACKTRACE"] = "1"
}
}
// Spellchecker
["typos"] = new Step {
workspace_indicator = "_typos.toml"
glob = List( "*README", "*.{.login,astro,bash,bash_logout,bashrc,browserlistrc,conf,config,csh,css,cts,fish,gitattributes,gitmodules,html,htmx,ini,j2,jinja,jinja2,json,json5,jsonc,jsonl,ksh,md,mdown,mdtext,mdtxt,mdwn,mdx,mk,mkd,mts,nix,nu,pkl,profile,quokka,sass,scss,sh,sh,shellcheckrc,sql,sqlite,stylelintrc,svelte,tcsh,toml,ts,tsx,txt,yaml,yml,zlogin,zlogout,zprofile,zsh,zshenv,zshrc}", "*Dockerfile*", "*Makefile*", "*makefile*", "CHANGELOG*", "CODE_OF_CONDUCT*", "CONTRIBUTING*", "HACKING*", "LICENSE", "README*", "SECURITY*", "UNLICENSE")
check = "typos -j 8 --config {{ workspace_indicator }} {{ files }}"
fix = "typos --write-changes --config {{ workspace_indicator }} {{ files }}"
}
// define a custom linter
["pkl"] = new Step {
glob = "*.pkl"
check = "pkl eval {{files}} >/dev/null"
}
}
local ci = (linters) {
["cargo_test"] {
check = "cargo nextest --manifest-path {{ workspace_indicator }} run --all-features --fail-fast -p ci"
}
}
hooks {
["pre-commit"] {
fix = true // automatically modify files with available linter fixes
stash = "git" // stashes unstaged changes while running fix steps
steps = linters
}
// instead of pre-commit, you can instead define pre-push hooks
["pre-push"] {
steps = linters
}
["fix"] {
fix = true
stash = "git" // stashes unstaged changes while running fix steps
steps = linters
}
["check"] {
steps = linters
}
["test"] {
steps = linters
.toMap()
.filter(
(name, _) -> name == "cargo_test")
.toMapping()
}
["ci"] {
steps = ci
}
}