-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (35 loc) · 1.62 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
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))"
APPLICATIONAUTOSCALING_API_PATH="$(shell echo $(shell go env GOPATH))/pkg/mod/$(AWS_SDK_GO_VERSIONED_PATH)/service/applicationautoscaling/applicationautoscalingiface"
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 clean-mocks mocks
all: test
test: ## 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
clean-mocks: ## Remove mocks directory
rm -r mocks
install-mockery:
@test/scripts/install-mockery.sh
mocks: install-mockery ## Build mocks
go get -d $(AWS_SDK_GO_VERSIONED_PATH)
@echo "building mocks for $(APPLICATIONAUTOSCALING_API_PATH) ... "
@pushd $(APPLICATIONAUTOSCALING_API_PATH) 1>/dev/null; \
$(SERVICE_CONTROLLER_SRC_PATH)/bin/mockery --all --dir=. --output=$(SERVICE_CONTROLLER_SRC_PATH)/mocks/aws-sdk-go/applicationautoscaling/ ; \
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}'