-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathmakefile
More file actions
169 lines (143 loc) · 5.12 KB
/
makefile
File metadata and controls
169 lines (143 loc) · 5.12 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
# 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')
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 .
.PHONY: swag
swag: ## Runs the swaggo/swag utility for generating the swagger yaml
swag init \
--parseDependency \
--parseInternal \
-g api/swagger.go \
-o docs
.PHONY: swagfmt
swagfmt: ## Runs swaggo/swag for formatting swag godoc comments
swag fmt
.PHONY: generate
generate: ## Regenerates ent code from schema
go generate ./pkg/storage/ent/...
.PHONY: build-local
build-local: ## Builds local artifacts with local toolchain
$(call print-target)
@mkdir -p ./build
CGO_ENABLED=1 GOEXPERIMENT=jsonv2 go build -ldflags "$(LDFLAGS)" -o ./build/ ./cli/tapes
CGO_ENABLED=1 GOEXPERIMENT=jsonv2 go build -ldflags "$(LDFLAGS)" -o ./build/ ./cli/tapesprox
CGO_ENABLED=1 GOEXPERIMENT=jsonv2 go build -ldflags "$(LDFLAGS)" -o ./build/ ./cli/tapesapi
.PHONY: install
install: build-local ## Builds local artifacts and installs to configured $GOPATH
$(call print-target)
cp ./build/tapes $(shell go env GOBIN)
cp ./build/tapesprox $(shell go env GOBIN)
cp ./build/tapesapi $(shell go env GOBIN)
.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-push-image
build-push-image: ## Builds and publishes multi-arch container images to ECR
dagger call \
build-push-image \
--registry=${REGISTRY} \
--tags=${VERSION} \
--tags=latest \
--version=${VERSION} \
--commit=${COMMIT}
.PHONY: up
up:
docker compose up --build
.PHONY: build-containers
build-containers: build-tapes-container build-api-container build-proxy-container ## Builds all container artifacts
.PHONY: build-tapes-container
build-tapes-container: ## Build the tapes container artifact
$(call print-target)
docker build -f dockerfiles/tapes.Dockerfile \
-t papercomputeco/tapes:$(VERSION) \
-t papercomputeco/tapes:latest \
.
.PHONY: build-api-container
build-api-container: ## Build the tapesapi container artifact
$(call print-target)
docker build -f dockerfiles/tapesapi.Dockerfile \
-t papercomputeco/api:$(VERSION) \
-t papercomputeco/api:latest \
.
.PHONY: build-proxy-container
build-proxy-container: ## Build the tapesprox container artifact
$(call print-target)
docker build -f dockerfiles/tapesprox.Dockerfile \
-t papercomputeco/proxy:$(VERSION) \
-t papercomputeco/proxy:latest \
.
.PHONY: clean
clean: ## Removes the "build" directory with built artifacts
$(call print-target)
@rm -rf ./build
.PHONY: unit-test
unit-test: ## Runs unit tests via "go test"
$(call print-target)
dagger call test
.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: test-kafka-e2e
test-kafka-e2e: ## Runs Kafka e2e proxy publish test
$(call print-target)
dagger call test-kafka-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