-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
135 lines (108 loc) · 4.27 KB
/
Makefile
File metadata and controls
135 lines (108 loc) · 4.27 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
# GridStream Makefile.
#
# This is the Stage-1 adoption surface from ADR-0006: a `Makefile` is
# the first artifact teams adopt, ahead of the shared workflow and the
# chart. Targets here mirror what's documented in docs/paved-road.md.
.DEFAULT_GOAL := help
# ─── Configuration ──────────────────────────────────────────────────────────
# single-source-of-truth
PYTHON_VERSION := $(shell cut -d. -f1,2 .python-version)
# Local Kind cluster name. Override with `make CLUSTER=foo infra-up`.
CLUSTER ?= gridstream
KIND_CONFIG ?= kind/cluster.yaml
# Stub service.
STUB_NAME := standard-service-stub
STUB_DIR := packages/standard-service-stub
STUB_IMAGE := gridstream-$(STUB_NAME):dev
# Standard "make help" niceties.
GREEN := \033[32m
CYAN := \033[36m
BOLD := \033[1m
RESET := \033[0m
##@ Workflow
.PHONY: help
help: ## Show this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make $(CYAN)<target>$(RESET)\n"} \
/^[a-zA-Z_0-9-]+:.*?##/ { printf " $(CYAN)%-15s$(RESET) %s\n", $$1, $$2 } \
/^##@/ { printf "\n$(BOLD)%s$(RESET)\n", substr($$0, 5) }' $(MAKEFILE_LIST)
##@ Setup
.PHONY: setup
setup: ## Sync workspace dependencies and install pre-commit hooks.
uv sync --all-extras --dev
uv run pre-commit install
uv run pre-commit install --hook-type commit-msg
##@ Quality Gates (ADR-0005, ADR-0011)
.PHONY: lint
lint: ## Ruff check + format check across the workspace.
uv run ruff check .
uv run ruff format --check .
.PHONY: typecheck
typecheck: ## Mypy strict type-check on the stub.
uv run mypy $(STUB_DIR)/src $(STUB_DIR)/tests
.PHONY: test
test: ## Run pytest with the 80% coverage gate.
uv run pytest $(STUB_DIR)/tests \
--cov=$(STUB_DIR)/src \
--cov-report=term-missing \
--cov-fail-under=80
.PHONY: check-schema
# Validates the schema FILE is well-formed
check-schema: ## Smoke-test charts/standard-service/values.schema.json (ADR-0011).
@scripts/check-chart-schema.sh
.PHONY: check-chart
# Validates schema's BEHAVIOR — that helm actually rejects const-pinned and
# required-field violations at template/install time
check-chart: ## Verify helm enforces the values schema (ADR-0011 phase 2).
@scripts/check-chart-behavior.sh
.PHONY: hooks
hooks: ## Run all pre-commit hooks against all files (broader gate than lint)
@uv run pre-commit run --all-files
##@ Build (ADR-0009)
.PHONY: build
build: ## Build the stub's distroless production image.
docker build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
-f $(STUB_DIR)/Dockerfile \
-t $(STUB_IMAGE) \
.
.PHONY: build-dev
build-dev: ## Build the stub's slim local-dev image (NOT FOR PRODUCTION).
docker build \
--build-arg PYTHON_VERSION=$(PYTHON_VERSION) \
-f $(STUB_DIR)/Dockerfile.dev \
-t $(STUB_IMAGE)-dev \
.
##@ Local Cluster
.PHONY: infra-up
infra-up: ## Start the local Kind cluster.
@if kind get clusters 2>/dev/null | grep -q '^$(CLUSTER)$$'; then \
echo "$(GREEN)→$(RESET) Cluster '$(CLUSTER)' already up."; \
else \
kind create cluster --name $(CLUSTER) --config $(KIND_CONFIG); \
fi
.PHONY: infra-down
infra-down: ## Tear down the local Kind cluster.
kind delete cluster --name $(CLUSTER)
.PHONY: deploy-local
deploy-local: build check-schema check-chart ## Build, kind-load, and helm-install the stub.
kind load docker-image $(STUB_IMAGE) --name $(CLUSTER)
helm upgrade --install $(STUB_NAME) charts/standard-service \
--set app.name=$(STUB_NAME) \
--set image.repository=gridstream-$(STUB_NAME) \
--set image.tag=dev \
--wait
@echo ""
@echo "$(GREEN)Stub deployed.$(RESET) Try:"
@echo " kubectl get pods -l app.kubernetes.io/instance=$(STUB_NAME)"
@echo " kubectl port-forward svc/$(STUB_NAME) 8000:80"
@echo " curl http://localhost:8000/healthz"
.PHONY: smoke-test
smoke-test: ## Smoke-test the deployed standard-service-stub.
@scripts/smoke-test.sh
# Use uv run to activate the project venv (python and pyyaml resolve from there).
.PHONY: check-no-code-changes
check-no-code-changes: ## Verify pending changes touch only comments/docs
@uv run python scripts/check_no_code_changes.py $(ARGS)
.PHONY: check-docs-only
check-docs-only: check-no-code-changes ## Pre-deploy guard: safe to skip re-test?
@echo "✓ docs-only change confirmed — re-test not required"