-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
204 lines (170 loc) · 6.3 KB
/
Copy pathlefthook.yml
File metadata and controls
204 lines (170 loc) · 6.3 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
201
202
203
204
# lefthook.yml
# Migrated from pre-commit
#
# INSTALL: lefthook install
# MANUAL PIPELINES:
# lefthook run security-full
# lefthook run codeql (sequential: go → js → findings → parity)
# lefthook run testing
# lefthook run lint-full
#
# TOOL REQUIREMENTS (no longer managed by pre-commit, must be installed):
# shellcheck, actionlint, markdownlint, semgrep, gitleaks, hadolint (docker)
# All existing scripts are reused as-is — no changes to scripts/ needed.
# ============================================================
# PRE-COMMIT (blocking, runs on every commit)
# ============================================================
pre-commit:
parallel: true
commands:
# --- File hygiene (replaces pre-commit/pre-commit-hooks) ---
end-of-file-fixer:
glob: "*.{go,ts,tsx,js,jsx,yaml,yml,sh,md}"
exclude: "frontend/(coverage|dist|node_modules|\\.vite)/|.*\\.tsbuildinfo$"
run: |
modified=0
for file in {staged_files}; do
[ -f "$file" ] && [ -s "$file" ] && \
[ -n "$(tail -c1 "$file")" ] && echo >> "$file" && modified=1
done
if [ "$modified" -eq 1 ]; then
git add {staged_files}
echo "end-of-file-fixer: files modified and re-staged — review changes and commit again."
exit 1
fi
trailing-whitespace:
glob: "*.{go,ts,tsx,js,jsx,yaml,yml,sh,md}"
exclude: "frontend/(coverage|dist|node_modules|\\.vite)/|.*\\.tsbuildinfo$"
run: |
modified=0
for file in {staged_files}; do
if grep -qP '\s+$' "$file" 2>/dev/null; then
sed -i 's/[[:space:]]*$//' "$file" && modified=1
fi
done
if [ "$modified" -eq 1 ]; then
git add {staged_files}
echo "trailing-whitespace: trailing spaces removed and re-staged — review changes and commit again."
exit 1
fi
check-yaml:
glob: "*.{yaml,yml}"
run: python3 -c "import sys,yaml; [yaml.safe_load(open(f)) for f in sys.argv[1:]]" {staged_files}
# --- Blocking security/commit guards (always run) ---
check-lfs-large-files:
run: bash scripts/pre-commit-hooks/check-lfs-for-large-files.sh
block-codeql-db:
run: bash scripts/pre-commit-hooks/block-codeql-db-commits.sh
block-data-backups:
run: bash scripts/pre-commit-hooks/block-data-backups-commit.sh
# --- Shell / Actions / Docker ---
shellcheck:
glob: "*.sh"
exclude: "frontend/(coverage|dist|node_modules|\\.vite)/|test-results|codeql-agent-results"
run: shellcheck --severity=error {staged_files}
actionlint:
glob: ".github/workflows/*.{yaml,yml}"
run: actionlint {staged_files}
dockerfile-check:
glob: "Dockerfile*"
run: tools/dockerfile_check.sh {staged_files}
# --- Go ---
go-vet:
glob: "*.go"
run: cd backend && go vet ./...
golangci-lint-fast:
glob: "*.go"
run: scripts/pre-commit-hooks/golangci-lint-fast.sh
check-version-match:
glob: ".version"
run: bash scripts/check-version-match-tag.sh
# --- Frontend ---
# NOTE: ESLint upgraded to v10.x. Overrides in frontend/package.json for
# react-hooks, jsx-a11y, promise plugins (peer deps not yet updated).
# Remove overrides when plugins declare ESLint v10 support natively.
frontend-type-check:
glob: "frontend/**/*.{ts,tsx}"
run: cd frontend && /usr/share/nodejs/corepack/shims/npx tsc --noEmit
frontend-lint:
glob: "frontend/**/*.{ts,tsx,js,jsx}"
run: cd frontend && /usr/share/nodejs/corepack/shims/npm run lint
semgrep:
glob: "{**/*.{go,ts,tsx,js,jsx,sh,yml,yaml,json},Dockerfile*}"
exclude: 'frontend/(coverage|dist|node_modules|\.vite)/'
run: scripts/pre-commit-hooks/semgrep-scan.sh {staged_files}
# ============================================================
# MANUAL: security-full
# Run with: lefthook run security-full
# ============================================================
security-full:
parallel: true
commands:
security-scan:
glob: "*.go"
run: scripts/security-scan.sh
gorm-scan:
glob: "*.go"
run: scripts/pre-commit-hooks/gorm-security-check.sh
gitleaks:
run: scripts/pre-commit-hooks/gitleaks-tuned-scan.sh
semgrep:
glob: "{**/*.{go,ts,tsx,js,jsx,sh,yml,yaml,json},Dockerfile*}"
exclude: 'frontend/(coverage|dist|node_modules|\.vite)/'
run: scripts/pre-commit-hooks/semgrep-scan.sh
# ============================================================
# MANUAL: codeql
# Run with: lefthook run codeql
# MUST remain sequential — findings check depends on scan output
# ============================================================
codeql:
parallel: false
commands:
1-go-scan:
glob: "*.go"
run: scripts/pre-commit-hooks/codeql-go-scan.sh
2-js-scan:
glob: "frontend/**/*.{ts,tsx,js,jsx}"
run: scripts/pre-commit-hooks/codeql-js-scan.sh
3-check-findings:
run: scripts/pre-commit-hooks/codeql-check-findings.sh
4-parity-check:
run: scripts/ci/check-codeql-parity.sh
# ============================================================
# MANUAL: testing
# Run with: lefthook run testing
# ============================================================
testing:
parallel: true
commands:
go-test-coverage:
glob: "*.go"
run: scripts/go-test-coverage.sh
go-test-race:
glob: "*.go"
run: cd backend && go test -race ./...
frontend-test-coverage:
glob: "frontend/**/*.{ts,tsx,js,jsx}"
run: scripts/frontend-test-coverage.sh
# ============================================================
# MANUAL: lint-full
# Run with: lefthook run lint-full
# ============================================================
lint-full:
parallel: false
commands:
golangci-lint-full:
glob: "*.go"
run: scripts/pre-commit-hooks/golangci-lint-full.sh
hadolint:
glob: "Dockerfile*"
run: docker run --rm -i hadolint/hadolint < Dockerfile
markdownlint:
run: |
markdownlint --fix .; md_exit=$?
if ! git diff --quiet; then
git add -A
echo "markdownlint: auto-fixed files and re-staged — review changes and commit again."
exit 1
fi
exit $md_exit
exclude: "node_modules|\\.venv|test-results|codeql-db|codeql-agent-results"