-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
100 lines (88 loc) · 2.85 KB
/
.pre-commit-config.yaml
File metadata and controls
100 lines (88 loc) · 2.85 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
# Pre-commit configuration for go-locate project
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_install_hook_types:
- pre-commit
- commit-msg
default_language_version:
golang: "1.24.4"
repos:
# Basic file checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: end-of-file-fixer
- id: check-yaml
- id: check-toml
- id: check-json
- id: check-added-large-files
args: [--maxkb=1024]
- id: check-merge-conflict
- id: check-case-conflict
- id: mixed-line-ending
args: [--fix=lf]
# Go-specific hooks
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
# Go formatting
- id: go-fmt-repo
name: Go Format (gofmt)
description: Format Go source code
# Go mod tidy
- id: go-mod-tidy-repo
name: Go Mod Tidy
description: Ensure go.mod matches source code
# Go vet
- id: go-vet-repo-mod
name: Go Vet
description: Examine Go source code for suspicious constructs
# Go build check
- id: go-build-repo-mod
name: Go Build
description: Build Go packages to check for compilation errors
# GolangCI-Lint (using existing config)
- id: golangci-lint-repo-mod
name: GolangCI-Lint
description: Run golangci-lint with existing configuration
args: [--config=.golangci.yml]
# Local Go tools (using system commands)
- repo: local
hooks:
# Go imports using system goimports
- id: go-imports-local
name: Go Imports (goimports)
description: Update Go import lines
entry: bash -c 'export PATH=$PATH:$(go env GOPATH)/bin && goimports -w .'
language: system
types: [go]
pass_filenames: false
# Go tests with coverage
- id: go-test-local
name: Go Test with Coverage
description: Run Go tests with race detection and coverage
entry: bash -c 'go test -v -race -coverprofile=coverage.out ./...'
language: system
types: [go]
pass_filenames: false
# Security checks
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
name: Detect Secrets
description: Detect secrets in code
args: [--baseline, .secrets.baseline]
exclude: ^(go\.sum|\.secrets\.baseline)$
# Custom commit message validation
- repo: local
hooks:
- id: custom-commit-msg
name: Custom Commit Format
description: Ensure commit messages follow project format [TYPE] - description
entry: scripts/check-commit-msg.sh
language: script
stages: [commit-msg]
pass_filenames: true