-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (77 loc) · 3.28 KB
/
Copy pathMakefile
File metadata and controls
95 lines (77 loc) · 3.28 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
SHELL := /bin/sh
PROJECT ?= $(p)
VERSION ?= $(v)
TAG := v$(patsubst v%,%,$(VERSION))
DEVCTL_WORKSPACE_ROOT ?= $(abspath ..)
DEVCTL_VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo 0.0.0-dev)
COMPOSE := docker compose -f .docker/docker-compose.yml
DEVCTL := ./devctl
export DEVCTL_WORKSPACE_ROOT
export DEVCTL_VERSION
.PHONY: help install build boot proxy doctor up down stop ls logs validate clean check test release
help:
@echo "devctl commands:"
@echo " make install Install host wrapper into PATH"
@echo " make build Build devctl container image"
@echo " make boot Initialize state and start proxy"
@echo " make proxy Start Caddy proxy"
@echo " make doctor Check local environment"
@echo " make up p=<name> Start project"
@echo " make down p=<name> Stop project"
@echo " make stop Stop all managed projects"
@echo " make ls List services"
@echo " make logs p=<name> Show project logs"
@echo " make clean Remove devctl containers and state volume"
@echo " make validate Validate example .devctl.json profiles"
@echo " make check Validate code and config"
@echo " make test Run unit tests"
@echo " make release v=X.Y.Z Tag and push a release (CI publishes it)"
install:
./install.sh
build:
$(COMPOSE) build devctl
boot: build
$(DEVCTL) bootstrap
$(COMPOSE) up -d caddy
proxy:
$(COMPOSE) up -d caddy
doctor:
$(DEVCTL) doctor
up:
@test -n "$(PROJECT)" || { echo "Usage: make up p=<project>"; exit 2; }
$(DEVCTL) up "$(PROJECT)"
down:
@test -n "$(PROJECT)" || { echo "Usage: make down p=<project>"; exit 2; }
$(DEVCTL) down "$(PROJECT)"
stop:
$(DEVCTL) down --all
ls:
$(DEVCTL) list
logs:
@test -n "$(PROJECT)" || { echo "Usage: make logs p=<project>"; exit 2; }
$(DEVCTL) logs "$(PROJECT)"
clean:
$(COMPOSE) down --volumes --remove-orphans
validate:
@set -e; for profile in examples/profiles/*.devctl.json; do \
echo "Validating $$profile"; \
$(DEVCTL) validate --file "$$profile"; \
done
check: build validate
$(COMPOSE) config >/dev/null
$(COMPOSE) run --rm --entrypoint sh devctl -c 'python -m py_compile /usr/local/bin/devctl && python -m compileall -q "$$DEVCTL_REPO_ROOT"/src'
$(COMPOSE) run --rm --entrypoint sh devctl -c 'cd "$$DEVCTL_REPO_ROOT" && ruff check . && ruff format --check .'
test: build
$(COMPOSE) run --rm --entrypoint sh devctl -c 'cd "$$DEVCTL_REPO_ROOT" && python -m unittest discover -s . -p "test*.py" -v'
release:
@test -n "$(VERSION)" || { echo "Usage: make release v=X.Y.Z"; exit 2; }
@echo "$(TAG)" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$$' || { echo "Version must be X.Y.Z, got: $(VERSION)"; exit 2; }
@git diff --quiet && git diff --cached --quiet || { echo "Working tree is dirty; commit or stash first."; exit 2; }
@git fetch origin --tags
@! git rev-parse -q --verify "refs/tags/$(TAG)" >/dev/null || { echo "Tag $(TAG) already exists."; exit 2; }
@test "$$(git rev-parse HEAD)" = "$$(git rev-parse @{u})" || { echo "HEAD differs from upstream; push or pull first."; exit 2; }
git tag -a "$(TAG)" -m "$(TAG)"
git push origin "$(TAG)"
@echo "Pushed $(TAG). CI will run checks and publish the release:"
@echo " gh run list --workflow=release.yml --limit 1"
@echo "Then rebuild the local image: make build"