tenseleyflow/shithub / 5721d2f

Browse files

S37: Makefile — deploy/restore-drill/bench-staging targets

Authored by espadonne
SHA
5721d2fda4958d574135e9610e227b409806d1d5
Parents
195ca8f
Tree
03fd231

1 changed file

StatusFile+-
M Makefile 24 1
Makefilemodified
@@ -2,7 +2,7 @@
22
 # Targets mirror what CI runs. The Makefile is the source of truth.
33
 
44
 .DEFAULT_GOAL := help
5
-.PHONY: help dev build test test-race lint lint-policy lint-markdown lint-secret-logs fmt tidy clean ci assets install-tools version
5
+.PHONY: help dev build test test-race lint lint-policy lint-markdown lint-secret-logs fmt tidy clean ci assets install-tools version deploy deploy-check restore-drill bench-staging
66
 
77
 # Build metadata embedded into the binary via -ldflags.
88
 VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
@@ -152,3 +152,26 @@ version: ## Print version info that would be embedded into the binary.
152152
 	@echo "Version: $(VERSION)"
153153
 	@echo "Commit:  $(COMMIT)"
154154
 	@echo "Built:   $(BUILT)"
155
+
156
+# --- deploy ---
157
+# Inventory selection: ANSIBLE_INVENTORY=production make deploy (default: staging).
158
+ANSIBLE_INVENTORY ?= staging
159
+ANSIBLE_TAGS      ?=
160
+ANSIBLE_LIMIT     ?=
161
+
162
+deploy-check: ## Dry-run the Ansible playbook (--check) against $$ANSIBLE_INVENTORY.
163
+	cd deploy/ansible && ansible-playbook -i inventory/$(ANSIBLE_INVENTORY) site.yml --check --diff \
164
+		$(if $(ANSIBLE_TAGS),--tags $(ANSIBLE_TAGS)) \
165
+		$(if $(ANSIBLE_LIMIT),--limit $(ANSIBLE_LIMIT))
166
+
167
+deploy: ## Apply the Ansible playbook against $$ANSIBLE_INVENTORY (set to production for prod).
168
+	cd deploy/ansible && ansible-playbook -i inventory/$(ANSIBLE_INVENTORY) site.yml \
169
+		$(if $(ANSIBLE_TAGS),--tags $(ANSIBLE_TAGS)) \
170
+		$(if $(ANSIBLE_LIMIT),--limit $(ANSIBLE_LIMIT))
171
+
172
+restore-drill: ## Run the restore drill on the backup host (must be run via ssh on that host).
173
+	deploy/restore-drill/run.sh
174
+
175
+bench-staging: ## Run the bench harness against staging (BENCH_TARGET must be set to the staging URL).
176
+	@if [ -z "$$BENCH_TARGET" ]; then echo "set BENCH_TARGET=https://staging.shithub.example"; exit 2; fi
177
+	go run ./bench -target=$$BENCH_TARGET -iters=$${BENCH_ITERS:-50}