-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
86 lines (72 loc) · 2.3 KB
/
Makefile
File metadata and controls
86 lines (72 loc) · 2.3 KB
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
.PHONY: help
help:
@echo "Available commands:"
@echo " format Format the project code"
@echo " lint Run the configured linters (before pushing)"
@echo " compile Compile the project code"
@echo " test Run the unit tests"
@echo " build Build a binary"
@echo " run Run the project locally"
@echo " update Update all the project dependencies"
generate: tools gogenerate
format: generate gofmt
lint: format golint
compile: lint gocompile
test: compile gotest
build: test gobuild
run: test gorun
rundev: generate gocompile gotest gobuild gorun
update: build goupdate build
.PHONY: tools
tools:
go install github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen@v2.4.1
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2
go install golang.org/x/tools/cmd/goimports@v0.33.0
.PHONY: gogenerate
gogenerate:
# Generate Open API V3 model (all types)
oapi-codegen -package=_api -generate types,skip-prune \
-o api/openapi/v3/_api/types.go \
api/openapi/v3/api.yaml
# Generate Open API server interfaces
# https://github.com/oapi-codegen/oapi-codegen/issues/1513
for path in api/openapi/v3/paths/*; do \
tag=$${path##*/}; \
echo "Generate Server Interface for $${tag} path" ; \
mkdir -p api/openapi/v3/_api/$${tag}/ ; \
oapi-codegen -package=_$${tag} -generate gin-server,types \
-o api/openapi/v3/_api/$${tag}/$${tag}-server.go \
-include-tags $${tag} \
api/openapi/v3/api.yaml ; \
done
# Generate swagger spec (doc)
oapi-codegen -package=_api -generate spec \
-o api/openapi/v3/_api/spec.go \
api/openapi/v3/api.yaml
# Generate client stubs
# oapi-codegen -package=_api -generate client \
# -o api/openapi/v3/_api/client.go \
# api/openapi/v3/api.yaml
.PHONY: gofmt
gofmt:
gofmt -s -w ./internal/ ./cmd/ && goimports -w -local ./internal/ ./cmd/
.PHONY: golint
golint:
golangci-lint run
.PHONY: gobuild
gobuild:
mkdir -p .bin/
CGO_ENABLED=0 go build -a -o .bin/okdp-server main.go
.PHONY: gocompile
gocompile:
CGO_ENABLED=0 go build -a -o /dev/null main.go
.PHONY: gotest
gotest:
go test ./... -v
.PHONY: gorun
gorun:
go run *.go --config=.local/application-local.yaml
.PHONY: goupdate
goupdate:
go get -u ./...
go mod tidy