-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy pathMakefile
62 lines (48 loc) · 2.35 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
.ONESHELL:
.DELETE_ON_ERROR:
MAKEFLAGS += --no-builtin-rules
NAME = "github.com/odpf/optimus"
LAST_COMMIT := $(shell git rev-parse --short HEAD)
LAST_TAG := "$(shell git rev-list --tags --max-count=1)"
OPMS_VERSION := "$(shell git describe --tags ${LAST_TAG})-next"
PROTON_COMMIT := "4eed966804481fc19c02ce99c2df9fb3907899d0"
.PHONY: build test generate pack-files generate-proto unit-test smoke-test integration-test vet coverage clean install
.DEFAULT_GOAL := build
build: generate # build optimus binary
@echo " > building optimus version ${OPMS_VERSION}"
@go build -ldflags "-X ${NAME}/config.Version=${OPMS_VERSION} -X ${NAME}/config.BuildCommit=${LAST_COMMIT}" -o optimus .
@echo " - build complete"
test: smoke-test unit-test vet ## run tests
generate: pack-files
@echo " > notice: skipped proto generation, use 'generate-proto' make command"
pack-files:
@echo " > packing resources"
@go generate ./..
generate-proto: ## regenerate protos
@echo " > generating protobuf from odpf/proton"
@echo " > [info] make sure correct version of dependencies are installed using 'make install'"
@buf generate https://github.com/odpf/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path odpf/optimus
@echo " > protobuf compilation finished"
unit-test:
go list ./... | grep -v -e third_party -e api/proto | xargs go test -count 5 -cover -race -timeout 1m -tags=unit_test
smoke-test: build
@bash ./scripts/smoke-test.sh
integration-test:
go list ./... | grep -v -e third_party -e api/proto | xargs go test -count 1 -cover -race -timeout 1m
vet: ## run go vet
go vet ./...
coverage: ## print code coverage
go test -race -coverprofile coverage.txt -covermode=atomic ./... -tags=unit_test && go tool cover -html=coverage.txt
clean:
rm -rf ./optimus ./dist ./api/proto/* ./api/third_party/odpf/*
install: ## install required dependencies
@echo "> installing dependencies"
go mod tidy
go get google.golang.org/protobuf/cmd/[email protected]
go get github.com/golang/protobuf/[email protected]
go get github.com/golang/protobuf/[email protected]
go get google.golang.org/[email protected]
go get google.golang.org/grpc/cmd/[email protected]
go get github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go get github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
go get github.com/bufbuild/buf/cmd/[email protected]