Skip to content

Commit e31bb02

Browse files
committed
feat: add bats tests, renovate
Signed-off-by: Josef Andersson <josef.andersson@digg.se>
1 parent 28a9982 commit e31bb02

22 files changed

+947
-54
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/libs/

.mise.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ PIP_INDEX_URL = "{{ get_env(name='PIP_INDEX_URL', default='') }}"
2929
"aqua:google/yamlfmt" = "v0.20.0"
3030
"aqua:hadolint/hadolint" = "v2.12.0"
3131
"pipx:reuse" = "6.2.0"
32+
"aqua:bats-core/bats-core" = "1.13.0"

README.md

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -112,35 +112,55 @@ Override `lint-all` in your justfile to add Java, Node, Python, etc.:
112112
```just
113113
java_lint := devtools_dir + "/linters/java"
114114
115-
# Extend base linters with Java-specific ones
116-
lint-all: _ensure-devtools lint-java
117-
#!/usr/bin/env bash
118-
source "{{colors}}"
119-
just --justfile {{devtools_dir}}/justfile lint-base
120-
just_success "All linting checks completed"
115+
# Run all linters with summary (automatically detects Java linters)
116+
lint-all: _ensure-devtools
117+
@{{devtools_dir}}/scripts/verify.sh
121118
119+
# Run all Java linters together (convenience command)
122120
lint-java:
123121
@{{java_lint}}/lint.sh
122+
123+
# Individual Java linters (auto-detected by verify.sh)
124+
lint-java-checkstyle:
125+
@{{java_lint}}/checkstyle.sh
126+
127+
lint-java-pmd:
128+
@{{java_lint}}/pmd.sh
129+
130+
lint-java-spotbugs:
131+
@{{java_lint}}/spotbugs.sh
124132
```
125133

134+
When you run `just lint-all` or `just verify`, the verify script automatically detects `lint-java-checkstyle`, `lint-java-pmd`, and `lint-java-spotbugs` recipes and runs them individually with a summary table. You can also run `just lint-java` to execute all Java linters together.
135+
126136
See [`examples/java-justfile`](examples/java-justfile) for a complete example.
127137

128138
### Node/TypeScript Project
129139

130140
```just
131141
node_lint := devtools_dir + "/linters/node"
132142
133-
# Extend base linters with Node linters
134-
lint-all: _ensure-devtools lint-node
135-
#!/usr/bin/env bash
136-
source "{{colors}}"
137-
just --justfile {{devtools_dir}}/justfile lint-base
138-
just_success "All linting checks completed"
143+
# Run all linters with summary (automatically detects Node linters)
144+
lint-all: _ensure-devtools
145+
@{{devtools_dir}}/scripts/verify.sh
139146
147+
# Run all Node linters together (convenience command)
140148
lint-node:
141149
@{{node_lint}}/lint.sh
150+
151+
# Individual Node linters (auto-detected by verify.sh)
152+
lint-node-eslint:
153+
@{{node_lint}}/eslint.sh
154+
155+
lint-node-format:
156+
@{{node_lint}}/format.sh check
157+
158+
lint-node-ts-types:
159+
@{{node_lint}}/types.sh
142160
```
143161

162+
When you run `just lint-all` or `just verify`, the verify script automatically detects `lint-node-*` recipes and runs them individually with a summary table. You can also run `just lint-node` to execute all Node linters together.
163+
144164
See [`examples/node-justfile`](examples/node-justfile) for a complete example.
145165

146166
### Python Project
@@ -203,21 +223,33 @@ lint-rust:
203223
### Minimal Project (base linters only)
204224

205225
```just
206-
# Run all linters (uses base linters only)
226+
# Run all linters with summary (base linters only)
207227
lint-all: _ensure-devtools
208-
@just --justfile {{devtools_dir}}/justfile lint-base
228+
@{{devtools_dir}}/scripts/verify.sh
209229
```
210230

211231
### Multiple Languages
212232

213233
```just
214-
lint-all: _ensure-devtools lint-java lint-python lint-node
215-
#!/usr/bin/env bash
216-
source "{{colors}}"
217-
just --justfile {{devtools_dir}}/justfile lint-base
218-
just_success "All linting checks completed"
234+
# Define linters from multiple languages - verify.sh auto-detects them all
235+
lint-all: _ensure-devtools
236+
@{{devtools_dir}}/scripts/verify.sh
237+
238+
# Java linters
239+
lint-java-checkstyle:
240+
@{{java_lint}}/checkstyle.sh
241+
242+
# Python linters
243+
lint-python:
244+
ruff check .
245+
246+
# Node linters
247+
lint-node-eslint:
248+
@{{node_lint}}/eslint.sh
219249
```
220250

