-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yml
More file actions
104 lines (94 loc) · 3.99 KB
/
Copy pathlefthook.yml
File metadata and controls
104 lines (94 loc) · 3.99 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
# SPDX-FileCopyrightText: 2026 Uberware Inc. <https://uberware.net>
# SPDX-License-Identifier: AGPL-3.0-or-later
# lefthook — Git hook runner for sqi
# Docs: https://lefthook.dev/configuration/
#
# Install hooks into .git/hooks/ by running:
# make hooks
# or directly:
# lefthook install
#
# Install lefthook itself:
# go install github.com/evilmartians/lefthook@latest
#
# To bypass hooks for a single commit (e.g. a WIP commit):
# git commit --no-verify
#
# Developer-local overrides (not committed) live in lefthook-local.yml.
# Example use: disable the slow golangci-lint step locally while keeping
# formatting and vet checks active.
min_version: "1.6.0"
assert_lefthook_installed: true
# ── pre-commit ────────────────────────────────────────────────────────────────
# Runs on every `git commit`. Steps are ordered by priority and piped —
# if formatting fails, lint will not run (avoids noisy output on partial fixes).
pre-commit:
piped: true # stop the chain on first failure
commands:
# Step 1 — format staged Go files with gofumpt and re-stage the result.
# gofumpt is a stricter superset of gofmt.
# Install: go install mvdan.cc/gofumpt@latest
gofumpt:
priority: 1
glob: "*.go"
run: gofumpt -l -w {staged_files}
stage_fixed: true
fail_text: "gofumpt failed — is it installed? (go install mvdan.cc/gofumpt@latest)"
# Step 2 — organise imports with goimports and re-stage.
# Keeps stdlib / external / internal groups separate.
# Install: go install golang.org/x/tools/cmd/goimports@latest
goimports:
priority: 2
glob: "*.go"
run: goimports -local github.com/uberware/sqi -l -w {staged_files}
stage_fixed: true
fail_text: "goimports failed — is it installed? (go install golang.org/x/tools/cmd/goimports@latest)"
# Step 3 — go vet across the whole module.
# Fast; catches common correctness issues that don't require the full
# linter suite.
go-vet:
priority: 3
glob: "*.go"
run: go vet ./...
fail_text: "go vet found issues — run 'make vet' for details"
# Step 4 — golangci-lint with auto-fix enabled.
# Slower than vet (~5–30 s depending on codebase size). Skip it locally
# by adding the following to lefthook-local.yml:
#
# pre-commit:
# commands:
# golangci-lint:
# skip: true
#
golangci-lint:
priority: 4
glob: "*.go"
run: golangci-lint run --fix ./...
stage_fixed: true
fail_text: "golangci-lint found issues — run 'make lint-fix' to apply fixes"
# ── commit-msg ────────────────────────────────────────────────────────────────
# Enforces Conventional Commits format so the CHANGELOG can be generated
# automatically. Merge commits and fixups are exempt.
#
# Valid format: type(optional-scope): description
# Valid types: feat fix docs style refactor test chore build ci perf revert
# Examples:
# feat(scheduler): add usage-pool admission check
# fix: correct heartbeat timeout calculation
# chore: bump golangci-lint to v1.60
commit-msg:
commands:
conventional-commits:
# {1} is the path to the file containing the commit message.
# grep exits 0 if the pattern matches, non-zero otherwise.
run: >
grep -qE
"^(feat|fix|docs|style|refactor|test|chore|build|ci|perf|revert)(\(.+\))?(!)?: .{1,}"
{1}
|| (grep -qE "^(Merge|fixup!|squash!)" {1})
fail_text: |
Commit message does not follow Conventional Commits.
Expected: type(scope)?: short description
Example: feat(scheduler): add usage-pool admission check
Types: feat fix docs style refactor test chore build ci perf revert
Docs: https://www.conventionalcommits.org