-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhk.pkl
More file actions
99 lines (88 loc) · 4.24 KB
/
Copy pathhk.pkl
File metadata and controls
99 lines (88 loc) · 4.24 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* SPDX-FileCopyrightText: 2025 Adam Poulemanos <89049923+bashandbone@users.noreply.github.com>
*
* SPDX-License-Identifier: LicenseRef-PlainMIT OR MIT
*/
amends "package://github.com/jdx/hk/releases/download/v1.48.0/hk@1.48.0#/Config.pkl"
import "package://github.com/jdx/hk/releases/download/v1.48.0/hk@1.48.0#/Builtins.pkl"
local linters = new Mapping<String, Step> {
["cargo_deny"] = new Step {
workspace_indicator = "Cargo.toml"
// All three inputs matter now that every check runs: `licenses` and `bans`
// read Cargo.toml, and all four read deny.toml. With only Cargo.lock here,
// editing the policy itself would not re-run the step that enforces it.
glob = List("Cargo.lock", "Cargo.toml", "deny.toml")
// `check` with no subcommand runs all four — advisories, bans, licenses,
// sources — letting cargo-deny's own exit code decide. This was
// `check advisories` with `-A unsound -A unmaintained -A yanked -A notice`,
// which meant `deny.toml`'s licenses/bans/sources policy was configured but
// never enforced by any hook or CI job. The four allowances are gone too:
// they suppress nothing in the current graph, so keeping them would only
// hide a *future* unmaintained or yanked dependency. If one lands, add it to
// `ignore` in deny.toml with a reason rather than reinstating a blanket -A.
// (The previous `-f json ... | jq -e '.[].vulnerabilities | length == 0'`
// pipeline no longer parses: with `-f json` cargo-deny streams one object
// per diagnostic, not an array, so jq failed with exit 5 on every run.)
// --exclude-dev is a top-level flag; it moved off the `check` subcommand.
check = "cargo deny --all-features --manifest-path {{ workspace_indicator }} --exclude-dev -L warn check --hide-inclusion-graph"
}
["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*", "CODE_OF_CONDUCT*", "CONTRIBUTING*", "HACKING*", "LICENSE", "README*", "SECURITY*", "UNLICENSE")
// CHANGELOG.md is generated by git-cliff from commit subjects; abbreviated
// commit hashes trip the spellchecker. _typos.toml also excludes it, but that
// only applies when typos walks a directory — hk passes explicit file paths.
exclude = "CHANGELOG.md"
check = "typos -j 8 {{ files }}"
fix = "typos --write-changes {{ 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 = new Mapping<String, Step> {
["cargo_test"] = linters["cargo_test"]
}
}
["ci"] {
steps = ci
}
}