Skip to content

Commit 7041731

Browse files
committed
Initial add of hooks
Taking scripts from: https://github.com/dnephin/pre-commit-golang to start. We will improve these scripts from here. Signed-off-by: Bryan Hundven <[email protected]>
1 parent c58c28a commit 7041731

15 files changed

+953
-0
lines changed

.pre-commit-config.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
repos:
3+
- repo: https://github.com/pre-commit/pre-commit-hooks
4+
rev: v5.0.0
5+
hooks:
6+
- id: check-case-conflict
7+
- id: check-illegal-windows-names
8+
- id: check-merge-conflict
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
- id: check-json
12+
- id: no-commit-to-branch
13+
- repo: https://github.com/rhysd/actionlint
14+
rev: v1.7.7
15+
hooks:
16+
- id: actionlint
17+
- repo: https://github.com/adrienverge/yamllint.git
18+
rev: v1.35.1
19+
hooks:
20+
- id: yamllint
21+
args: [--strict, -c=.yamllint.yaml]
22+
- repo: https://github.com/koalaman/shellcheck-precommit
23+
rev: v0.10.0
24+
hooks:
25+
- id: shellcheck

.pre-commit-hooks.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
- id: go-fmt
3+
name: 'gofmt'
4+
entry: pre-commit-hooks/gofmt.sh
5+
types: [go]
6+
exclude: '(^|/)vendor/'
7+
language: 'script'
8+
description: "Runs `gofmt`. Requires golang"
9+
pass_filenames: true
10+
- id: go-imports
11+
name: 'goimports'
12+
entry: pre-commit-hooks/go-imports.sh
13+
types: [go]
14+
exclude: '(^|/)vendor/'
15+
language: 'script'
16+
description: "Runs `goimports`. Requires golang and goimports"
17+
pass_filenames: true
18+
- id: go-vet
19+
name: 'go vet'
20+
entry: pre-commit-hooks/go-vet.sh
21+
types: [go]
22+
exclude: '(^|/)vendor/'
23+
language: 'script'
24+
description: "Runs `go vet`. Requires golang"
25+
pass_filenames: true
26+
- id: go-lint
27+
name: 'golint'
28+
entry: pre-commit-hooks/go-lint.sh
29+
types: [go]
30+
exclude: '(^|/)vendor/'
31+
language: 'script'
32+
description: "Runs `golint`. Requires golang and golint"
33+
pass_filenames: true
34+
- id: golangci-lint
35+
name: 'golangci-lint'
36+
entry: pre-commit-hooks/golangci-lint.sh
37+
types: [go]
38+
exclude: '(^|/)vendor/'
39+
language: 'script'
40+
description: "Runs `golangci-lint`. Requires golangci-lint"
41+
pass_filenames: true
42+
- id: go-critic
43+
name: "gocritic"
44+
entry: pre-commit-hooks/go-critic.sh
45+
types: [go]
46+
exclude: '(^|/)vendor/'
47+
language: 'script'
48+
description: "Runs `gocritic`. Requires gocritic"
49+
pass_filenames: true
50+
- id: go-unit-tests
51+
name: 'go test'
52+
entry: pre-commit-hooks/go-unit-tests.sh
53+
types: [go]
54+
exclude: '(^|/)vendor/'
55+
language: 'script'
56+
description: "Runs `go test`"
57+
pass_filenames: false
58+
- id: go-build
59+
name: 'go build'
60+
entry: pre-commit-hooks/go-build.sh
61+
types: [go]
62+
language: 'script'
63+
description: "Runs `go build`"
64+
pass_filenames: false
65+
- id: go-generate
66+
name: 'go generate'
67+
entry: pre-commit-hooks/go-build.sh
68+
types: [go]
69+
language: 'script'
70+
description: "Runs `go generate`"
71+
pass_filenames: true
72+
- id: go-mod-tidy
73+
name: 'go mod tidy'
74+
entry: pre-commit-hooks/go-mod-tidy.sh
75+
types: [go]
76+
language: 'script'
77+
description: "Runs `go mod tidy -v`"
78+
pass_filenames: true
79+
- id: go-mod-vendor
80+
name: 'go mod vendor'
81+
entry: pre-commit-hooks/go-mod-vendor.sh
82+
types: [go]
83+
language: 'script'
84+
description: "Runs `go mod vendor`"
85+
pass_filenames: false

.yamllint.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
extends: default
3+
4+
yaml-files:
5+
- '*.yaml'
6+
- '*.yml'
7+
8+
# Github workflows are checked by actionlint
9+
ignore: |
10+
.github/workflows/
11+
12+
# rules:

0 commit comments

Comments
 (0)