forked from ohsu-comp-bio/funnel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
282 lines (225 loc) · 10.2 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
# The commands used in this Makefile expect to be interpreted by bash.
SHELL := /bin/bash
TESTS=$(shell go list ./... | grep -v /vendor/ | grep -v github-release-notes)
PROTO_INC=-I ./ -I $(shell pwd)/util/proto/
git_commit := $(shell git rev-parse --short HEAD)
git_branch := $(shell git symbolic-ref -q --short HEAD)
git_upstream := $(shell git remote get-url $(shell git config branch.$(shell git symbolic-ref -q --short HEAD).remote) 2> /dev/null)
export GIT_BRANCH = $(git_branch)
export GIT_UPSTREAM = $(git_upstream)
export FUNNEL_VERSION=0.11.0
# LAST_PR_NUMBER is used by the release notes builder to generate notes
# based on pull requests (PR) up until the last release.
export LAST_PR_NUMBER = 716
VERSION_LDFLAGS=\
-X "github.com/ohsu-comp-bio/funnel/version.BuildDate=$(shell date)" \
-X "github.com/ohsu-comp-bio/funnel/version.GitCommit= $(git_commit)" \
-X "github.com/ohsu-comp-bio/funnel/version.GitBranch=$(git_branch)" \
-X "github.com/ohsu-comp-bio/funnel/version.GitUpstream=$(git_upstream)"
export CGO_ENABLED=0
# Build the code
install:
@touch version/version.go
@go install -ldflags '$(VERSION_LDFLAGS)' .
# Build the code
build:
@touch version/version.go
@go build -ldflags '$(VERSION_LDFLAGS)' -buildvcs=false .
# Build an unoptimized version of the code for use during debugging
# https://go.dev/doc/gdb
debug:
@go install -gcflags=all="-N -l"
@funnel server run
# Generate the protobuf/gRPC code
proto:
@cd tes && protoc \
$(PROTO_INC) \
--go_out ./ \
--go_opt paths=source_relative \
--go-grpc_out ./ \
--go-grpc_opt paths=source_relative \
--grpc-gateway_out ./ \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt paths=source_relative \
tes.proto
@cd compute/scheduler && protoc \
$(PROTO_INC) \
--go_out ./ \
--go_opt paths=source_relative \
--go-grpc_out ./ \
--go-grpc_opt paths=source_relative \
--grpc-gateway_out ./ \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt paths=source_relative \
scheduler.proto
@cd events && protoc \
$(PROTO_INC) \
-I ../tes \
--go_out ./ \
--go_opt paths=source_relative \
--go-grpc_out ./ \
--go-grpc_opt paths=source_relative \
--grpc-gateway_out ./ \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt paths=source_relative \
events.proto
proto-depends:
@git submodule update --init --recursive
@go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
@go install github.com/grpc-ecosystem/grpc-gateway/v2/[email protected]
@go install google.golang.org/protobuf/cmd/[email protected]
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
@go install github.com/ckaznocha/[email protected]
# Start API reference doc server
serve-doc:
@go get golang.org/x/tools/cmd/godoc
godoc --http=:6060
# Automatially update code formatting
tidy:
@go get golang.org/x/tools/cmd/goimports
@find . \( -path ./vendor -o -path ./webdash/node_modules -o -path ./venv -o -path ./.git \) -prune -o -type f -print | grep -v "\.pb\." | grep -v "web.go" | grep -E '.*\.go$$' | xargs goimports -w
@find . \( -path ./vendor -o -path ./webdash/node_modules -o -path ./venv -o -path ./.git \) -prune -o -type f -print | grep -v "\.pb\." | grep -v "web.go" | grep -E '.*\.go$$' | xargs gofmt -w -s
lint-depends:
go install github.com/golangci/golangci-lint/cmd/[email protected]
go install golang.org/x/tools/cmd/goimports
# Run code style and other checks
lint:
@golangci-lint run --timeout 3m --disable-all --enable=vet --enable=golint --enable=gofmt --enable=goimports --enable=misspell \
--skip-dirs "vendor" \
--skip-dirs "webdash" \
--skip-dirs "cmd/webdash" \
--skip-dirs "funnel-work-dir" \
-e '.*bundle.go' -e ".*pb.go" -e ".*pb.gw.go" \
./...
@golangci-lint run --timeout 3m --disable-all --enable=vet --enable=gofmt --enable=goimports --enable=misspell ./cmd/termdash/...
# Run all tests
test:
@go test $(TESTS)
test-verbose:
@go test -v $(TESTS)
start-elasticsearch:
@docker rm -f funnel-es-test > /dev/null 2>&1 || echo
@docker run -d --name funnel-es-test -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "xpack.security.enabled=false" docker.elastic.co/elasticsearch/elasticsearch:5.6.3 > /dev/null
test-elasticsearch:
@go test ./tests/core/ -funnel-config `pwd`/tests/elastic.config.yml
@go test ./tests/scheduler/ -funnel-config `pwd`/tests/elastic.config.yml
start-mongodb:
@docker rm -f funnel-mongodb-test > /dev/null 2>&1 || echo
@docker run -d --name funnel-mongodb-test -p 27000:27017 docker.io/mongo > /dev/null
test-mongodb:
@go version
@go test ./tests/core/ --funnel-config `pwd`/tests/mongo.config.yml
@go test ./tests/scheduler/ --funnel-config `pwd`/tests/mongo.config.yml
test-badger:
@go version
@go test ./tests/core/ -funnel-config `pwd`/tests/badger.config.yml
start-dynamodb:
@docker rm -f funnel-dynamodb-test > /dev/null 2>&1 || echo
@docker run -d --name funnel-dynamodb-test -p 18000:8000 docker.io/dwmkerr/dynamodb:38 -sharedDb > /dev/null
test-dynamodb:
@go test ./tests/core/ -funnel-config `pwd`/tests/dynamo.config.yml
start-datastore:
@docker rm -f funnel-datastore-test > /dev/null 2>&1 || echo
@docker run -d --name funnel-datastore-test -p 12432:12432 google/cloud-sdk:latest gcloud beta emulators datastore start --no-store-on-disk --host-port 0.0.0.0:12432 --project funnel-test
test-datastore:
DATASTORE_EMULATOR_HOST=localhost:12432 \
go test ./tests/core/ -funnel-config `pwd`/tests/datastore.config.yml
start-kafka:
@docker rm -f funnel-kafka > /dev/null 2>&1 || echo
@docker run -d --name funnel-kafka -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST="localhost" --env ADVERTISED_PORT=9092 spotify/kafka
test-kafka:
@go test ./tests/kafka/ -funnel-config `pwd`/tests/kafka.config.yml
test-htcondor:
@docker pull ohsucompbio/htcondor
@go test -timeout 120s ./tests/htcondor -funnel-config `pwd`/tests/htcondor.config.yml
test-slurm:
@go version
@docker pull quay.io/ohsu-comp-bio/slurm
@go test -timeout 120s ./tests/slurm -funnel-config `pwd`/tests/slurm.config.yml
test-gridengine:
@docker pull ohsucompbio/gridengine
@go test -timeout 120s ./tests/gridengine -funnel-config `pwd`/tests/gridengine.config.yml
test-pbs-torque:
@docker pull ohsucompbio/pbs-torque
@go test -timeout 120s ./tests/pbs -funnel-config `pwd`/tests/pbs.config.yml
test-amazon-s3:
@go test -v ./tests/storage -funnel-config `pwd`/tests/s3.config.yml -run TestAmazonS3
start-generic-s3:
@docker rm -f funnel-s3server > /dev/null 2>&1 || echo
@docker run -d --name funnel-s3server -p 18888:8000 -e REMOTE_MANAGEMENT_DISABLE=1 zenko/cloudserver
@docker rm -f funnel-minio > /dev/null 2>&1 || echo
@docker run -d --name funnel-minio -p 9000:9000 -e "MINIO_ACCESS_KEY=fakekey" -e "MINIO_SECRET_KEY=fakesecret" -e "MINIO_REGION=us-east-1" minio/minio server /data
test-generic-s3:
@go test -v ./tests/storage -funnel-config `pwd`/tests/amazoncli-minio-s3.config.yml -run TestAmazonS3Storage
@go test -v ./tests/storage -funnel-config `pwd`/tests/scality-s3.config.yml -run TestGenericS3Storage
@go test -v ./tests/storage -funnel-config `pwd`/tests/minio-s3.config.yml -run TestGenericS3Storage
@go test -v ./tests/storage -funnel-config `pwd`/tests/multi-s3.config.yml -run TestGenericS3Storage
test-gs:
@go test ./tests/storage -run TestGoogleStorage -funnel-config `pwd`/tests/gs.config.yml ${GCE_PROJECT_ID}
test-swift:
@go test ./tests/storage -funnel-config `pwd`/tests/swift.config.yml -run TestSwiftStorage
start-pubsub:
@docker rm -f funnel-pubsub-test > /dev/null 2>&1 || echo
@docker run -d --name funnel-pubsub-test -p 8085:8085 google/cloud-sdk:latest gcloud beta emulators pubsub start --project funnel-test --host-port 0.0.0.0:8085
test-pubsub:
@PUBSUB_EMULATOR_HOST=localhost:8085 \
go test ./tests/pubsub/ -funnel-config `pwd`/tests/pubsub.config.yml
start-ftp:
@cd tests/ftp-test-server/ && ./start-server.sh
test-ftp:
@go test -v ./tests/storage -run TestFTPStorage -funnel-config `pwd`/tests/ftp.config.yml
# Build the web dashboard
webdash:
@go get -u github.com/go-bindata/go-bindata/...
@cd webdash && yarn build
@go-bindata -pkg webdash -prefix "webdash/build" -o webdash/web.go webdash/build/...
# Build binaries for all OS/Architectures
snapshot: release-dep
@goreleaser \
--clean \
--snapshot
# build a docker container locally
docker:
docker build -t ohsucompbio/funnel:latest ./
# build a docker container that supports docker-in-docker
docker-dind:
docker build -t ohsucompbio/funnel-dind:latest -f Dockerfile.dind .
# build a docker container that supports rootless docker-in-docker
docker-dind-rootless:
docker build -t ohsucompbio/funnel-dind-rootless:latest -f Dockerfile.dind-rootless .
# Create a release on Github using GoReleaser
release:
@go get github.com/buchanae/github-release-notes
@goreleaser \
--clean \
--release-notes <(github-release-notes -org ohsu-comp-bio -repo funnel -stop-at ${LAST_PR_NUMBER})
# Install dependencies for release
release-dep:
@go get github.com/goreleaser/goreleaser
@go get github.com/buchanae/github-release-notes
# Generate mocks for testing.
gen-mocks:
@go get github.com/vektra/mockery/...
@mockery -dir compute/scheduler -name Client -inpkg -output compute/scheduler
@mockery -dir compute/scheduler -name SchedulerServiceServer -inpkg -output compute/scheduler
# Bundle example task messages into Go code.
bundle-examples:
@go-bindata -pkg examples -o examples/internal/bundle.go $(shell find examples/ -name '*.json')
@go-bindata -pkg config -o config/internal/bundle.go $(shell find config/ -name '*.txt' -o -name '*.yaml')
@gofmt -w -s examples/internal/bundle.go config/internal/bundle.go
# Make everything usually needed to prepare for a pull request
full: proto install tidy lint test website webdash
# Build the website
website:
@cp ./config/*.txt ./website/static/funnel-config-examples/
@cp ./config/default-config.yaml ./website/static/funnel-config-examples/
hugo --source ./website
# Serve the Funnel website on localhost:1313
website-dev:
@cp ./config/*.txt ./website/static/funnel-config-examples/
@cp ./config/default-config.yaml ./website/static/funnel-config-examples/
hugo --source ./website -w server
# Remove build/development files.
clean:
@rm -rf ./bin ./pkg ./test_tmp ./build ./buildtools
.PHONY: proto website docker webdash build debug