-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlefthook.yaml
More file actions
82 lines (73 loc) · 2.08 KB
/
lefthook.yaml
File metadata and controls
82 lines (73 loc) · 2.08 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
# Lefthook configuration for Coro
# See: https://github.com/evilmartians/lefthook
pre-commit:
parallel: true
commands:
# Formatting checks
gofmt:
glob: "*.go"
run: |
unformatted=$(gofmt -l {staged_files})
if [ -n "$unformatted" ]; then
echo "The following files are not formatted:"
echo "$unformatted"
echo ""
echo "Run: gofmt -w ."
exit 1
fi
# Go module tidiness check
gomod:
glob: "go.{mod,sum}"
run: |
go mod tidy
if ! git diff --exit-code go.mod go.sum; then
echo "go.mod or go.sum is not tidy. Run: go mod tidy"
exit 1
fi
# Linting
golangci-lint:
glob: "*.go"
run: golangci-lint run --new-from-rev=HEAD~1
# Proto file linting (only if proto files changed)
buf-lint:
glob: "proto/**/*.proto"
run: make buf-lint
# Check for common debugging artifacts
debug-check:
glob: "*.go"
run: |
matches=$(grep -rn "fmt.Print\|spew.Dump(" {staged_files} || true)
if [ -n "$matches" ]; then
echo "Warning: Found potential debugging code:"
echo "$matches"
echo ""
echo "Remove debugging statements before committing"
exit 1
fi
# Quick unit tests on changed packages
unit-tests:
glob: "*.go"
run: |
# Get unique packages from staged files
packages=$(echo "{staged_files}" | xargs -n1 dirname | sort -u | sed 's|^|./|' | tr '\n' ' ')
if [ -n "$packages" ]; then
go test $packages -race -count=1 -short
fi
pre-push:
parallel: false
commands:
# Full unit test suite
all-unit-tests:
run: make unit-test
# Integration tests - ensure postgres is fresh
integration-tests:
run: |
echo "Restarting postgres for integration tests..."
make restart-postgres
echo "Running integration tests..."
make integration-test
# Final build check
build:
run: |
mkdir -p build
go build -o build/ ./...