forked from ZupIT/horusec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
147 lines (119 loc) · 6.41 KB
/
Makefile
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
GO ?= go
GOFMT ?= gofmt
GO_FILES ?= $$(find . -name '*.go' | grep -v vendor | grep -v /examples/)
GO_LIST_TO_TEST ?= $$(go list ./... | grep -v /examples/ | grep -v /e2e/)
GOLANG_CI_LINT ?= golangci-lint
GO_IMPORTS ?= goimports
GO_IMPORTS_LOCAL ?= github.com/ZupIT/horusec/
GO_FUMPT ?= gofumpt
GO_GCI ?= gci
ADDLICENSE ?= addlicense
HORUSEC ?= horusec
DOCKER_COMPOSE ?= docker-compose
PATH_BINARY_BUILD_CLI ?= $(GOPATH)/bin
ARCH_ARM64 ?= arm64
ARCH_AMD64 ?= amd64
MAIN = ./cmd/app
lint:
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
$(GOLANG_CI_LINT) run -v --timeout=5m -c .golangci.yml ./...
coverage:
curl -fsSL https://raw.githubusercontent.com/ZupIT/horusec-devkit/main/scripts/coverage.sh | bash -s 90 ./cmd
curl -fsSL https://raw.githubusercontent.com/ZupIT/horusec-devkit/main/scripts/coverage.sh | bash -s 90 ./config
curl -fsSL https://raw.githubusercontent.com/ZupIT/horusec-devkit/main/scripts/coverage.sh | bash -s 86 ./internal
test:
$(GO) clean -testcache
$(GO) test -v $(GO_LIST_TO_TEST) -race -timeout=5m -parallel=1 -failfast -short
test-e2e:
sh ./deployments/scripts/build-all-tools.sh
$(GO) clean -testcache
$(GO) test -v ./e2e/analysis/... -timeout=30m -parallel=1 -failfast
$(GO) clean -testcache
$(GO) test -v ./e2e/commands/... -timeout=30m -parallel=1 -failfast
format: install-format-dependencies
$(GOFMT) -s -l -w $(GO_FILES)
$(GO_IMPORTS) -w -local $(GO_IMPORTS_LOCAL) $(GO_FILES)
$(GO_FUMPT) -l -w $(GO_FILES)
$(GO_GCI) -w -local $(GO_IMPORTS_LOCAL) $(GO_FILES)
install-format-dependencies:
$(GO) install golang.org/x/tools/cmd/goimports@latest
$(GO) install mvdan.cc/gofumpt@latest
$(GO) install github.com/daixiang0/gci@latest
license:
$(GO) install github.com/google/addlicense@latest
@$(ADDLICENSE) -check -f ./copyright.txt $(shell find -regex '.*\.\(go\|js\|ts\|yml\|yaml\|sh\|dockerfile\)')
license-fix:
$(GO) install github.com/google/addlicense@latest
@$(ADDLICENSE) -f ./copyright.txt $(shell find -regex '.*\.\(go\|js\|ts\|yml\|yaml\|sh\|dockerfile\)')
security:
ifeq (, $(shell which $(HORUSEC)))
make install
$(HORUSEC) start -p="./" -e="true"
else
$(HORUSEC) start -p="./" -e="true"
endif
build-dev:
$(GO) build -o horusec $(MAIN)
build-install-cli-linux-amd64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)" &> /dev/null
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH_AMD64) $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)"
horusec-linux-$(ARCH_AMD64) version
build-install-cli-linux-arm64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)" &> /dev/null
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH_ARM64) $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)"
horusec-linux-$(ARCH_ARM64) version
build-install-cli-darwin-amd64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)" &> /dev/null
CGO_ENABLED=0 GOOS=darwin GOARCH=$(ARCH_AMD64) $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)"
horusec-mac-$(ARCH_AMD64) version
build-install-cli-darwin-arm64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_ARM64)" &> /dev/null
CGO_ENABLED=0 GOOS=darwin GOARCH=$(ARCH_ARM64) $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_ARM64)" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_ARM64)"
horusec-mac-$(ARCH_ARM64) version
build-install-cli-linux:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux" &> /dev/null
CGO_ENABLED=0 GOOS=linux $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux"
horusec-linux version
build-install-cli-darwin:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac" &> /dev/null
CGO_ENABLED=0 GOOS=darwin $(GO) build -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac"
horusec-mac version
build-install-cli-windows:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" &> /dev/null
env GOOS=windows GOARCH=amd64 $(GO) build -o "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" $(MAIN)
build-install-stand-alone-cli-linux-amd64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)" &> /dev/null
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH_AMD64) $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux-amd64" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_AMD64)"
horusec-linux-$(ARCH_AMD64) version
build-install-stand-alone-cli-linux-arm64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)" &> /dev/null
CGO_ENABLED=0 GOOS=linux GOARCH=$(ARCH_ARM64) $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-linux-arm64" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-linux-$(ARCH_ARM64)"
horusec-linux-$(ARCH_ARM64) version
build-install-stand-alone-cli-darwin-amd64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)" &> /dev/null
CGO_ENABLED=0 GOOS=darwin GOARCH=$(ARCH_ARM64) $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_AMD64)"
horusec-mac-$(ARCH_AMD64) version
build-install-stand-alone-cli-darwin-arm64:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-mac-$(ARCH_ARM64)" &> /dev/null
CGO_ENABLED=0 GOOS=darwin GOARCH=$(ARCH_ARM64) $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -a -installsuffix cgo -o "$(PATH_BINARY_BUILD_CLI)/horusec-mac" $(MAIN)
chmod +x "$(PATH_BINARY_BUILD_CLI)/horusec-mac-arm64"
horusec-mac-$(ARCH_ARM64) version
build-install-stand-alone-cli-windows:
rm -rf "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" &> /dev/null
env GOOS=windows GOARCH=amd64 $(GO) build -ldflags "-X github.com/ZupIT/horusec/config/dist.standAlone=true" -o "$(PATH_BINARY_BUILD_CLI)/horusec-win.exe" $(MAIN)
install:
./deployments/scripts/install.sh latest
install-beta:
./deployments/scripts/install.sh latest-beta
install-rc:
./deployments/scripts/install.sh latest-rc
pipeline: format lint test coverage security