-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (113 loc) · 3.27 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
commit = $(shell git rev-parse HEAD)
version = latest
ifeq ($(OS),Windows_NT)
wharf.exe: swag
go build -o wharf.exe
else
wharf: swag
go build -o wharf
endif
.PHONY: clean
clean: clean-swag clean-build
.PHONY: clean-build
clean-build:
ifeq ($(OS),Windows_NT)
rm -rfv wharf.exe
else
rm -rfv wharf
endif
.PHONY: install
install: swag
go install ./cmd/wharf
.PHONY: tidy
tidy:
go mod tidy
.PHONY: deps
deps: deps-go deps-npm
.PHONY: deps-go
deps-go:
go install github.com/mgechev/revive@latest
go install golang.org/x/tools/cmd/goimports@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
go install github.com/alta/protopatch/cmd/protoc-gen-go-patch@v0.5.0
go install github.com/swaggo/swag/cmd/swag@v1.8.1
go install github.com/yoheimuta/protolint/cmd/protolint@v0.37.1
.PHONY: deps-npm
deps-npm:
npm install
.PHONY: check
check: swag
go test ./...
.PHONY: proto
proto: api/workerapi/v1/worker.pb.go
api/workerapi/v1/worker.pb.go: api/workerapi/v1/worker.proto
protoc -I . \
-I `go list -m -f {{.Dir}} github.com/alta/protopatch` \
-I `go list -m -f {{.Dir}} google.golang.org/protobuf` \
--go-patch_out=plugin=go,paths=source_relative:. \
--go-patch_out=plugin=go-grpc,paths=source_relative:. \
./api/workerapi/v1/worker.proto
# Generated files have some non-standard formatting, so let's format it.
goimports -w ./api/workerapi/v1/.
.PHONY: docker
docker:
docker build . \
--pull \
-t "quay.io/iver-wharf/wharf-cmd:latest" \
-t "quay.io/iver-wharf/wharf-cmd:$(version)" \
--build-arg BUILD_VERSION="$(version)" \
--build-arg BUILD_GIT_COMMIT="$(commit)" \
--build-arg BUILD_DATE="$(shell date --iso-8601=seconds)"
@echo ""
@echo "Push the image by running:"
@echo "docker push quay.io/iver-wharf/wharf-cmd:latest"
ifneq "$(version)" "latest"
@echo "docker push quay.io/iver-wharf/wharf-cmd:$(version)"
endif
.PHONY: docker-run
docker-run:
docker run --rm -it quay.io/iver-wharf/wharf-cmd:$(version)
.PHONY: clean-swag
clean-swag:
rm -vrf pkg/provisioner/provisionerserver/docs pkg/worker/workerserver/docs
.PHONY: swag-force
swag-force: clean-swag swag
.PHONY: swag
swag: \
pkg/provisioner/provisionerserver/docs \
pkg/worker/workerserver/docs
pkg/provisioner/provisionerserver/docs:
swag init \
--dir pkg/provisioner/provisionerserver,pkg/provisioner \
--parseDependency --parseDepth 1 \
--generalInfo provisionerserver.go \
--output pkg/provisioner/provisionerserver/docs \
--instanceName provisionerapi
pkg/worker/workerserver/docs:
swag init \
--dir pkg/worker/workerserver \
--parseDependency --parseDepth 2 \
--generalInfo restserver.go \
--output pkg/worker/workerserver/docs \
--instanceName workerapi
.PHONY: lint lint-fix \
lint-md lint-go lint-proto \
lint-fix-md lint-fix-go lint-fix-proto
lint: lint-md lint-go lint-proto
lint-fix: lint-fix-md lint-fix-go lint-fix-proto
lint-md:
npx remark . .github
lint-fix-md:
npx remark . .github -o
lint-go:
@echo goimports -d '**/*.go'
@goimports -d $(shell git ls-files "*.go")
revive -formatter stylish -config revive.toml ./...
lint-fix-go:
@echo goimports -d -w '**/*.go'
@goimports -d -w $(shell git ls-files "*.go")
lint-proto:
protolint lint api/workerapi
lint-fix-proto:
protolint lint -fix api/workerapi