251+
All defined `lint-*` recipes are automatically detected and included in the summary.
252+
221253
## Utilities
222254

223255
Use `colors.sh` for consistent output in custom recipes:

REUSE.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ path = [
1111
"REUSE.toml",
1212
".mise.toml",
1313
"justfile",
14+
".gitignore",
1415
"renovate.json",
1516
".github/**/*.yml",
1617
"examples/*",

examples/java-justfile

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,22 +67,18 @@ tools-install: _ensure-devtools
6767

6868
# ▪ Run all checks
6969
[group('verify')]
70-
verify: _ensure-devtools check-tools lint-all test
71-
#!/usr/bin/env bash
72-
source "{{colors}}"
73-
just_success "All checks passed"
70+
verify: _ensure-devtools check-tools
71+
@{{devtools_dir}}/scripts/verify.sh
72+
@just test
7473

7574
# ==================================================================================== #
7675
# LINT
7776
# ==================================================================================== #
7877

79-
# ▪ Run all linters (base + Java)
78+
# ▪ Run all linters with summary
8079
[group('lint')]
81-
lint-all: _ensure-devtools lint-java
82-
#!/usr/bin/env bash
83-
source "{{colors}}"
84-
just --justfile {{devtools_dir}}/justfile lint-base
85-
just_success "All linting checks completed"
80+
lint-all: _ensure-devtools
81+
@{{devtools_dir}}/scripts/verify.sh
8682

8783
# Individual base linters (can be run separately)
8884
[group('lint')]

justfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,20 @@ lint-markdown-fix:
124124
[group('lint-fix')]
125125
lint-shell-fmt-fix:
126126
@{{lint}}/shell-fmt.sh fix
127+
128+
# ==================================================================================== #
129+
# TEST - Run tests
130+
# ==================================================================================== #
131+
132+
# ▪ Setup test dependencies (BATS libraries)
133+
[group('test')]
134+
test-setup:
135+
@./tests/setup-bats-libs.sh
136+
137+
# ▪ Run all tests
138+
[group('test')]
139+
test:
140+
#!/usr/bin/env bash
141+
eval "$(mise activate bash)"
142+
[[ -d tests/libs ]] || ./tests/setup-bats-libs.sh
143+
bats tests/

linters/node/eslint.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ main() {
1919

2020
# Check if project has ESLint configured
2121
if [[ ! -f "package.json" ]]; then
22-
print_warn "No package.json found. Skipping ESLint"
22+
print_warning "No package.json found. Skipping ESLint"
2323
return 0
2424
fi
2525

2626
if ! grep -q "eslint" package.json 2>/dev/null; then
27-
print_warn "ESLint not configured in package.json. Skipping"
27+
print_warning "ESLint not configured in package.json. Skipping"
2828
return 0
2929
fi
3030

linters/node/format.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ main() {
4343

4444
# Check if project has Prettier configured
4545
if [[ ! -f "package.json" ]]; then
46-
print_warn "No package.json found. Skipping Prettier"
46+
print_warning "No package.json found. Skipping Prettier"
4747
return 0
4848
fi
4949

5050
if ! grep -q "prettier" package.json 2>/dev/null; then
51-
print_warn "Prettier not configured in package.json. Skipping"
51+
print_warning "Prettier not configured in package.json. Skipping"
5252
return 0
5353
fi
5454

linters/node/types.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ main() {
1919

2020
# Check if project has TypeScript configured
2121
if [[ ! -f "tsconfig.json" ]] && [[ ! -f "package.json" ]]; then
22-
print_warn "No tsconfig.json or package.json found. Skipping type checking"
22+
print_warning "No tsconfig.json or package.json found. Skipping type checking"
2323
return 0
2424
fi
2525

2626
if [[ -f "package.json" ]] && ! grep -q "typescript" package.json 2>/dev/null; then
27-
print_warn "TypeScript not configured in package.json. Skipping"
27+
print_warning "TypeScript not configured in package.json. Skipping"
2828
return 0
2929
fi
3030

linters/shell.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
1010
source "${SCRIPT_DIR}/../utils/colors.sh"
1111

1212
find_shell_scripts() {
13-
find . -type f \( -name "*.sh" -o -name "*.bash" \) -not -path "./.git/*" 2>/dev/null
13+
find . -type f \( -name "*.sh" -o -name "*.bash" \) \
14+
-not -path "./.git/*" \
15+
-not -path "./tests/libs/*" \
16+
2>/dev/null
1417
}
1518

1619
main() {

0 commit comments

Comments
 (0)