-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
57 lines (45 loc) · 1.58 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
.EXPORT_ALL_VARIABLES:
OUT_DIR := ./_output
BIN_DIR := ./bin
PACKAGE=github.com/gopaytech/go-commons
CURRENT_DIR=$(shell pwd)
VERSION=$(shell cat ${CURRENT_DIR}/VERSION)
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GIT_COMMIT=$(shell git rev-parse --short HEAD)
GIT_TAG=$(shell if [ -z "`git status --porcelain`" ]; then git describe --exact-match --tags HEAD 2>/dev/null; fi)
$(shell mkdir -p $(OUT_DIR) $(BIN_DIR))
# perform static compilation
STATIC_BUILD?=true
override LDFLAGS += \
-X ${PACKAGE}.version=${VERSION} \
-X ${PACKAGE}.buildDate=${BUILD_DATE} \
-X ${PACKAGE}.gitCommit=${GIT_COMMIT}
ifeq (${STATIC_BUILD}, true)
override LDFLAGS += -extldflags "-static"
endif
ifneq (${GIT_TAG},)
IMAGE_TAG=${GIT_TAG}
LDFLAGS += -X ${PACKAGE}.gitTag=${GIT_TAG}
else
IMAGE_TAG?=$(GIT_COMMIT)
endif
# Code build targets
.PHONY: vendor
vendor:
go mod vendor
# Main Test Targets (without docker)
.PHONY: test
test:
go test -race -coverprofile=$(OUT_DIR)/coverage.out ./...
# Integration test executed by github workflow
.PHONY: integration-test
integration-test:
go test -v -race -tags=integration -coverprofile=$(OUT_DIR)/coverage.out ./...
# Local Integration test only able to be executed on local with docker engine present
.PHONY: local-integration-test
local-integration-test:
go test -v -race -tags=local,integration -coverprofile=$(OUT_DIR)/coverage.out ./...
.PHONY: mock
mock:
cd $(CURRENT_DIR)/pkg/gitlab && mockery --all --case=underscore --output ./gitlab_mock --outpkg gitlab_mock
cd $(CURRENT_DIR)/pkg/tmpl && mockery --all --case=underscore --output ./tmpl_mock --outpkg tmpl_mock