-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.COMMON
55 lines (44 loc) · 1.97 KB
/
Makefile.COMMON
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
NAME ?= $(error NAME not set in including Makefile)
.DEFAULT_GOAL = run
PKGS = $(go list ./... | grep -v "/vendor/")
TAG=$(shell git rev-parse --short=8 HEAD)
GCR_HOST=us.gcr.io
GCP_PROJECT=wa-labs
.PHONY: help
help:
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: deps
deps: ## Install the project dependencies
dep ensure -v
.PHONY: test
test: ## Runs the tests
go test -v $(PKGS)
.PHONY: lint
lint: ## Runs the linter
gometalinter --vendor --fast --disable=gotype --disable=gas --disable=errcheck $(PKGS)
.PHONY: install
install: ## Installs the Go binary for development
@go version
GOGC=off go install -v
.PHONY: run
run: install ## Runs the Go program for development
source deploy/local/local.env && $(NAME)
.PHONY: deploy-staging
deploy-staging: ## Deploys the current commit to staging
carebox-client -d $(STAGING_SERVER) -t $(DEPLOY_TOKEN_STAGING) -u $(REGISTRY_URL) -l $(REGISTRY_LOGIN) -p $(gcloud auth print-access-token) -e $(REGISTRY_EMAIL) -b develop -n $(REPO_NAME) -x TAG:$(CI_BUILD_REF_NAME)
.PHONY: ci-docker-auth
ci-docker-auth: ## Authenticates through the gcloud CLI
echo $(GCLOUD_SERVICE_KEY) | base64 -d > $(HOME)/gcloud-service-key.json
gcloud auth activate-service-account --key-file $(HOME)/gcloud-service-key.json
gcloud config set project $(GCP_PROJECT)
.PHONY: ci-docker-test
ci-docker-test: ## Runs all the CI tests in Docker (test and lint)
gcloud docker -- build -f ./Dockerfile-test -t $(NAME)-test:$(TAG) .
gcloud docker -- run -i $(NAME)-test:$(TAG)
.PHONY: ci-docker-build
ci-docker-build: ## Builds the production Docker image
gcloud docker -- build -t $(GCR_HOST)/$(GCP_PROJECT)/$(NAME):$(TAG) -t $(GCR_HOST)/$(GCP_PROJECT)/$(NAME):latest .
.PHONY: ci-docker-push
ci-docker-push: ## Pushes the production Docker image
gcloud docker -- push $(GCR_HOST)/$(GCP_PROJECT)/$(NAME):$(TAG)
gcloud docker -- push $(GCR_HOST)/$(GCP_PROJECT)/$(NAME):latest