-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
109 lines (96 loc) · 4.37 KB
/
Copy pathlefthook.yml
File metadata and controls
109 lines (96 loc) · 4.37 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
# Git hooks for mcp-slack-block-kit. Runs the fast checks locally so CI
# isn't the first thing that catches a typo.
#
# Install once after clone: `make setup` (or `lefthook install` directly).
# Bypass in emergencies: `LEFTHOOK=0 git commit -m "..."` (or `--no-verify`).
#
# Docs: https://lefthook.dev/configuration/
# Pinned to lefthook v1 because v2 currently requires Go 1.26 to build via
# `go install`, and this project targets Go 1.25. v1 has the same hook
# semantics — switch the bound to 2.x once the toolchain bumps.
min_version: 1.11.0
assert_lefthook_installed: true # fail loudly if .git/hooks aren't wired
no_auto_install: false # auto-wire on any lefthook invocation
# Quiet by default. To debug, run with `--verbose` or
# `LEFTHOOK_OUTPUT=meta,summary,success,failure,execution,execution_out`.
output:
- summary
- failure
# ---------------------------------------------------------------------------
# pre-commit: fast checks on staged content (target: under ~3s on a clean tree)
# ---------------------------------------------------------------------------
pre-commit:
parallel: true
skip: [merge, rebase] # don't fight git during merges/rebases
commands:
fmt:
tags: [format]
glob: "*.go"
exclude: '(^|/)(vendor|.*\.pb\.go|.*_gen\.go)(/|$)'
run: gofumpt -w {staged_files}
stage_fixed: true
fail_text: "gofumpt rewrote files; review and recommit."
lint:
tags: [lint]
glob: "*.go"
# Whole-tree lint. Passing {staged_files} to golangci-lint breaks
# typechecking when staged files span multiple Go packages — the
# linter needs each package in one invocation. Whole-tree is fast
# enough on this project (~3s) and matches the CI behavior, so
# contributors don't see green locally then fail in CI.
#
# Project-scoped GOCACHE / GOLANGCI_LINT_CACHE so multiple
# checkouts of the same repo don't fight each other's caches and
# so a stale system-wide cache can't make this hook lie.
run: env GOCACHE=/tmp/mcp-slack-block-kit-gocache GOLANGCI_LINT_CACHE=/tmp/mcp-slack-block-kit-golangci-cache golangci-lint run --timeout=5m ./...
fail_text: "golangci-lint failed. Run: golangci-lint run ./... to see issues."
vet:
tags: [lint]
glob: "*.go"
run: go vet ./... # whole-tree vet is cheap
mod-tidy:
tags: [mod]
glob: "{go.mod,go.sum}"
# -diff exits non-zero if `go mod tidy` would change files,
# without modifying anything.
run: go mod tidy -diff
fail_text: "go.mod/go.sum not tidy. Run: go mod tidy"
# ---------------------------------------------------------------------------
# pre-push: medium checks before code leaves the local machine
# ---------------------------------------------------------------------------
pre-push:
parallel: true
commands:
test-race:
tags: [test]
run: go test -race -count=1 -timeout=120s ./...
fail_text: "Race tests failed."
govulncheck:
tags: [security]
# Standalone gosec is intentionally NOT run — golangci-lint v2
# already bundles gosec, and double-running just creates noise.
run: govulncheck ./...
fail_text: "Known vulnerabilities found. See https://pkg.go.dev/vuln/."
build-smoke:
tags: [build]
run: go build ./...
fuzz-smoke:
tags: [test, fuzz]
# 30-second fuzz smoke; the long fuzz time-budget lives in CI.
# `|| true` means the smoke is informational, not gating.
run: go test -run=^$ -fuzz=. -fuzztime=30s ./internal/splitter/ || true
# ---------------------------------------------------------------------------
# commit-msg: Conventional Commits enforcement (no commitlint dep)
# ---------------------------------------------------------------------------
commit-msg:
commands:
conventional:
tags: [commit-msg]
# {1} is the path to the commit-msg file Lefthook passes in.
run: |
grep -Eq '^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([a-z0-9._/-]+\))?(!)?: .{1,100}$' {1} \
|| (echo "ERROR: commit message must follow Conventional Commits 1.0."; \
echo " format: <type>(<scope>)?: <subject>"; \
echo " types: build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test"; \
echo " example: feat(converter): add task-list checkbox support"; \
exit 1)