-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
240 lines (195 loc) · 6.84 KB
/
Makefile
File metadata and controls
240 lines (195 loc) · 6.84 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
PROJECTS := py ts rust
.PHONY: help
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Run-all targets (operate on all projects):'
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+:.*?##/ && !/^[a-zA-Z_-]+-%:/ { printf " %-20s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@echo ''
@echo 'Project-specific targets (use with -<project> suffix, e.g., -py, -ts):'
@awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z_-]+-%:.*?##/ { gsub(/-%/, "-<project>", $$1); printf " %-20s %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
@echo ''
@echo 'Available projects:'
@for project in $(PROJECTS); do \
echo " - $$project"; \
done
# run a make command in the given directory
run-for:
@if [ -d "./$(PROJECT)" ]; then \
if [ -f "./$(PROJECT)/Makefile" ]; then \
cd ./$(PROJECT) && make $(CMD); \
else \
echo "Error: Makefile not found in ./$(PROJECT) directory"; \
exit 1; \
fi; \
else \
echo "Error: Directory ./$(PROJECT) does not exist"; \
exit 1; \
fi
.PHONY: check
check: ## Check all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=check; \
done
.PHONY: check-%
check-%: ## Check the given project
@$(MAKE) run-for PROJECT=$(@:check-%=%) CMD=check
.PHONY: install
install: ## Install dependencies for all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=install; \
done
.PHONY: install-%
install-%: ## Install dependencies for the given project
@$(MAKE) run-for PROJECT=$(@:install-%=%) CMD=install
.PHONY: dev
dev: ## Run development server for the rust project
@$(MAKE) run-for PROJECT=rust CMD=dev
.PHONY: dev-%
dev-%: ## Run development server for the given project
@$(MAKE) run-for PROJECT=$(@:dev-%=%) CMD=dev
.PHONY: build
build: ## Build all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=build; \
done
.PHONY: build-%
build-%: ## Build the given project
@$(MAKE) run-for PROJECT=$(@:build-%=%) CMD=build
.PHONY: test
test: ## Run tests for all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=test; \
done
.PHONY: test-%
test-%: ## Run tests for the given project
@$(MAKE) run-for PROJECT=$(@:test-%=%) CMD=test
.PHONY: test-unit
test-unit: ## Run unit tests (no external dependencies)
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=test-unit; \
done
.PHONY: test-integration
test-integration: ## Run integration tests (requires local services)
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=test-integration; \
done
.PHONY: lint
lint: ## Run linters for all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=lint; \
done
.PHONY: lint-%
lint-%: ## Run linters for the given project
@$(MAKE) run-for PROJECT=$(@:lint-%=%) CMD=lint
.PHONY: fmt
fmt: ## Format all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=fmt; \
done
.PHONY: fmt-%
fmt-%: ## Format the given project
@$(MAKE) run-for PROJECT=$(@:fmt-%=%) CMD=fmt
.PHONY: fmt-check
fmt-check: ## Check formatting for all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=fmt-check; \
done
.PHONY: fmt-check-%
fmt-check-%: ## Check formatting for the given project
@$(MAKE) run-for PROJECT=$(@:fmt-check-%=%) CMD=fmt-check
.PHONY: types
types: ## Run type checking for all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=types; \
done
.PHONY: types-%
types-%: ## Run type checking for the given project
@$(MAKE) run-for PROJECT=$(@:types-%=%) CMD=types
.PHONY: setup
setup: ## Setup local development (database + redis)
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=setup; \
done
.PHONY: setup-%
setup-%: ## Setup local development for the given project
@$(MAKE) run-for PROJECT=$(@:setup-%=%) CMD=setup
.PHONY: wipe
wipe: ## Drop all databases (keeps containers running)
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=wipe; \
done
.PHONY: wipe-%
wipe-%: ## Drop databases for the given project
@$(MAKE) run-for PROJECT=$(@:wipe-%=%) CMD=wipe
.PHONY: teardown
teardown: ## Stop and remove all containers and volumes
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=teardown; \
done
.PHONY: teardown-%
teardown-%: ## Teardown containers for the given project
@$(MAKE) run-for PROJECT=$(@:teardown-%=%) CMD=teardown
.PHONY: docker-build
docker-build: ## Build Docker images for all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=docker-build; \
done
.PHONY: docker-build-%
docker-build-%: ## Build Docker image for the given project
@$(MAKE) run-for PROJECT=$(@:docker-build-%=%) CMD=docker-build
.PHONY: docker-up
docker-up: ## Start docker-compose with vault secrets (rebuilds images)
@./bin/vault run --stage development -- docker compose up --build
.PHONY: docker-down
docker-down: ## Stop docker-compose
@docker compose down
.PHONY: docker-clean
docker-clean: ## Remove docker images and volumes
@docker compose down -v --rmi local
.PHONY: clean
clean: ## Clean all projects
@for project in $(PROJECTS); do \
$(MAKE) run-for PROJECT=$$project CMD=clean; \
done
.PHONY: clean-%
clean-%: ## Clean the given project
@$(MAKE) run-for PROJECT=$(@:clean-%=%) CMD=clean
.PHONY: ports
ports: ## Show dev server port assignment for current branch
@./bin/worktree-ports
.PHONY: worktree-create
worktree-create: ## Create a new git worktree - usage: make worktree-create BRANCH=<branch-name>
@if [ -z "$(BRANCH)" ]; then \
echo "Error: BRANCH is required. Usage: make worktree-create BRANCH=feature/my-branch"; \
exit 1; \
fi
@./bin/worktree --repo . create $(BRANCH)
.PHONY: worktree-list
worktree-list: ## List all git worktrees
@./bin/worktree --repo . list
.PHONY: worktree-remove
worktree-remove: ## Remove a git worktree - usage: make worktree-remove BRANCH=<branch-name>
@if [ -z "$(BRANCH)" ]; then \
echo "Error: BRANCH is required. Usage: make worktree-remove BRANCH=feature/my-branch"; \
exit 1; \
fi
@./bin/worktree --repo . remove $(BRANCH)
.PHONY: worktree-cleanup
worktree-cleanup: ## Remove all git worktrees
@./bin/worktree --repo . cleanup
# Terraform Cloud management - pass all arguments after 'tfc' to the script
.PHONY: tfc
tfc: ## Terraform Cloud management - pass all arguments after 'tfc' to the script
@./bin/tfc $(filter-out $@,$(MAKECMDGOALS))
# Infrastructure management - pass all arguments after 'iac' to the script
.PHONY: iac
iac: ## Infrastructure management - run terraform with vault secrets
@./bin/iac $(filter-out $@,$(MAKECMDGOALS))
# Deployment management - pass all arguments after 'deploy' to the kamal script
.PHONY: kamal
kamal: ## Deploy services using Kamal - usage: make kamal <service> <stage> <command>
@./bin/kamal $(filter-out $@,$(MAKECMDGOALS))
# Catch additional arguments to tfc, ghcr, iac, and deploy commands
%:
@: