Skip to content

Commit 6bafd5e

Browse files
committed
fix: verify respects justfile
Signed-off-by: Josef Andersson <josef.andersson@digg.se>
1 parent e31bb02 commit 6bafd5e

File tree

2 files changed

+142
-50
lines changed

2 files changed

+142
-50
lines changed

scripts/verify.sh

Lines changed: 28 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ source "${SCRIPT_DIR}/../utils/colors.sh"
1313

1414
# Base linters
1515
LINTERS=(
16-
"Commits|conform|${LINTERS_DIR}/commits.sh"
17-
"Secrets|gitleaks|${LINTERS_DIR}/secrets.sh"
18-
"YAML|yamlfmt|${LINTERS_DIR}/yaml.sh check"
19-
"Markdown|rumdl|${LINTERS_DIR}/markdown.sh check"
20-
"Shell Scripts|shellcheck|${LINTERS_DIR}/shell.sh"
21-
"Shell Format|shfmt|${LINTERS_DIR}/shell-fmt.sh check"
22-
"GitHub Actions|actionlint|${LINTERS_DIR}/github-actions.sh"
23-
"License|reuse|${LINTERS_DIR}/license.sh"
24-
"Containers|hadolint|${LINTERS_DIR}/container.sh"
25-
"XML|xmllint|${LINTERS_DIR}/xml.sh"
16+
"Commits|conform|just lint-commits"
17+
"Secrets|gitleaks|just lint-secrets"
18+
"YAML|yamlfmt|just lint-yaml"
19+
"Markdown|rumdl|just lint-markdown"
20+
"Shell Scripts|shellcheck|just lint-shell"
21+
"Shell Format|shfmt|just lint-shell-fmt"
22+
"GitHub Actions|actionlint|just lint-actions"
23+
"License|reuse|just lint-license"
24+
"Containers|hadolint|just lint-container"
25+
"XML|xmllint|just lint-xml"
2626
)
2727

2828
declare -A RESULTS
@@ -31,48 +31,26 @@ detect_language_linters() {
3131
local recipes
3232
recipes=$(just --list 2>&1 || true)
3333

34-
# Java linters - if lint-java exists, use it (calls scripts directly to show each row)
35-
# Otherwise use individual recipes if they exist
36-
if grep -qE "^\s+lint-java\s" <<<"$recipes"; then
37-
local java_lint_dir="$(dirname "${SCRIPT_DIR}")/linters/java"
38-
if [[ -d "$java_lint_dir" ]]; then
39-
LINTERS+=("Java Checkstyle|checkstyle|${java_lint_dir}/checkstyle.sh")
40-
LINTERS+=("Java PMD|pmd|${java_lint_dir}/pmd.sh")
41-
LINTERS+=("Java SpotBugs|spotbugs|${java_lint_dir}/spotbugs.sh")
42-
fi
43-
else
44-
# No lint-java, check for individual recipes
45-
if grep -qE "^\s+lint-java-checkstyle\s" <<<"$recipes"; then
46-
LINTERS+=("Java Checkstyle|checkstyle|just lint-java-checkstyle")
47-
fi
48-
if grep -qE "^\s+lint-java-pmd\s" <<<"$recipes"; then
49-
LINTERS+=("Java PMD|pmd|just lint-java-pmd")
50-
fi
51-
if grep -qE "^\s+lint-java-spotbugs\s" <<<"$recipes"; then
52-
LINTERS+=("Java SpotBugs|spotbugs|just lint-java-spotbugs")
53-
fi
34+
# Java linters - check for individual recipes
35+
if grep -qE "^\s+lint-java-checkstyle(\s|#|$)" <<<"$recipes"; then
36+
LINTERS+=("Java Checkstyle|checkstyle|just lint-java-checkstyle")
37+
fi
38+
if grep -qE "^\s+lint-java-pmd(\s|#|$)" <<<"$recipes"; then
39+
LINTERS+=("Java PMD|pmd|just lint-java-pmd")
40+
fi
41+
if grep -qE "^\s+lint-java-spotbugs(\s|#|$)" <<<"$recipes"; then
42+
LINTERS+=("Java SpotBugs|spotbugs|just lint-java-spotbugs")
5443
fi
5544

56-
# Node linters - if lint-node exists, use it (calls scripts directly to show each row)
57-
# Otherwise use individual recipes if they exist
58-
if grep -qE "^\s+lint-node\s" <<<"$recipes"; then
59-
local node_lint_dir="$(dirname "${SCRIPT_DIR}")/linters/node"
60-
if [[ -d "$node_lint_dir" ]]; then
61-
LINTERS+=("Node ESLint|eslint|${node_lint_dir}/eslint.sh")
62-
LINTERS+=("Node Format|prettier|${node_lint_dir}/format.sh check")
63-
LINTERS+=("Node Types|tsc|${node_lint_dir}/types.sh")
64-
fi
65-
else
66-
# No lint-node, check for individual recipes
67-
if grep -qE "^\s+lint-node-eslint\s" <<<"$recipes"; then
68-
LINTERS+=("Node ESLint|eslint|just lint-node-eslint")
69-
fi
70-
if grep -qE "^\s+lint-node-format\s" <<<"$recipes"; then
71-
LINTERS+=("Node Format|prettier|just lint-node-format")
72-
fi
73-
if grep -qE "^\s+lint-node-ts-types\s" <<<"$recipes"; then
74-
LINTERS+=("Node Types|tsc|just lint-node-ts-types")
75-
fi
45+
# Node linters - check for individual recipes
46+
if grep -qE "^\s+lint-node-eslint(\s|#|$)" <<<"$recipes"; then
47+
LINTERS+=("Node ESLint|eslint|just lint-node-eslint")
48+
fi
49+
if grep -qE "^\s+lint-node-format(\s|#|$)" <<<"$recipes"; then
50+
LINTERS+=("Node Format|prettier|just lint-node-format")
51+
fi
52+
if grep -qE "^\s+lint-node-ts-types(\s|#|$)" <<<"$recipes"; then
53+
LINTERS+=("Node Types|tsc|just lint-node-ts-types")
7654
fi
7755
}
7856

