-
Notifications
You must be signed in to change notification settings - Fork 33
/
Makefile
49 lines (37 loc) · 1.67 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
SHELL := /bin/bash # Use bash syntax
# Set up variables
GO111MODULE=on
AWS_SDK_GO_VERSION="$(shell echo $(shell go list -m -f '{{.Version}}' github.com/aws/aws-sdk-go))"
AWS_SDK_GO_VERSIONED_PATH="$(shell echo github.com/aws/aws-sdk-go@$(AWS_SDK_GO_VERSION))"
ELASTICACHE_API_PATH="$(shell echo $(shell go env GOPATH))/pkg/mod/$(AWS_SDK_GO_VERSIONED_PATH)/service/elasticache/elasticacheiface"
SERVICE_CONTROLLER_SRC_PATH="$(shell pwd)"
# Build ldflags
VERSION ?= "v0.0.0"
GITCOMMIT=$(shell git rev-parse HEAD)
BUILDDATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GO_LDFLAGS=-ldflags "-X main.version=$(VERSION) \
-X main.buildHash=$(GITCOMMIT) \
-X main.buildDate=$(BUILDDATE)"
.PHONY: all test local-test clean-mocks mocks
all: test
test: | mocks ## Run code tests
go test -v ./...
test-cover: | mocks ## Run code tests with resources coverage
go test -coverpkg=./pkg/resource/... -covermode=count -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
local-test: | mocks ## Run code tests using go.local.mod file
go test -modfile=go.local.mod -v ./...
clean-mocks: ## Remove mocks directory
rm -rf mocks
install-mockery:
@scripts/install-mockery.sh
mocks: install-mockery ## Build mocks
go get -d $(AWS_SDK_GO_VERSIONED_PATH)
@echo "building mocks for $(ELASTICACHE_API_PATH) ... "
@pushd $(ELASTICACHE_API_PATH) 1>/dev/null; \
$(SERVICE_CONTROLLER_SRC_PATH)/bin/mockery --all --dir=. --output=$(SERVICE_CONTROLLER_SRC_PATH)/mocks/aws-sdk-go/elasticache/ ; \
popd 1>/dev/null;
@echo "ok."
help: ## Show this help.
@grep -F -h "##" $(MAKEFILE_LIST) | grep -F -v grep | sed -e 's/\\$$//' \
| awk -F'[:#]' '{print $$1 = sprintf("%-30s", $$1), $$4}'