forked from yorkie-team/yorkie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (65 loc) · 3.05 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
82
83
YORKIE_VERSION := 0.4.31
GO_PROJECT = github.com/yorkie-team/yorkie
ifeq ($(OS),Windows_NT)
BUILD_DATE := $(shell echo %date:~6,4%-%date:~0,2%-%date:~3,2%)
GO_SRC := $(shell dir /s /b *.go | findstr /v "vendor")
EXECUTABLE = ./bin/yorkie.exe
else
BUILD_DATE := $(shell date "+%Y-%m-%d")
GO_SRC := $(shell find . -path ./vendor -prune -o -type f -name '*.go' -print)
EXECUTABLE = ./bin/yorkie
endif
# inject the version number into the golang version package using the -X linker flag
GO_LDFLAGS ?=
GO_LDFLAGS += -X ${GO_PROJECT}/internal/version.Version=${YORKIE_VERSION}
GO_LDFLAGS += -X ${GO_PROJECT}/internal/version.BuildDate=${BUILD_DATE}
default: help
tools: ## install tools for developing yorkie
go install github.com/bufbuild/buf/cmd/buf@v1.28.1
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.31.0
go install connectrpc.com/connect/cmd/protoc-gen-connect-go@v1.12.0
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.55.1
go install github.com/sudorandom/protoc-gen-connect-openapi@v0.5.5
proto: ## generate proto files
buf generate
build: ## builds an executable that runs in the current environment
CGO_ENABLED=0 go build -o $(EXECUTABLE) -ldflags "${GO_LDFLAGS}" ./cmd/yorkie
build-binaries: ## builds binaries to attach a new release
rm -rf binaries
./build/build-binaries.sh $(YORKIE_VERSION) "$(GO_LDFLAGS)"
fmt: ## applies format and simplify codes
gofmt -s -w $(GO_SRC)
lint: ## runs the golang-ci lint, checks for lint violations
golangci-lint run ./...
coverage: ## runs coverage tests
go clean -testcache
go test -tags integration -race -coverprofile=coverage.txt -covermode=atomic ./...
go tool cover -html=coverage.txt
rm -f coverage.txt
test: ## runs integration tests that require local applications such as MongoDB
go clean -testcache
go test -tags integration -race ./...
bench: ## runs benchmark tests
rm -f pipe output.txt mem.prof cpu.prof bench.test
mkfifo pipe
tee output.txt < pipe &
go test -tags bench -benchmem -bench=. ./test/bench -memprofile=mem.prof -cpuprofile=cpu.prof > pipe
rm -f pipe
docker: ## builds docker images with the current version and latest tag
docker buildx build --push --platform linux/amd64,linux/arm64,linux/386 -t yorkieteam/yorkie:$(YORKIE_VERSION) -t yorkieteam/yorkie:latest .
docker-latest: ## builds docker images with latest tag
docker buildx build --push --platform linux/amd64,linux/arm64,linux/386 -t yorkieteam/yorkie:latest .
swagger: ## runs swagger-ui with the yorkie api docs
docker run -p 3000:8080 \
-e URLS="[ \
{ url: 'docs/yorkie/v1/admin.openapi.yaml', name: 'Admin' }, \
{ url: 'docs/yorkie/v1/resources.openapi.yaml', name: 'Resources' }, \
{ url: 'docs/yorkie/v1/yorkie.openapi.yaml', name: 'Yorkie' } \
]" \
-v `pwd`/api/docs:/usr/share/nginx/html/docs/ \
swaggerapi/swagger-ui
help:
@echo 'Commands:'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-20s %s\n", $$1, $$2}'
@echo
.PHONY: tools proto build build-binaries fmt lint test bench docker docker-latest help