tests/verify.bats

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,117 @@ EOF
103103
assert_output --regexp "[0-9]+ passed"
104104
assert_output --regexp "\(of [0-9]+\)"
105105
}
106+
107+
@test "verify.sh respects justfile recipe overrides for base linters" {
108+
cat > justfile << EOF
109+
# SPDX-FileCopyrightText: 2025 Test
110+
# SPDX-License-Identifier: MIT
111+
lint-commits:
112+
@${DEVBASE_DIR}/linters/commits.sh
113+
lint-secrets:
114+
@${DEVBASE_DIR}/linters/secrets.sh
115+
lint-yaml:
116+
@${DEVBASE_DIR}/linters/yaml.sh check
117+
lint-markdown:
118+
@${DEVBASE_DIR}/linters/markdown.sh check
119+
lint-shell:
120+
@${DEVBASE_DIR}/linters/shell.sh
121+
lint-shell-fmt:
122+
@${DEVBASE_DIR}/linters/shell-fmt.sh check
123+
lint-actions:
124+
@${DEVBASE_DIR}/linters/github-actions.sh
125+
lint-license:
126+
@echo "Skipping license check"
127+
lint-container:
128+
@${DEVBASE_DIR}/linters/container.sh
129+
lint-xml:
130+
@${DEVBASE_DIR}/linters/xml.sh
131+
EOF
132+
133+
run "$SCRIPT_DIR/verify.sh"
134+
135+
# Should show the custom message instead of running license.sh
136+
assert_output --partial "Skipping license check"
137+
# Should NOT run actual license check
138+
refute_output --partial "REUSE"
139+
}
140+
141+
@test "verify.sh respects Java linter recipe overrides" {
142+
cat > justfile << EOF
143+
# SPDX-FileCopyrightText: 2025 Test
144+
# SPDX-License-Identifier: MIT
145+
lint-commits:
146+
@${DEVBASE_DIR}/linters/commits.sh
147+
lint-secrets:
148+
@${DEVBASE_DIR}/linters/secrets.sh
149+
lint-yaml:
150+
@${DEVBASE_DIR}/linters/yaml.sh check
151+
lint-markdown:
152+
@${DEVBASE_DIR}/linters/markdown.sh check
153+
lint-shell:
154+
@${DEVBASE_DIR}/linters/shell.sh
155+
lint-shell-fmt:
156+
@${DEVBASE_DIR}/linters/shell-fmt.sh check
157+
lint-actions:
158+
@${DEVBASE_DIR}/linters/github-actions.sh
159+
lint-license:
160+
@${DEVBASE_DIR}/linters/license.sh
161+
lint-container:
162+
@${DEVBASE_DIR}/linters/container.sh
163+
lint-xml:
164+
@${DEVBASE_DIR}/linters/xml.sh
165+
lint-java-checkstyle:
166+
@echo "Custom Java Checkstyle"
167+
lint-java-pmd:
168+
@${DEVBASE_DIR}/linters/java/pmd.sh
169+
lint-java-spotbugs:
170+
@${DEVBASE_DIR}/linters/java/spotbugs.sh
171+
EOF
172+
173+
run "$SCRIPT_DIR/verify.sh"
174+
175+
# Should show the custom message for overridden recipe
176+
assert_output --partial "Custom Java Checkstyle"
177+
# Should show Java Checkstyle in summary
178+
assert_output --partial "Java Checkstyle"
179+
}
180+
181+
@test "verify.sh respects Node linter recipe overrides" {
182+
cat > justfile << EOF
183+
# SPDX-FileCopyrightText: 2025 Test
184+
# SPDX-License-Identifier: MIT
185+
lint-commits:
186+
@${DEVBASE_DIR}/linters/commits.sh
187+
lint-secrets:
188+
@${DEVBASE_DIR}/linters/secrets.sh
189+
lint-yaml:
190+
@${DEVBASE_DIR}/linters/yaml.sh check
191+
lint-markdown:
192+
@${DEVBASE_DIR}/linters/markdown.sh check
193+
lint-shell:
194+
@${DEVBASE_DIR}/linters/shell.sh
195+
lint-shell-fmt:
196+
@${DEVBASE_DIR}/linters/shell-fmt.sh check
197+
lint-actions:
198+
@${DEVBASE_DIR}/linters/github-actions.sh
199+
lint-license:
200+
@${DEVBASE_DIR}/linters/license.sh
201+
lint-container:
202+
@${DEVBASE_DIR}/linters/container.sh
203+
lint-xml:
204+
@${DEVBASE_DIR}/linters/xml.sh
205+
lint-node-eslint:
206+
@echo "Custom Node ESLint"
207+
lint-node-format:
208+
@${DEVBASE_DIR}/linters/node/format.sh check
209+
lint-node-ts-types:
210+
@${DEVBASE_DIR}/linters/node/types.sh
211+
EOF
212+
213+
run "$SCRIPT_DIR/verify.sh"
214+
215+
# Should show the custom message for overridden recipe
216+
assert_output --partial "Custom Node ESLint"
217+
# Should show Node ESLint in summary
218+
assert_output --partial "Node ESLint"
219+
}

0 commit comments

Comments
 (0)