This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
forked from jpeeler/podpreset-crd
-
Notifications
You must be signed in to change notification settings - Fork 10
/
before-commit.sh
executable file
·109 lines (97 loc) · 2.42 KB
/
before-commit.sh
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
#!/usr/bin/env bash
readonly CI_FLAG=ci
RED='\033[0;31m'
GREEN='\033[0;32m'
INVERTED='\033[7m'
NC='\033[0m' # No Color
echo -e "${INVERTED}"
echo "USER: " + $USER
echo "PATH: " + $PATH
echo "GOPATH:" + $GOPATH
echo -e "${NC}"
##
# DEP ENSURE
##
#dep ensure -v --vendor-only
#ensureResult=$?
#if [ ${ensureResult} != 0 ]; then
# echo -e "${RED}✗ dep ensure -v --vendor-only${NC}\n$ensureResult${NC}"
# exit 1
#else echo -e "${GREEN}√ dep ensure -v --vendor-only${NC}"
#fi
##
# GO BUILD
##
binaries=("manager")
buildEnv=""
if [ "$1" == "$CI_FLAG" ]; then
# build binary statically for linux architecture
buildEnv="env GO111MODULE=on CGO_ENABLED=0 GOOS=linux GOARCH=amd64"
fi
for binary in "${binaries[@]}"; do
${buildEnv} go build -o ${binary} ./cmd/${binary}
goBuildResult=$?
if [ ${goBuildResult} != 0 ]; then
echo -e "${RED}✗ go build ${binary} ${NC}\n$goBuildResult${NC}"
exit 1
else echo -e "${GREEN}√ go build ${binary} ${NC}"
fi
done
##
# DEP STATUS
##
#echo "? dep status"
#depResult=$(dep status -v)
#if [ $? != 0 ]; then
# echo -e "${RED}✗ dep status\n$depResult${NC}"
# exit 1
#else echo -e "${GREEN}√ dep status${NC}"
#fi
##
# GO LINT
##
#go build -o golint-vendored ./vendor/golang.org/x/lint/golint
#buildLintResult=$?
#if [ ${buildLintResult} != 0 ]; then
# echo -e "${RED}✗ go build lint${NC}\n$buildLintResult${NC}"
# exit 1
#fi
#golintResult=$(echo "${goFilesToCheck}" | xargs -L1 ./golint-vendored)
#rm golint-vendored
#
#if [ $(echo ${#golintResult}) != 0 ]; then
# echo -e "${RED}✗ golint\n$golintResult${NC}"
# exit 1
#else echo -e "${GREEN}√ golint${NC}"
#fi
##
# GO IMPORTS & FMT
##
#go build -o goimports-vendored ./vendor/golang.org/x/tools/cmd/goimports
#buildGoImportResult=$?
#if [ ${buildGoImportResult} != 0 ]; then
# echo -e "${RED}✗ go build goimports${NC}\n$buildGoImportResult${NC}"
# exit 1
#fi
#
#goImportsResult=$(echo "${goFilesToCheck}" | xargs -L1 ./goimports-vendored -w -l)
#rm goimports-vendored
#
#if [ $(echo ${#goImportsResult}) != 0 ]; then
# echo -e "${RED}✗ goimports and fmt${NC}\n$goImportsResult${NC}"
# exit 1
#else echo -e "${GREEN}√ goimports and fmt${NC}"
#fi
##
# GO VET
##
#packagesToVet=("./cmd/..." "./pkg/...")
#
#for vPackage in "${packagesToVet[@]}"; do
# vetResult=$(go vet ${vPackage})
# if [ $(echo ${#vetResult}) != 0 ]; then
# echo -e "${RED}✗ go vet ${vPackage} ${NC}\n$vetResult${NC}"
# exit 1
# else echo -e "${GREEN}√ go vet ${vPackage} ${NC}"
# fi
#done