-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
53 lines (37 loc) · 1.8 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
.PHONY: all build
WORKSPACE ?= $$(pwd)
RACEFLAG ?= -race
GO_TEST_LIST := $(shell go list ./... | grep -v /mock)
GO_PKG_LIST := $(shell go list ./... | grep -v /mock | grep -v ./pkg/apic/apiserver/clients \
| grep -v ./pkg/apic/apiserver/models | grep -v ./pkg/apic/unifiedcatalog/models)
export GOFLAGS := -mod=mod
PROTO_OUT_PATH := ${WORKSPACE}
all : clean
clean:
@echo "Clean complete"
dep-check:
@go mod verify
resolve-dependencies:
@echo "Resolving go package dependencies"
@go mod tidy
@echo "Package dependencies completed"
dep: resolve-dependencies
test: dep
@go vet ${GO_TEST_LIST}
@go test -short ${RACEFLAG} -coverprofile=${WORKSPACE}/gocoverage.out -count=1 ${GO_TEST_LIST}
test-sonar: dep
@go vet ${GO_PKG_LIST}
@go test -short -coverpkg=./... -coverprofile=${WORKSPACE}/gocoverage.out -count=1 ${GO_PKG_LIST} -json > ${WORKSPACE}/goreport.json
apiserver-generate: # generate api server resources, prod by default. ex: make apiserver-generate protocol=https host=apicentral.axway.com port=443
docker run --name generator --rm -v $(shell pwd)/scripts/apiserver:/codegen/scripts -v $(shell pwd)/pkg/apic/apiserver:/codegen/output -e PROTOCOL='$(protocol)' -e HOST='$(host)' -e PORT='$(port)' -e USERID=$(shell id -u) -e GROUPID=$(shell id -g) -w /codegen/scripts --entrypoint ./apiserver_generate.sh ampc-beano-docker-release-phx.artifactory-phx.ecd.axway.int/base-images/beano-alpine-codegen:latest
PROTOFILES := $(shell find $(WORKSPACE)/proto -type f -name '*.proto')
PROTOTARGETS := $(PROTOFILES:.proto=.pb.go)
%.pb.go : %.proto
@echo $<
@docker run --rm -u $(shell id -u) \
-v${WORKSPACE}:${WORKSPACE} \
-w${WORKSPACE} rvolosatovs/protoc:latest \
--proto_path=${WORKSPACE}/proto --go_out=${PROTO_OUT_PATH} --go-grpc_out=${PROTO_OUT_PATH} \
$<
# generate protobufs
protoc: $(PROTOTARGETS)