Skip to content

Commit a9cfe74

Browse files
stemplergithub-actions[bot]
authored andcommitted
feat: use mise exec to run most steps
...to remove the need to add the tools to the mise config and to be able to specify tool versions in the shared hk configuration.
1 parent a09dc22 commit a9cfe74

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

Shared.pkl

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,39 @@ actionlint = (Builtins.actionlint) {
55
// extend to include actiion.yml/yaml files XXX turned out this is not supported by actionlint at the moment
66
// glob = List(".github/workflows/*.yml", ".github/workflows/*.yaml", "action.yml", "action.yaml")
77

8+
local prefix = "mise x actionlint -- "
9+
check = prefix + Builtins.actionlint.check
10+
811
// exclude managed tf- files which are generated
912
exclude = List(".github/workflows/tf-*")
1013
}
1114

1215
prettier = (Builtins.prettier) {
16+
local prefix = "mise x prettier -- "
17+
18+
check = prefix + Builtins.prettier.check_list_files
19+
check_list_files = prefix + Builtins.prettier.check_list_files
20+
fix = prefix + Builtins.prettier.fix
21+
1322
// exclude files which are generated/managed
1423
exclude = List(".github/workflows/tf-*", "CHANGELOG.md")
1524
}
1625

17-
pkl = Builtins.pkl
26+
local pkl_version = "0.30.0"
27+
local pkl_prefix = "mise x pkl@\(pkl_version) -- "
28+
29+
pkl = (Builtins.pkl) {
30+
check = pkl_prefix + Builtins.pkl.check
31+
}
1832

1933
// Note: supported since pkl 0.30 - https://pkl-lang.org/main/current/release-notes/0.30.html
2034
// TODO use Builtins.pkl_format as soon as hk is released (>1.25.0)
2135
pklformat = new Config.Step {
2236
stage = "<JOB_FILES>"
2337
glob = "*.pkl"
24-
check = "pkl format --silent {{files}}"
25-
// exit code of pkl format is 1 if changes were made, so we first attempt to write changes with -w, and if that fails, we run again with --silent to ensure a zero exit code on success
26-
fix = "pkl format -w {{files}} || pkl format --silent {{files}}"
38+
check = "\(pkl_prefix) pkl format --silent {{files}}"
39+
// exit code of pkl format is not zero if changes were made, so we first attempt to write changes with -w, and then run again with --silent to ensure a zero exit code on success
40+
fix = "\(pkl_prefix) pkl format -w {{files}} || \(pkl_prefix) pkl format --silent {{files}}"
2741
}
2842

2943
spotlessGradle = new Config.Step {
@@ -50,32 +64,33 @@ spotlessGradle = new Config.Step {
5064
// Secret detection tools
5165

5266
// https://github.com/Yelp/detect-secrets
53-
// mise: pipx:detect-secrets
5467
detectsecrets = new Config.Step {
5568
// needs a baseline
5669
// create with `detect-secrets scan > .secrets.baseline`
5770
// check will fail if file does not exist
58-
check = "detect-secrets-hook --baseline .secrets.baseline {{files}}"
71+
check = "mise x pipx:detect-secrets -- detect-secrets-hook --baseline .secrets.baseline {{files}}"
5972
}
6073

6174
// https://github.com/sirwart/ripsecrets
6275
ripsecrets = new Config.Step {
63-
check = "ripsecrets {{files}}"
76+
check = "mise x ripsecrets -- ripsecrets {{files}}"
6477
}
6578

6679
// https://github.com/gitleaks/gitleaks
6780
gitleaks = new Config.Step {
81+
// don't use latest as there may be breaking changes (even for minor version updates)
82+
local gitleaks_version = "8.30.0"
6883
// XXX scans whole folder if there are multiple files (see https://github.com/gitleaks/gitleaks/issues/1727)
69-
check = "gitleaks dir -v {{files}}"
84+
check = "mise x gitleaks@\(gitleaks_version) -- gitleaks dir -v {{files}}"
7085
}
7186

7287
// https://github.com/trufflesecurity/trufflehog
7388
trufflehog = new Config.Step {
74-
check = "trufflehog filesystem {{files}} --fail"
89+
check = "mise x trufflehog -- trufflehog filesystem {{files}} --fail"
7590
}
7691

7792
// https://trivy.dev/docs/latest/scanner/secret/
7893
trivysecrets = new Config.Step {
7994
// Note: trivy fs can only take one file/path as argument, so we can only scan the current directory and not pass the files
80-
check = "trivy fs --exit-code 1 --scanners secret ."
95+
check = "mise x trivy -- trivy fs --exit-code 1 --scanners secret ."
8196
}

mise.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[tools]
2+
# for git hooks
23
hk = "latest"
34
pkl = "latest"
4-
prettier = "3"

0 commit comments

Comments
 (0)