-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
101 lines (89 loc) · 3.27 KB
/
.pre-commit-config.yaml
File metadata and controls
101 lines (89 loc) · 3.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
# Eos Pre-Commit Hook Configuration
# Last Updated: 2025-11-05
#
# Installation:
# pip install pre-commit
# pre-commit install
#
# Run manually:
# pre-commit run --all-files
#
# Update hooks:
# pre-commit autoupdate
repos:
# Go-specific hooks from TekWizely (most flexible for Go monorepos)
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
# Format Go code
- id: go-fmt
name: Format Go code (gofmt)
description: Ensures all Go code is properly formatted
# Organize imports
- id: go-imports
name: Organize imports (goimports)
description: Ensures imports are organized correctly
# Run go vet
- id: go-vet
name: Static analysis (go vet)
description: Runs go vet for static analysis
args: [] # Can add CGO_ENABLED=1 if needed
# Run golangci-lint
- id: golangci-lint
name: Lint (golangci-lint)
description: Runs golangci-lint with project config
args: [--timeout=5m]
# Ensure go.mod and go.sum are tidy
- id: go-mod-tidy
name: Verify go.mod is tidy
description: Ensures go.mod and go.sum are up to date
args: [-v]
# Local hooks for custom checks
- repo: local
hooks:
# Enforce local/CI parity lane via npm wrapper
- id: ci-debug-parity
name: CI debug parity gate (npm run ci:debug)
entry: npm run ci:debug --silent
language: system
pass_filenames: false
require_serial: true
description: Runs the same ci:debug lane used by hooks and CI
# Run fast tests (skip integration and E2E)
- id: go-test-fast
name: Run unit tests
entry: go test -race -short -v ./...
language: system
pass_filenames: false
description: Runs fast unit tests with race detector
# Check test coverage
- id: go-coverage-check
name: Check test coverage
entry: bash -c 'go test -coverprofile=coverage.out -covermode=atomic ./... && go run github.com/vladopajic/go-test-coverage/v2@latest --config=.testcoverage.yml'
language: system
pass_filenames: false
description: Ensures test coverage meets thresholds
# Build verification
- id: go-build
name: Verify build
entry: go build -o /tmp/eos-build-precommit .
language: system
pass_filenames: false
description: Ensures code compiles successfully
# Verify environment-dependent tests are build-tagged
- id: verify-test-build-tags
name: Verify test build tags
entry: bash scripts/ci/check-test-tags.sh
language: system
pass_filenames: false
description: Ensures environment-dependent tests keep their explicit build tags
# Check for deprecated benchmark pattern
- id: check-benchmark-pattern
name: Check for deprecated benchmarks
entry: bash -c '! git grep -n "for.*b\.N.*{" -- "*_test.go" || { echo "ERROR: Found deprecated benchmark pattern. Use B.Loop() instead of for b.N"; exit 1; }'
language: system
pass_filenames: false
description: Detects deprecated benchmark patterns
# Global settings
fail_fast: false # Run all hooks even if one fails
minimum_pre_commit_version: '2.20.0'