-
Notifications
You must be signed in to change notification settings - Fork 339
Expand file tree
/
Copy pathcheck-code-committed.sh
More file actions
executable file
·55 lines (44 loc) · 1.19 KB
/
check-code-committed.sh
File metadata and controls
executable file
·55 lines (44 loc) · 1.19 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
#!/usr/bin/env sh
set -euf
echo --- :go: Checking go mod tidyness
go mod tidy
if ! git diff --no-ext-diff --exit-code; then
echo ^^^ +++
echo "The go.mod or go.sum files are out of sync with the source code"
echo "Please run \`go mod tidy\` locally, and commit the result."
exit 1
fi
echo +++ :go: Checking go formatting
fumpt_out=$(go tool gofumpt -extra -l .)
if ! [ -z "${fumpt_out}" ]; then
echo ^^^ +++
echo "Files have not been formatted with gofumpt:"
echo "${fumpt_out}"
echo "Fix this by running \`gofumpt -extra -w .\` locally, and committing the result."
exit 1
fi
echo --- :go: Generating code
go generate ./...
if ! git diff --no-ext-diff --exit-code; then
echo ^^^ +++
echo :x: Generated code was not commited.
echo "Run"
echo " go generate ./..."
echo "and make a commit."
exit 1
fi
echo +++ :go: Running golangci-lint...
if ! lint_out="$(golangci-lint run --color=always)" ; then
echo ^^^ +++
echo "golangci-lint found the following issues:"
echo ""
echo "${lint_out}"
buildkite-agent annotate --style=error <<EOF
golangci-lint found the following issues:
\`\`\`term
${lint_out}
\`\`\`
EOF
exit 1
fi
echo +++ Everything is clean and tidy! 🎉