-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
63 lines (48 loc) · 1.45 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
SHELL = /bin/sh
TOOLS_BIN = tools/bin
NPM_BIN = node_modules/.bin
OAPI_CODEGEN = $(TOOLS_BIN)/oapi-codegen
SWAGGER_CLI = $(NPM_BIN)/swagger-cli
NPM_PKG_SPECS = \
@apidevtools/swagger-cli@^4.0.4
ifeq ($(CI),)
GO_BUILD_FLAGS =
GO_TEST_FLAGS =
else
GO_BUILD_FLAGS = -v
GO_TEST_FLAGS = -v
endif
.PHONY: build
build:
go build $(GO_BUILD_FLAGS) ./...
.PHONY: test
test:
go test $(GO_TEST_FLAGS) ./...
.PHONY: test-cover
test-cover:
go test -coverprofile cover.out $(GO_TEST_FLAGS) ./...
.PHONY: generate
# Generates client api
generate: $(SWAGGER_CLI) $(OAPI_CODEGEN)
$(SWAGGER_CLI) bundle ../TidepoolApi/reference/summary.v1.yaml -o ./spec/summary.v1.yaml -t yaml
$(OAPI_CODEGEN) -package=api -generate=types spec/summary.v1.yaml > clients/summary/types.go
$(OAPI_CODEGEN) -package=api -generate=client spec/summary.v1.yaml > clients/summary/client.go
cd clients/summary && go generate ./...
$(OAPI_CODEGEN):
GOBIN=$(shell pwd)/$(TOOLS_BIN) go install github.com/oapi-codegen/oapi-codegen/v2/cmd/[email protected]
$(SWAGGER_CLI): npm-tools
.PHONY: npm-tools
npm-tools:
# When using --no-save, any dependencies not included will be deleted, so one
# has to install all the packages all at the same time. But it saves us from
# having to muck with packages.json.
npm install --no-save --local $(NPM_PKG_SPECS)
.PHONY: clean
clean:
rm -rf node_modules tools
.PHONY: ci-generate
ci-generate: generate
.PHONY: ci-build
ci-build: build
.PHONY: ci-test
ci-test: test