-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
105 lines (87 loc) · 2.98 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
# Copyright © 2020-2024 Dell Inc. or its subsidiaries. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include overrides.mk
all: clean build
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif
check:
GOLINT=$(GOLINT) bash check.sh --all
format:
@gofmt -w -s .
clean:
rm -f core/core_generated.go
go clean
build: golint check
go generate
CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build
install:
go generate
GOOS=linux CGO_ENABLED=0 go install
# Generates the docker container (but does not push)
docker:
go generate
go run core/semver/semver.go -f mk >semver.mk
make -f docker.mk build-base-image docker
# build the reverseproxy container as part of this target
( cd csireverseproxy; make docker )
# Generates the docker container without cache (but does not push)
docker-no-cache:
go generate
go run core/semver/semver.go -f mk >semver.mk
make -f docker.mk build-base-image docker-no-cache
# build the reverseproxy container as part of this target
( cd csireverseproxy; make docker-no-cache )
# Pushes container to the repository
push: docker
make -f docker.mk push
# Run unit tests and skip the BDD tests
unit-test: golint check
( cd service; go clean -cache; CGO_ENABLED=0 GO111MODULE=on go test -skip TestGoDog -v -coverprofile=c.out ./... )
# Run BDD tests. Need to be root to run as tests require some system access, need to fix
bdd-test: golint check
( cd service; go clean -cache; CGO_ENABLED=0 GO111MODULE=on go test -run TestGoDog -v -coverprofile=c.out ./... )
# Linux only; populate env.sh with the hardware parameters
integration-test:
( cd test/integration; sh run.sh )
release:
BUILD_TYPE="R" $(MAKE) clean build docker push
version:
go generate
go run core/semver/semver.go -f mk >semver.mk
make -f docker.mk version
gosec:
ifeq (, $(shell which gosec))
go install github.com/securego/gosec/v2/cmd/gosec@latest
$(shell $(GOBIN)/gosec -quiet -log gosec.log -out=gosecresults.csv -fmt=csv ./...)
else
$(shell gosec -quiet -log gosec.log -out=gosecresults.csv -fmt=csv ./...)
endif
@echo "Logs are stored at gosec.log, Outputfile at gosecresults.csv"
golint:
ifeq (, $(shell which golint))
@{ \
set -e ;\
GOLINT_GEN_TMP_DIR=$$(mktemp -d) ;\
cd $$GOLINT_GEN_TMP_DIR ;\
go mod init tmp ;\
go install golang.org/x/lint/golint@latest ;\
rm -rf $$GOLINT_GEN_TMP_DIR ;\
}
GOLINT=$(GOBIN)/golint
else
GOLINT=$(shell which golint)
endif