-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (66 loc) · 2.47 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
74
75
76
77
78
79
80
81
ENVIRONMENT ?= dev
VERSION ?= latest
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
TAG := $(BRANCH)-$(VERSION)
# If you want to escape branch-environment constraint, pass in OVERRIDE_BRANCH=true
ifeq ($(ENVIRONMENT),prod)
DNS_ZONE = radix.equinor.com
else
DNS_ZONE = dev.radix.equinor.com
endif
CONTAINER_REPO ?= radix$(ENVIRONMENT)
DOCKER_REGISTRY ?= $(CONTAINER_REPO).azurecr.io
DOCKER_BUILDX_BUILD_BASE_CMD := docker buildx build -t $(DOCKER_REGISTRY)/radix-job-scheduler:$(TAG) --platform linux/arm64,linux/amd64 -f Dockerfile
echo:
@echo "ENVIRONMENT : " $(ENVIRONMENT)
@echo "DNS_ZONE : " $(DNS_ZONE)
@echo "CONTAINER_REPO : " $(CONTAINER_REPO)
@echo "DOCKER_REGISTRY : " $(DOCKER_REGISTRY)
@echo "BRANCH : " $(BRANCH)
@echo "TAG : " $(TAG)
# This make command is only needed for local testing now
# we also do make swagger inside Dockerfile
.PHONY: swagger
swagger: SHELL:=/bin/bash
swagger: bootstrap
swagger generate spec -o ./swaggerui/html/swagger.json --scan-models --exclude-deps
swagger validate ./swaggerui/html/swagger.json
.PHONY: docker-build
docker-build:
${DOCKER_BUILDX_BUILD_BASE_CMD} .
.PHONY: docker-push
docker-push:
az acr login --name $(CONTAINER_REPO)
${DOCKER_BUILDX_BUILD_BASE_CMD} --push .
.PHONY: deploy
deploy: docker-build docker-push
.PHONY: test
test:
go test -cover `go list ./...`
lint: bootstrap
golangci-lint run --timeout=30m --max-same-issues=0
.PHONY: mocks
mocks: bootstrap
mockgen -source ./api/v2/handler.go -destination ./api/v2/mock/handler_mock.go -package mock
mockgen -source ./api/v1/jobs/job_handler.go -destination ./api/v1/jobs/mock/job_mock.go -package mock
mockgen -source ./api/v1/batches/batch_handler.go -destination ./api/v1/batches/mock/batch_mock.go -package mock
mockgen -source ./pkg/notifications/notifier.go -destination ./pkg/notifications/notifier_mock.go -package notifications
mockgen -source ./pkg/batch/history.go -destination ./pkg/batch/history_mock.go -package batch
.PHONY: generate
generate: swagger mocks
.PHONY: verify-generate
verify-generate: generate
git diff --exit-code
HAS_SWAGGER := $(shell command -v swagger;)
HAS_GOLANGCI_LINT := $(shell command -v golangci-lint;)
HAS_MOCKGEN := $(shell command -v mockgen;)
bootstrap:
ifndef HAS_SWAGGER
go install github.com/go-swagger/go-swagger/cmd/[email protected]
endif
ifndef HAS_GOLANGCI_LINT
go install github.com/golangci/golangci-lint/cmd/[email protected]
endif
ifndef HAS_MOCKGEN
go install github.com/golang/mock/[email protected]
endif