-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
124 lines (95 loc) · 4.39 KB
/
Copy pathMakefile
File metadata and controls
124 lines (95 loc) · 4.39 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
# CNF — Cluster Nova Federation
# Developer convenience targets. Run `make help` for the full list.
# Use bash with strict flags for recipe execution.
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help
# Tooling — override on the command line, e.g. `make test PYTHON=python3.11`.
PYTHON ?= python3
PIP ?= $(PYTHON) -m pip
COMPOSE ?= docker compose
PROTO_DIR ?= proto
GRPC_OUT ?= cnf/grpc
IMAGE ?= openstack-cnf
TAG ?= 0.1.0
CNF_CONFIG ?= etc/cnf/cnf.yaml
# Infra services started for local development (see docker-compose.yml).
INFRA_SERVICES ?= postgres redis etcd
.PHONY: help
help: ## Show this help
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) \
| sort \
| awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-18s\033[0m %s\n", $$1, $$2}'
# ── Install ────────────────────────────────────────────────────────────────
.PHONY: install
install: ## Install the package (runtime deps only)
$(PIP) install --upgrade pip
$(PIP) install .
.PHONY: install-dev
install-dev: ## Editable install with dev extras (tests, lint, type)
$(PIP) install --upgrade pip
$(PIP) install -e ".[dev]"
.PHONY: proto
proto: ## Compile gRPC stubs from proto/cnf.proto into cnf/grpc/
$(PYTHON) -m grpc_tools.protoc \
-I $(PROTO_DIR) \
--python_out=$(GRPC_OUT) \
--grpc_python_out=$(GRPC_OUT) \
$(PROTO_DIR)/cnf.proto
# ── Quality ────────────────────────────────────────────────────────────────
.PHONY: lint
lint: ## Run ruff + mypy static checks
$(PYTHON) -m ruff check cnf tests
$(PYTHON) -m mypy cnf
.PHONY: format
format: ## Auto-format with black and apply ruff fixes
$(PYTHON) -m black cnf tests
$(PYTHON) -m ruff check --fix cnf tests
.PHONY: test
test: ## Run the test suite
$(PYTHON) -m pytest
.PHONY: test-cov
test-cov: ## Run tests with an HTML coverage report
$(PYTHON) -m pytest --cov=cnf --cov-report=term-missing --cov-report=html
.PHONY: tox
tox: ## Run the full tox matrix (lint, type, tests)
$(PYTHON) -m tox
# ── Database ───────────────────────────────────────────────────────────────
.PHONY: migrate
migrate: ## Apply Alembic database migrations (upgrade head)
$(PYTHON) -m alembic upgrade head
.PHONY: migration
migration: ## Create a new autogenerated migration: make migration m="message"
$(PYTHON) -m alembic revision --autogenerate -m "$(m)"
# ── Run ────────────────────────────────────────────────────────────────────
.PHONY: run
run: ## Run the CNF agent in the foreground
CNF_CONFIG=$(CNF_CONFIG) cnf-agent
.PHONY: worker
worker: ## Run a Celery worker for async migration tasks
$(PYTHON) -m celery -A cnf.tasks.migration_tasks:app worker --loglevel=info
.PHONY: beat
beat: ## Run the Celery beat scheduler
$(PYTHON) -m celery -A cnf.tasks.migration_tasks:app beat --loglevel=info
# ── Local infrastructure (Docker) ──────────────────────────────────────────
.PHONY: infra-up
infra-up: ## Start local infra (postgres, redis, etcd) in the background
$(COMPOSE) up -d $(INFRA_SERVICES)
.PHONY: infra-down
infra-down: ## Stop local infra containers
$(COMPOSE) down
.PHONY: stack-up
stack-up: ## Build and start the full local stack (two simulated clusters)
$(COMPOSE) up --build
.PHONY: logs
logs: ## Tail logs from the local stack
$(COMPOSE) logs -f
.PHONY: docker-build
docker-build: ## Build the runtime Docker image ($(IMAGE):$(TAG))
docker build -t $(IMAGE):$(TAG) .
# ── Housekeeping ───────────────────────────────────────────────────────────
.PHONY: clean
clean: ## Remove build, cache, and coverage artifacts
rm -rf build dist *.egg-info .pytest_cache .mypy_cache .ruff_cache .tox htmlcov .coverage
find . -type d -name __pycache__ -prune -exec rm -rf {} +
find . -type f -name '*.pyc' -delete