-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
89 lines (68 loc) · 3.26 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
SHELL = /bin/sh
TOOLS_BIN = tools/bin
NPM_BIN = node_modules/.bin
OAPI_CODEGEN = $(TOOLS_BIN)/oapi-codegen
MOCKGEN = $(TOOLS_BIN)/mockgen
SWAGGER_CLI = $(NPM_BIN)/swagger-cli
OPENAPI_FILTER = $(NPM_BIN)/openapi-filter
NPM_PKG_SPECS = \
@apidevtools/swagger-cli@^4.0.4 \
openapi-filter@^3.2.3
PATH:=$(shell pwd)/$(TOOLS_BIN):$(PATH)
# Generates server files
.PHONY: generate
generate: $(SWAGGER_CLI) $(OAPI_CODEGEN) $(MOCKGEN)
$(SWAGGER_CLI) bundle ../TidepoolApi/reference/clinic.v1.yaml -o ./spec/clinic.v1.yaml -t yaml
$(OAPI_CODEGEN) -exclude-tags=Confirmations -package=api -generate=server spec/clinic.v1.yaml > api/gen_server.go
$(OAPI_CODEGEN) -exclude-tags=Confirmations -package=api -generate=spec spec/clinic.v1.yaml > api/gen_spec.go
$(OAPI_CODEGEN) -exclude-tags=Confirmations -package=api -generate=types spec/clinic.v1.yaml > api/gen_types.go
$(OAPI_CODEGEN) -exclude-tags=Confirmations -package=client -generate=types spec/clinic.v1.yaml > client/types.go
$(OAPI_CODEGEN) -exclude-tags=Confirmations -package=client -generate=client spec/clinic.v1.yaml > client/client.go
$(SWAGGER_CLI) bundle ../TidepoolApi/reference/redox.v1.yaml -o ./spec/redox.v1.yaml -t yaml
$(OAPI_CODEGEN) -package=redox_models -generate=types spec/redox.v1.yaml > redox_models/gen_types.go
$(OAPI_CODEGEN) -include-tags="Orders (Partner)",Webhooks -package=xealth_client -generate=types,skip-prune ../TidepoolApi/reference/xealth.v2.yaml > xealth_client/gen_types.go
$(OAPI_CODEGEN) -include-tags="Orders (Partner)" -package=xealth_client -generate=client ../TidepoolApi/reference/xealth.v2.yaml > xealth_client/gen_client.go
go generate ./...
cd client && go generate ./...
# Generate linkerd service profile
service-profile/profile.yaml: service-profile/clinic.v1.yaml service-profile
linkerd profile --ignore-cluster --open-api service-profile/clinic.v1.yaml clinic > service-profile/profile.yaml
service-profile/clinic.v1.yaml: $(OPENAPI_FILTER) generate service-profile
$(OPENAPI_FILTER) -f Confirmations --checkTags spec/clinic.v1.yaml service-profile/clinic.v1.yaml
service-profile:
mkdir -p service-profile
# Set flags
.PHONY: go-flags
go-flags:
go env -w GOFLAGS=-mod=mod
tools/bin/ginkgo:
GOBIN=$(shell pwd)/$(TOOLS_BIN) go install github.com/onsi/ginkgo/v2/ginkgo@v2.19.0
# Runs tests
.PHONY: test
test: go-flags $(TOOLS_BIN)/ginkgo
$(TOOLS_BIN)/ginkgo --require-suite --compilers=2 -r --randomize-suites --randomize-all --succinct --fail-on-pending --trace --race --poll-progress-after=10s --poll-progress-interval=20s --keep-going ./...
# Builds package
.PHONY: build
build: go-flags
./build.sh
$(OAPI_CODEGEN):
GOBIN=$(shell pwd)/$(TOOLS_BIN) go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.3.0
$(MOCKGEN):
GOBIN=$(shell pwd)/$(TOOLS_BIN) go install github.com/golang/mock/mockgen@v1.6.0
$(SWAGGER_CLI): npm-tools
$(OPENAPI_FILTER): 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 dist node_modules tools
.PHONY: ci-generate
ci-generate: generate
.PHONY: ci-build
ci-build: build
.PHONY: ci-test
ci-test: test