-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathMakefile
More file actions
206 lines (171 loc) · 8 KB
/
Copy pathMakefile
File metadata and controls
206 lines (171 loc) · 8 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
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
PROJECT := enduro
MAKEDIR := hack/make
SHELL := /bin/bash
.DEFAULT_GOAL := help
.PHONY: *
DBG_MAKEFILE ?=
ifeq ($(DBG_MAKEFILE),1)
$(warning ***** starting Makefile for goal(s) "$(MAKECMDGOALS)")
$(warning ***** $(shell date))
else
# If we're not debugging the Makefile, don't echo recipes.
MAKEFLAGS += -s
endif
define NEWLINE
endef
IGNORED_PACKAGES := \
github.com/artefactual-labs/enduro/hack/% \
github.com/artefactual-labs/enduro/%/fake \
github.com/artefactual-labs/enduro/ui \
github.com/artefactual-labs/enduro/internal/api/design \
github.com/artefactual-labs/enduro/internal/api/gen/% \
github.com/artefactual-labs/enduro/internal/batch/fake \
github.com/artefactual-labs/enduro/internal/collection/fake \
github.com/artefactual-labs/enduro/internal/pipeline/fake \
github.com/artefactual-labs/enduro/internal/watcher/fake
PACKAGES := $(shell go list ./...)
TEST_PACKAGES := $(filter-out $(IGNORED_PACKAGES),$(PACKAGES))
TEST_IGNORED_PACKAGES := $(filter $(IGNORED_PACKAGES),$(PACKAGES))
# Configure bine.
export PATH := $(shell go tool bine path):$(PATH)
tool-%:
@go tool bine get $* 1> /dev/null
run: # @HELP Builds and run the enduro binary.
run: build
./build/enduro
build: # @HELP Builds the enduro binary.
build: GO ?= $(shell which go)
build: BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%T%z)
build: GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
build: LD_FLAGS ?= '-X "main.buildTime=$(BUILD_TIME)" -X main.gitCommit=$(GIT_COMMIT)'
build: GO_FLAGS ?= -ldflags=$(LD_FLAGS)
build:
mkdir -p ./build
$(GO) build -trimpath -o build/enduro $(GO_FLAGS) -v
deps: tool-go-mod-outdated # @HELP Lists available module dependency updates.
go list -u -m -json all | go-mod-outdated -update -direct
deps-upgrade-direct: # @HELP Upgrades direct module dependencies.
go list -m -u -f '{{if and .Update (not .Indirect)}}{{.Path}}@{{.Update.Version}}{{end}}' all | xargs go get
go mod tidy
test: # @HELP Run all tests and output a summary using gotestsum.
test: TFORMAT ?= testdox
test: GOTESTSUM_FLAGS ?=
test: GOTEST_FLAGS ?=
test: COMBINED_FLAGS ?= $(GOTEST_FLAGS) $(TEST_PACKAGES)
test: tool-gotestsum
gotestsum --format=$(TFORMAT) $(GOTESTSUM_FLAGS) -- $(COMBINED_FLAGS)
test-race: # @HELP Run all tests with the race detector.
test-race:
$(MAKE) test GOTEST_FLAGS="-race"
test-ci: # @HELP Run all tests in CI with coverage and the race detector.
test-ci:
$(MAKE) test GOTESTSUM_FLAGS="--junitfile=junit.xml" GOTEST_FLAGS="-race -coverprofile=covreport -covermode=atomic"
test-smoke: # @HELP Run the Dagger smoke tests against ambox.
test-smoke:
dagger -m hack/dagger call smoke-tests --source . export --path hack/dagger/runtime/artifacts
test-smoke-object-storage: # @HELP Run the Dagger S3 watcher smoke tests against MinIO variants and SeaweedFS.
test-smoke-object-storage:
dagger -m hack/dagger call object-storage-smoke-tests --source . export --path hack/dagger/runtime/object-storage-artifacts
list-tested-packages: # @HELP Print a list of packages being tested.
list-tested-packages:
$(foreach PACKAGE,$(TEST_PACKAGES),@echo $(PACKAGE)$(NEWLINE))
list-ignored-packages: # @HELP Print a list of packages ignored in testing.
list-ignored-packages:
$(foreach PACKAGE,$(TEST_IGNORED_PACKAGES),@echo $(PACKAGE)$(NEWLINE))
fmt: # @HELP Formats the code using golangci-lint.
fmt: tool-golangci-lint
golangci-lint fmt -v
lint: # @HELP Lints the code using golangci-lint.
lint: tool-golangci-lint
golangci-lint run -v --fix
gen-goa: # @HELP Generates Goa assets.
gen-goa: tool-goa
goa gen github.com/artefactual-labs/enduro/internal/api/design -o internal/api
@$(MAKE) gen-goa-json-pretty
gen-goa-json-pretty: goa_http_dir = "internal/api/gen/http"
gen-goa-json-pretty: json_files = $(shell find $(goa_http_dir) -type f -name "*.json" | sort -u)
gen-goa-json-pretty:
@for f in $(json_files); \
do (cat "$$f" | jq -S '.' >> "$$f".sorted && mv "$$f".sorted "$$f") \
&& echo "Formatting $$f with jq" || exit 1; \
done
clean: # @HELP Cleans temporary files.
clean:
rm -rf ./build ./dist
release-build: # @HELP Generate the release build with GoReleaser.
release-build: tool-goreleaser
goreleaser build --clean --auto-snapshot
ui: # @HELP Builds the UI.
ui:
npm --prefix=ui install
npm --prefix=ui run build
ui-dev:
ui-dev: # @HELP Serves the UI for development.
npm --prefix=ui run dev
frontend: # @HELP Builds the frontend app.
frontend:
npm ci --prefix frontend
npm run build --prefix frontend
frontend-dev:
frontend-dev: # @HELP Serves the frontend app for development.
npm run dev --prefix frontend
ui-client: # @HELP Generates the UI client using openapi-generator-cli.
ui-client:
rm -rf $(CURDIR)/ui/src/client
docker container run --rm --user $(shell id -u):$(shell id -g) --volume $(CURDIR):/local openapitools/openapi-generator-cli:v7.19.0 \
generate \
--input-spec /local/internal/api/gen/http/openapi3.json \
--generator-name typescript-fetch \
--output /local/ui/src/openapi-generator/ \
--global-property apiDocs=false,modelDocs=false,apiTests=false,modelTests=false \
-p "generateAliasAsModel=false" \
-p "withInterfaces=true" \
-p "supportsES6=true"
echo "@@@@ Please, review all warnings generated by openapi-generator-cli above!"
frontend-client: # @HELP Generates the frontend client using openapi-generator-cli.
frontend-client:
rm -rf $(CURDIR)/frontend/app/openapi-generator
docker container run --rm --user $(shell id -u):$(shell id -g) --volume $(CURDIR):/local openapitools/openapi-generator-cli:v7.19.0 \
generate \
--input-spec /local/internal/api/gen/http/openapi3.json \
--generator-name typescript-fetch \
--output /local/frontend/app/openapi-generator/ \
--global-property apiDocs=false,modelDocs=false,apiTests=false,modelTests=false \
-p "generateAliasAsModel=false" \
-p "withInterfaces=true" \
-p "supportsES6=true" \
-p "disallowAdditionalPropertiesIfNotPresent=false" \
-p "enumUnknownDefaultCase=true" \
-p "legacyDiscriminatorBehavior=false" \
-p "useSingleRequestParameter=true" \
-p "prefixParameterInterfaces=true" \
-p "stringEnums=true"
node $(CURDIR)/frontend/scripts/patch-openapi-runtime.mjs
echo "@@@@ Please, review all warnings generated by openapi-generator-cli above!"
db: # @HELP Opens the MySQL CLI.
db:
docker compose exec --user=root mysql mysql -hlocalhost -uroot -proot123
flush: # @HELP Flushes the enduro database.
flush:
docker compose exec --user=root mysql mysql -hlocalhost -uroot -proot123 -e "drop database enduro"
docker compose exec --user=root mysql mysql -hlocalhost -uroot -proot123 -e "create database enduro"
gen-mock: # @HELP Generates mocks with mockgen.
gen-mock: tool-mockgen
mockgen -typed -destination=./internal/batch/fake/mock_batch.go -package=fake github.com/artefactual-labs/enduro/internal/batch Service
mockgen -typed -destination=./internal/collection/fake/mock_collection.go -package=fake github.com/artefactual-labs/enduro/internal/collection Service
mockgen -typed -source=./internal/collection/bulk_workflow.go -destination=./internal/collection/mock_bulk_collection_service_test.go -package=collection -mock_names=bulkCollectionService=MockBulkCollectionService
mockgen -typed -destination=./internal/pipeline/fake/mock_pipeline.go -package=fake github.com/artefactual-labs/enduro/internal/pipeline Service
mockgen -typed -destination=./internal/watcher/fake/mock_watcher.go -package=fake github.com/artefactual-labs/enduro/internal/watcher Service
mockgen -typed -destination=./internal/watcher/fake/mock_watcher_unit.go -package=fake github.com/artefactual-labs/enduro/internal/watcher Watcher
temporal: # @HELP Runs a development instance of Temporal.
temporal: PORT := 55555
temporal: LOG_LEVEL := warn
temporal: tool-temporal-cli
temporal-cli server start-dev --namespace=default --port=$(PORT) --headless --log-format=pretty --log-level=$(LOG_LEVEL)
help: # @HELP Prints this message.
echo "TARGETS:"
grep -E '^.*: *# *@HELP' Makefile \
| awk ' \
BEGIN {FS = ": *# *@HELP"}; \
{ printf " %-30s %s\n", $$1, $$2 }; \
'