forked from diggsweden/devbase-check
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
200 lines (167 loc) · 5.27 KB
/
justfile
File metadata and controls
200 lines (167 loc) · 5.27 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# SPDX-FileCopyrightText: 2025 Digg - Agency for Digital Government
#
# SPDX-License-Identifier: CC0-1.0
# Quality checks and automation for devbase-check
# Run 'just' to see available commands
lint := "./linters"
colors := "./utils/colors.sh"
# Color variables
CYAN_BOLD := "\\033[1;36m"
GREEN := "\\033[1;32m"
BLUE := "\\033[1;34m"
MAGENTA := "\\033[1;35m"
NC := "\\033[0m"
# ==================================================================================== #
# DEFAULT - Show available recipes
# ==================================================================================== #
# Display available recipes
default:
@printf "{{CYAN_BOLD}} DevBase Check{{NC}}\n"
@printf "\n"
@printf "Quick start: {{GREEN}}just verify{{NC}} | {{BLUE}}just lint-all{{NC}} | {{MAGENTA}}just lint-fix{{NC}}\n"
@printf "\n"
@just --list --unsorted
# ==================================================================================== #
# SETUP - Install development tools
# ==================================================================================== #
# ▪ Install development tools via mise
[group('setup')]
install:
@mise install
# ==================================================================================== #
# VERIFY - Quality assurance
# ==================================================================================== #
# ▪ Run all linters with summary
[group('verify')]
verify:
@./scripts/verify.sh
# ==================================================================================== #
# LINT - Code quality checks
# ==================================================================================== #
# ▪ Run all base linters (universal linters for any project)
[group('lint')]
lint-base:
@./scripts/verify.sh
# ▪ Run all linters (default, uses lint-base)
[group('lint')]
lint-all: lint-base
# Validate commit messages (conform)
[group('lint')]
lint-commits:
@{{lint}}/commits.sh
# Scan for secrets (gitleaks)
[group('lint')]
lint-secrets:
@{{lint}}/secrets.sh
# Lint YAML files (yamlfmt)
[group('lint')]
lint-yaml:
@{{lint}}/yaml.sh check
# Lint markdown files (rumdl)
[group('lint')]
lint-markdown:
@{{lint}}/markdown.sh check MD013
# Lint shell scripts (shellcheck)
[group('lint')]
lint-shell:
@{{lint}}/shell.sh
# Check shell formatting (shfmt)
[group('lint')]
lint-shell-fmt:
@{{lint}}/shell-fmt.sh check
# Lint GitHub Actions (actionlint)
[group('lint')]
lint-actions:
@{{lint}}/github-actions.sh
# Check license compliance (reuse)
[group('lint')]
lint-license:
@{{lint}}/license.sh
# Lint containers (hadolint)
[group('lint')]
lint-container:
@{{lint}}/container.sh
# Lint XML files (xmllint)
[group('lint')]
lint-xml:
@{{lint}}/xml.sh
# ==================================================================================== #
# LINT-FIX - Auto-fix linting violations
# ==================================================================================== #
# ▪ Fix all auto-fixable issues
[group('lint-fix')]
lint-fix: lint-yaml-fix lint-markdown-fix lint-shell-fmt-fix
#!/usr/bin/env bash
source "{{colors}}"
just_success "All auto-fixes completed"
# Fix YAML formatting
[group('lint-fix')]
lint-yaml-fix:
@{{lint}}/yaml.sh fix
# Fix markdown formatting
[group('lint-fix')]
lint-markdown-fix:
@{{lint}}/markdown.sh fix MD013
# Fix shell formatting
[group('lint-fix')]
lint-shell-fmt-fix:
@{{lint}}/shell-fmt.sh fix
# ==================================================================================== #
# TEST - Run tests
# ==================================================================================== #
# ▪ Run all tests
[group('test')]
test:
#!/usr/bin/env bash
set -uo pipefail
if ! command -v bats &>/dev/null; then
printf "Error: bats not installed. Run 'just test-setup' first.\n" >&2
exit 1
fi
[[ -d tests/libs ]] || ./tests/setup-bats-libs.sh
bats tests/
result=$?
if [[ $result -le 1 ]]; then exit 0; else exit $result; fi
# Setup test dependencies (bats libraries)
[group('test')]
test-setup:
@./tests/setup-bats-libs.sh
# Run tests with verbose output
[group('test')]
test-verbose:
#!/usr/bin/env bash
set -uo pipefail
if ! command -v bats &>/dev/null; then
printf "Error: bats not installed. Run 'just test-setup' first.\n" >&2
exit 1
fi
[[ -d tests/libs ]] || ./tests/setup-bats-libs.sh
bats --verbose-run tests/
result=$?
if [[ $result -le 1 ]]; then exit 0; else exit $result; fi
# Run specific test file
[group('test')]
test-file file:
#!/usr/bin/env bash
set -uo pipefail
if ! command -v bats &>/dev/null; then
printf "Error: bats not installed. Run 'just test-setup' first.\n" >&2
exit 1
fi
[[ -d tests/libs ]] || ./tests/setup-bats-libs.sh
bats "tests/{{file}}"
result=$?
if [[ $result -le 1 ]]; then exit 0; else exit $result; fi
# Run tests matching a filter
[group('test')]
test-filter filter:
#!/usr/bin/env bash
set -uo pipefail
if ! command -v bats &>/dev/null; then
printf "Error: bats not installed. Run 'just test-setup' first.\n" >&2
exit 1
fi
[[ -d tests/libs ]] || ./tests/setup-bats-libs.sh
bats -f "{{filter}}" tests/
result=$?
if [[ $result -le 1 ]]; then exit 0; else exit $result; fi