-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
103 lines (86 loc) · 2.18 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
SHELL = bash
SCRIPTDIR := $(shell pwd)
ROOTDIR := $(shell cd $(SCRIPTDIR) && pwd)
BUILDIMAGE := arangodboasis/golang-ci:latest
PROTOSOURCES := $(shell find . -name '*.proto' -not -path './vendor/*' -not -path './vendor-proto/*' | sort)
ifndef CIRCLECI
GITHUB_TOKEN := $(shell cat $(HOME)/.arangodb/ms/github-readonly-code-acces.token)
else
GITHUB_TOKEN :=
endif
DOCKERARGS := run -t --rm \
-u $(shell id -u):$(shell id -g) \
-v $(ROOTDIR):/usr/src \
-e GOSUMDB=off \
-e GOCACHE=/tmp/gocache \
-e CGO_ENABLED=0 \
-e GO111MODULE=on \
-w /usr/src \
$(BUILDIMAGE)
ifndef CIRCLECI
DOCKERENV := docker $(DOCKERARGS)
else
DOCKERENV :=
endif
.PHONY: all
all: generate build check ts docs
.PHONY: pull-build-image
pull-build-image:
ifndef CIRCLECI
ifndef OFFLINE
@docker pull $(BUILDIMAGE)
endif
endif
# Generate go code for proto files
.PHONY: generate
generate: $(CACHEVOL) $(MODVOL) $(HOMEVOL)
$(DOCKERENV) \
go generate ./...
# Build go code
.PHONY: build
build: generate
go build ./...
# Check go code
.PHONY: check
check:
zutano go check ./...
# Generate API docs
.PHONY: docs
docs: $(CACHEVOL) $(MODVOL) $(HOMEVOL)
$(DOCKERENV) \
protoc -I.:vendor-proto/ \
--doc_out=docs $(PROTOSOURCES) \
--doc_opt=html,index-raw.html
cat docs/header.txt docs/index-raw.html > docs/index.html
rm docs/index-raw.html
# Generate API as typescript
.PHONY: ts
ts: $(CACHEVOL) $(MODVOL) $(HOMEVOL)
@rm -Rf typescript
@mkdir -p typescript
$(DOCKERENV) \
protoc -I.:vendor-proto \
--ts_out=typescript $(PROTOSOURCES) \
--ts_opt=.
.PHONY: test
test:
mkdir -p bin/test
go test -coverprofile=bin/test/coverage.out -v ./... | tee bin/test/test-output.txt ; exit "$${PIPESTATUS[0]}"
cat bin/test/test-output.txt | go-junit-report > bin/test/unit-tests.xml
go tool cover -html=bin/test/coverage.out -o bin/test/coverage.html
bootstrap:
go get github.com/arangodb-managed/zutano
go get github.com/jstemmer/go-junit-report
go get github.com/stretchr/testify
check-version:
zutano check api branch
.PHONY: vendor
vendor:
go mod vendor
.PHONY: update-modules
update-modules:
go get \
github.com/golang/[email protected] \
github.com/grpc-ecosystem/[email protected]
go mod tidy
go mod vendor