-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.pre-commit-config.yaml
171 lines (158 loc) · 6.33 KB
/
.pre-commit-config.yaml
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
---
# IF ERROR ON INSTALL:
# brew uninstall pre-commit
# install with non-admin install this works on mac
# curl https://pre-commit.com/install-local.py | python -
# Setup: pre-commit install
# Upgrade: pre-commit autoupdate
# Run: pre-commit run --all-files
# https://pre-commit.com/hooks.html
default_language_version:
# force all unspecified python hooks to run python3
python: python3
exclude: (.terraform.lock.hcl)|(.devcontainer/)|(.cache/)|(.vscode/)
repos:
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
# https://github.com/jumanjihouse/pre-commit-hook-yamlfmt#override-defaults
# https://yaml.readthedocs.io/en/latest/example.html
rev: 0.1.0 # or specific tag
hooks:
- id: yamlfmt
args: [--mapping, "2", --sequence, "4", --offset, "2", --width, "200"] # set width high to avoid breaking a few pre-commit style inline scripts
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.26.3 # or higher tag
hooks:
- id: yamllint
args: [--format, parsable, --strict]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.0.1 # Use the ref you want to point at
# Documentation on the arguments for these hooks https://github.com/pre-commit/pre-commit-hooks
hooks:
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
- id: check-byte-order-marker
- id: check-case-conflict
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: mixed-line-ending
args: [--fix=lf]
- id: pretty-format-json
exclude: ^.vscode/
args: [--autofix, --no-ensure-ascii]
- id: check-yaml
# - id: detect-private-key
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: check-added-large-files
- id: check-merge-conflict
- id: forbid-new-submodules
- id: name-tests-test
- id: sort-simple-yaml
# - id: no-commit-to-branch
# args: [--branch, develop, --branch, master, --branch, main]
- id: requirements-txt-fixer
- id: check-toml
- repo: https://gitlab.com/bmares/check-json5
rev: v1.0.0
hooks:
- id: check-json5
# stages: ['commit']
# https://pre-commit.com/#supported-languages
- repo: local
hooks:
- id: shellcheck
name: shellcheck
entry: zsh -c docker run --rm -v "${PWD}:/mnt" koalaman/shellcheck:stable --format=json
language: system
- repo: https://github.com/tchoedak/pre-commit-sql-format
rev: v0.0.3
hooks:
- id: format-sql
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.3.2
hooks:
- id: markdownlint-cli2
- repo: https://github.com/zricethezav/gitleaks
rev: v8.2.0
hooks:
- id: gitleaks
# - repo: local
# hooks:
# - id: gitleaks
# name: gitleaks
# entry: gitleaks --commit=latest --no-git --format json --path=. --report=.artifacts/gitleaks.json --quiet
# language: system
# pass_filenames: false
# stages: [push]
# Go Local Hooks
- repo: local
hooks:
- id: golines
name: go-fmt
description: Run formatter against changed files
entry: golines --base-formatter="gofumpt" -w --max-len=120 --reformat-tags
types: [go]
language: golang
pass_filenames: true
- id: golangci-lint
name: golangci-lint
description: Fast linters runner for Go.
entry: golangci-lint run --fix
types: [go]
language: golang
pass_filenames: false
# pre-commit run --hook-stage push
- id: go-test-all
name: go-test-all
description: Run integration tests for go
#entry: GOTESTS='slow' go test ./... -json -v -shuffle=on -race -tags integration | tparse -notests -smallscreen -pulse 1s
# no race conditions for this because we are doing build tasks here and not threadsafe to run parallel builds on every function
#entry: zsh -c "GOTESTS='superslow' go test ./... -json -v -shuffle=on -tags integration | tparse -notests -smallscreen -pulse 1s"
# entry: zsh -c "(mkdir -p .artifacts/ || echo '.artifacts already exists') && GOTESTS='slow' GOTEST_FLAGS='--tags=integration' gotestsum --format pkgname --junitfile .artifacts/junit.xml --jsonfile
# .artifacts/gotest.json -- -coverpkg=./... -coverprofile=.artifacts/cover.out -covermode atomic -shuffle=on -tags=integration ./..."
always_run: true # Always run full tests before push
entry: gotestsum
args: [./...]
stages: [commit]
types: [go]
language: golang
pass_filenames: false
verbose: true
# - repo: local
# hooks:
# - id: gocover
# name: gocover
# entry: git-chglog -o CHANGELOG.md
# language: system
# stages: [commit]
# - id: gotest
# name: go-test-fast
# description: Run fast unit tests for go
# # entry: go test ./... -json -v -shuffle=on -race | tparse -notests -smallscreen -pulse 1s
# # no race conditions for this because we are doing build tasks here and not threadsafe to run parallel builds on every function
# entry: go test ./... -json -v -shuffle=on | tparse -notests -smallscreen -pulse 1s
# stages: [commit]
# types: [go]
# language: golang
# pass_filenames: false
# verbose: true
# - repo: local
# hooks:
# - id: gocover
# name: gocover
# entry: zsh -c '(mkdir -p .artifacts/ || echo ".artifacts already exists") && go tool cover -func=".artifacts/cover.out" -o=".artifacts/coverage.out"'
# language: system
# stages: [commit]
# - id: gobadge
# name: gobadge
# entry: zsh -c '(mkdir -p .artifacts/ || echo ".artifacts already exists") && gobadge -filename=.artifacts/coverage.out'
# language: system
# stages: [commit]
# github.com/AlexBeauchemin/gobadge@latest
# echo "🧪 running a full go test... this may take a few minutes"
# GOTESTS='superslow' go test ./... -v -json -coverprofile ./.artifacts/cover.out | tparse -all
# go tool cover -html=./.artifacts/cover.out -o ./.artifacts/coverage.html
# gopherbadger-md="README.md,coverage.md"
# git add README.md && git commit --amend --no-edit README.md
# git add coverage.md && git commit --amend --no-edit coverage.md
# git add coverage.md && git commit --amend --no-edit coverage_badge.png