-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathmakefile
More file actions
241 lines (208 loc) · 8.19 KB
/
Copy pathmakefile
File metadata and controls
241 lines (208 loc) · 8.19 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
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
# Based around the auto-documented Makefile:
# http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
VERSION ?= $(shell git describe --tags --always --dirty)
COMMIT := $(shell git rev-parse HEAD)
BUILDTIME ?= $(shell date -u '+%Y-%m-%d %H:%M:%S')
REGISTRY ?= public.ecr.aws/g4e5l3z3/papercomputeco
IMAGE ?= tapes:dev
# extproc does NOT ship from REGISTRY. tapes and postgres are published to ECR
# Public, whose repositories are enumerated in terraform and carry an anonymous
# pull policy; tapes-extproc is a private ECR repository in the Tooling account
# that the data plane pulls via the cross-account role. The two are different
# registries with different auth, so they get different variables — pointing
# extproc at REGISTRY produces a push the release role has no permission for.
EXTPROC_REGISTRY ?= 952121199601.dkr.ecr.us-east-1.amazonaws.com
EXTPROC_IMAGE ?= tapes-extproc:dev
POSTHOG_API_KEY ?=
POSTHOG_ENDPOINT ?= https://us.i.posthog.com
LDFLAGS := -s -w \
-X 'github.com/papercomputeco/tapes/pkg/utils.Version=$(VERSION)' \
-X 'github.com/papercomputeco/tapes/pkg/utils.Sha=$(COMMIT)' \
-X 'github.com/papercomputeco/tapes/pkg/utils.Buildtime=$(BUILDTIME)' \
-X 'github.com/papercomputeco/tapes/pkg/telemetry.PostHogAPIKey=$(POSTHOG_API_KEY)' \
-X 'github.com/papercomputeco/tapes/pkg/telemetry.PostHogEndpoint=$(POSTHOG_ENDPOINT)'
.PHONY: check
check: ## Runs all dagger checks. Auto-fixes are not automatically applied.
$(call print-target)
dagger check
.PHONY: format
format: ## Runs golangci-lint linters and formatters with auto-fixes applied.
$(call print-target)
dagger call fix-lint export --path . --quiet
# tapes publishes two contracts — the read API and the ingest write surface are
# different servers with different trust models, see the header of
# ingest/openapi.go — and each server compiles its own from the routes it
# registered and serves it at GET /openapi. Neither is generated into a checked-in
# file, so neither can be stale, so there is nothing to regenerate or verify.
#
# What IS checked in is a fingerprint per surface: api/CONTRACT and
# ingest/CONTRACT. Those are not copies of the document, they are copies of its
# identity, and the specs beside them recompile and compare on every run — so a
# change to a published contract fails until someone writes the new value in,
# which turns "this changes a contract" into a line in the diff rather than
# something a reviewer has to infer. They seal the PROSE-STRIPPED document, so a
# doc-comment edit is not a contract event.
#
# `contracts` below writes the documents themselves, with per-field prose folded
# in from a checkout, for consumers that want bytes on disk. Still not checked
# in, and still read by nothing here.
.PHONY: contracts
contracts: ## Compiles both published OpenAPI contracts into ./build/contracts
$(call print-target)
dagger call contracts export --path ./build/contracts
.PHONY: generate
generate: ## Regenerates sqlc queries
sqlc generate
.PHONY: build-local
build-local: ## Builds local artifacts with local toolchain
$(call print-target)
@mkdir -p ./build
CGO_ENABLED=0 GOEXPERIMENT=jsonv2 go build -ldflags "$(LDFLAGS)" -o ./build/ ./cli/tapes
.PHONY: install
install: build-local ## Builds local artifacts and installs to configured $GOPATH
$(call print-target)
# install (not cp) writes a temp file and renames it into place: a fresh
# inode each time. Overwriting the binary in place invalidates the running
# Mach-O's code signature on macOS, which SIGKILLs the next invocation.
install -m 0755 ./build/tapes $(shell go env GOBIN)/tapes
.PHONY: build
build: ## Builds all cross-platform artifacts - Warning! MacOS may fail cross compiling toolchain dependency
dagger call \
build-release \
--version ${VERSION} \
--commit ${COMMIT} \
--post-hog-public-key="${POSTHOG_API_KEY}" \
export \
--path ./build
.PHONY: nightly
nightly: ## Builds and releases nightly tapes artifacts
dagger call \
nightly \
--commit=${COMMIT} \
--post-hog-public-key="${POSTHOG_API_KEY}" \
--endpoint=env://BUCKET_ENDPOINT \
--bucket=env://BUCKET_NAME \
--access-key-id=env://BUCKET_ACCESS_KEY_ID \
--secret-access-key=env://BUCKET_SECRET_ACCESS_KEY
.PHONY: upload-install-script
upload-install-script: ## Uploads the install script
dagger call \
upload-install-sh \
--endpoint=env://BUCKET_ENDPOINT \
--bucket=env://BUCKET_NAME \
--access-key-id=env://BUCKET_ACCESS_KEY_ID \
--secret-access-key=env://BUCKET_SECRET_ACCESS_KEY
.PHONY: release
release: ## Builds and releases tapes artifacts
dagger call \
release-latest \
--version=${VERSION} \
--commit=${COMMIT} \
--post-hog-public-key=$(POSTHOG_API_KEY) \
--endpoint=env://BUCKET_ENDPOINT \
--bucket=env://BUCKET_NAME \
--access-key-id=env://BUCKET_ACCESS_KEY_ID \
--secret-access-key=env://BUCKET_SECRET_ACCESS_KEY
.PHONY: build-images
build-images: build-tapes-image build-extproc-image ## Builds all container artifacts
.PHONY: build-local-image
build-local-image: ## Build a local Docker image for Kind/clearing (IMAGE=tapes:dev)
$(call print-target)
dagger call \
build-tapes-image \
--version=${VERSION} \
--commit=${COMMIT} \
export-image \
--name=${IMAGE}
.PHONY: build-tapes-image
build-tapes-image: ## Builds, tags, and loads the tapes container artifact locally
$(call print-target)
dagger call \
build-tapes-image \
--version=${VERSION} \
--commit=${COMMIT} \
export-image \
--name=${REGISTRY}/tapes:${VERSION}
dagger call \
build-tapes-image \
--version=${VERSION} \
--commit=${COMMIT} \
export-image \
--name=${REGISTRY}/tapes:latest
.PHONY: build-push-tapes-images
build-push-tapes-images: ## Builds and publishes the multi-arch tapes container images
dagger call \
build-push-tapes-images \
--registry=${REGISTRY} \
--tags=${VERSION} \
--tags=latest \
--version=${VERSION} \
--commit=${COMMIT}
.PHONY: up
up: ## Starts the default, fully containerized Compose stack
docker compose up --build
.PHONY: down
down: ## Stops the Compose stack without deleting its volumes
docker compose -f docker-compose.yaml down
.PHONY: clean
clean: ## Removes the "build" directory with built artifacts
$(call print-target)
@rm -rf ./build
.PHONY: test
test: ## Runs tests via "go test" in the Dagger services environment
$(call print-target)
dagger call test
.PHONY: test-run-id
test-run-id: ## Runs tests via "go test" in the Dagger services environment
$(call print-target)
dagger call test --run-id="$$(date +%s)"
.PHONY: parity
parity: ## Runs the envelope contract fixture gates (no services needed)
$(call print-target)
dagger call check-parity
.PHONY: test-extproc
test-extproc: ## Runs the ext_proc adapter's test suite (no services needed)
$(call print-target)
dagger call check-extproc
.PHONY: check-extproc-image
check-extproc-image: ## Builds the tapes-extproc image without loading it (CI gate)
$(call print-target)
dagger call \
build-extproc-image \
--version=${VERSION} \
--commit=${COMMIT} \
sync
.PHONY: build-extproc-image
build-extproc-image: ## Builds and loads the tapes-extproc image locally (EXTPROC_IMAGE=tapes-extproc:dev)
$(call print-target)
dagger call \
build-extproc-image \
--version=${VERSION} \
--commit=${COMMIT} \
export-image \
--name=${EXTPROC_IMAGE}
.PHONY: build-local-extproc-image
# Cross-repo clearing contract; keep the Dagger invocation owned by
# build-extproc-image.
build-local-extproc-image: ## Build a local tapes-extproc image for Kind/clearing
$(MAKE) build-extproc-image EXTPROC_IMAGE="$(EXTPROC_IMAGE)"
.PHONY: build-push-extproc-images
build-push-extproc-images: ## Builds and publishes the multi-arch tapes-extproc container images
dagger call \
build-push-extproc-images \
--registry=${EXTPROC_REGISTRY} \
--tags=${VERSION} \
--tags=latest \
--version=${VERSION} \
--commit=${COMMIT}
.PHONY: e2e-test
e2e-test: ## Runs end-to-end tests with Postgres and Ollama via Dagger
$(call print-target)
dagger call test-e-2-e
.PHONY: help
.DEFAULT_GOAL := help
help: ## Prints this help message
@grep -h -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef