-
Notifications
You must be signed in to change notification settings - Fork 78
/
Makefile
73 lines (59 loc) · 2.4 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
DATAPLANEAPI_PATH?=$(shell pwd)
GIT_REPO?=$(shell git config --get remote.origin.url)
GIT_HEAD_COMMIT=$(shell git rev-parse --short HEAD)
GIT_LAST_TAG=$(shell git describe --abbrev=0 --tags)
GIT_TAG_COMMIT=$(shell git rev-parse --short ${GIT_LAST_TAG})
GIT_MODIFIED1=$(shell git diff "${GIT_HEAD_COMMIT}" "${GIT_TAG_COMMIT}" --quiet || echo .dev)
GIT_MODIFIED2=$(shell git diff --quiet || echo .dirty)
GIT_MODIFIED=${GIT_MODIFIED1}${GIT_MODIFIED2}
SWAGGER_VERSION=${shell curl -s https://raw.githubusercontent.com/haproxytech/client-native/master/Makefile | grep SWAGGER_VERSION -m 1 | awk -F"=" '{print $$2}'}
BUILD_DATE=$(shell date -u '+%Y-%m-%dT%H:%M:%SZ')
CGO_ENABLED?=0
GOLANGCI_LINT_VERSION=1.61.0
CHECK_COMMIT=5.0.4
all: update clean build
update:
go mod tidy
.PHONY: lint
lint:
cd bin;GOLANGCI_LINT_VERSION=${GOLANGCI_LINT_VERSION} sh lint-check.sh
bin/golangci-lint run --timeout 10m --color always --max-issues-per-linter 0 --max-same-issues 0
.PHONY: gofumpt
gofumpt:
go install mvdan.cc/gofumpt@latest
gofumpt -l -w .
clean:
rm -rf ${DATAPLANEAPI_PATH}/build
.PHONY: build
build:
mkdir -p ${DATAPLANEAPI_PATH}/build
CGO_ENABLED=$(CGO_ENABLED) go build -trimpath -ldflags "-X \"main.GitRepo=${GIT_REPO}\" -X main.GitTag=${GIT_LAST_TAG} -X main.GitCommit=${GIT_HEAD_COMMIT} -X main.GitDirty=${GIT_MODIFIED} -X main.BuildTime=${BUILD_DATE}" -o ${DATAPLANEAPI_PATH}/build/dataplaneapi ${DATAPLANEAPI_PATH}/cmd/dataplaneapi/
.PHONY: e2e
e2e: build
TESTNAME=$(TESTNAME) TESTNUMBER=$(TESTNUMBER) TESTDESCRIPTION="$(TESTDESCRIPTION)" SKIP_CLEANUP=$(SKIP_CLEANUP) PREWIPE=$(PREWIPE) HAPROXY_VERSION=$(HAPROXY_VERSION) ./e2e/run.bash
.PHONY: generate-parent-aliases_no_formatting
generate-parent-aliases_no_formatting:
rm -f handlers/parent_*_generated.go
go run generate/parents/*.go
.PHONY: generate-parent-aliases
generate-parent-aliases: generate-parent-aliases_no_formatting gofumpt
.PHONY: generate
generate:
cd generate/swagger;docker build \
--build-arg SWAGGER_VERSION=${SWAGGER_VERSION} \
--build-arg UID=$(shell id -u) \
--build-arg GID=$(shell id -g) \
-t dataplaneapi-swagger-gen .
docker run --rm -v "$(shell pwd)":/data dataplaneapi-swagger-gen
generate/post_swagger.sh
.PHONY: generate-native
generate-native:
generate/swagger/script.sh
generate/post_swagger.sh
.PHONY: test
test:
go test ./...
.PHONY: check-commit
check-commit:
cd bin;CHECK_COMMIT=${CHECK_COMMIT} sh check-commit.sh
bin/check-commit