-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
192 lines (162 loc) · 8.48 KB
/
Makefile
File metadata and controls
192 lines (162 loc) · 8.48 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
# ─────────────────────────────────────────────────────────────────────────────
# CHESS Federated Knowledge Fabric Node — top-level Makefile
# ─────────────────────────────────────────────────────────────────────────────
SERVICES := catalog-service data-service identity-service notification-service
SVC_DIRS := $(addprefix services/,$(SERVICES))
MANAGE := bash scripts/manage.sh
BOLD := \033[1m
GREEN := \033[32m
CYAN := \033[36m
RESET := \033[0m
.DEFAULT_GOAL := build
.PHONY: help
help: ## Show this help
@printf '$(BOLD)CHESS Federated Knowledge Fabric Node$(RESET)\n\n'
@awk 'BEGIN {FS=":.*##"} /^[a-zA-Z_\/-]+:.*##/ \
{printf " $(CYAN)%-26s$(RESET) %s\n",$$1,$$2}' $(MAKEFILE_LIST)
# ─────────────────────────────────────────────────────────────────────────────
# Build
# ─────────────────────────────────────────────────────────────────────────────
.PHONY: build
build: ## Build all service binaries
@$(MANAGE) build
.PHONY: deps/tidy
deps/tidy: ## Tidy go.mod/go.sum for all services
@for svc in $(SVC_DIRS); do \
printf '$(GREEN)→ tidy $$svc$(RESET)\n'; \
$(MAKE) -C $$svc deps/tidy --no-print-directory; \
done
# ─────────────────────────────────────────────────────────────────────────────
# Local process management (no Docker)
# ─────────────────────────────────────────────────────────────────────────────
.PHONY: start
start: ## Start all services locally (logs -> .logs/)
@$(MANAGE) start
.PHONY: stop
stop: ## Stop all locally running services
@$(MANAGE) stop
.PHONY: restart
restart: ## Restart all locally running services
@$(MANAGE) restart
.PHONY: status
status: ## Show PID, port and health of every service
@$(MANAGE) status
.PHONY: logs
logs: ## Tail all service logs merged (use: make logs SVC=catalog-service)
ifdef SVC
@$(MANAGE) logs $(SVC)
else
@$(MANAGE) logs --all
endif
.PHONY: start/%
start/%: ## Start a single service e.g. make start/catalog-service
@$(MANAGE) build $*
@$(MANAGE) start $*
.PHONY: stop/%
stop/%: ## Stop a single service e.g. make stop/data-service
@$(MANAGE) stop $*
.PHONY: restart/%
restart/%: ## Restart a single service e.g. make restart/identity-service
@$(MANAGE) restart $*
.PHONY: logs/%
logs/%: ## Tail log for a single service e.g. make logs/catalog-service
@$(MANAGE) logs $*
# ─────────────────────────────────────────────────────────────────────────────
# Test, Format, Lint
# ─────────────────────────────────────────────────────────────────────────────
.PHONY: test
test: ## Run tests across all services
@for svc in $(SVC_DIRS); do \
printf '$(GREEN)→ test $$svc$(RESET)\n'; \
$(MAKE) -C $$svc test --no-print-directory; \
done
.PHONY: fmt
fmt: ## Format all Go source
@for svc in $(SVC_DIRS); do \
$(MAKE) -C $$svc fmt --no-print-directory; \
done
.PHONY: vet
vet: ## Run go vet across all services
@for svc in $(SVC_DIRS); do \
$(MAKE) -C $$svc vet --no-print-directory; \
done
.PHONY: lint
lint: ## Run golangci-lint across all services
@for svc in $(SVC_DIRS); do \
$(MAKE) -C $$svc lint --no-print-directory; \
done
# ─────────────────────────────────────────────────────────────────────────────
# Docker Compose (alternative to local process management)
# ─────────────────────────────────────────────────────────────────────────────
.PHONY: docker/up
docker/up: ## Start the full node with Docker Compose
docker compose up --build -d
@printf '$(GREEN)✓ Stack running$(RESET)\n'
.PHONY: docker/down
docker/down: ## Stop the Docker Compose stack
docker compose down
.PHONY: docker/logs
docker/logs: ## Tail Docker Compose logs
docker compose logs -f
.PHONY: docker/ps
docker/ps: ## Show Docker container status
docker compose ps
# ─────────────────────────────────────────────────────────────────────────────
# Demo & health
# ─────────────────────────────────────────────────────────────────────────────
.PHONY: demo
demo: ## Run the end-to-end curl demo (services must be running)
@bash scripts/demo.sh
# Usage: make probe KEY=btr VALUE=test-123-a
# make probe KEY=cycle VALUE=2026-1
# make probe KEY=beamline VALUE=3a
# make probe KEY=sample_name VALUE=silicon-std VERBOSE=1
# make probe KEY=btr VALUE=test-123-a DRY_RUN=1
.PHONY: probe
probe: ## Trace FOXDEN→data-service→SPARQL data flow (KEY=<field> VALUE=<val>)
@test -n "$(KEY)" || (echo "Usage: make probe KEY=<field> VALUE=<val>"; exit 1)
@test -n "$(VALUE)" || (echo "Usage: make probe KEY=<field> VALUE=<val>"; exit 1)
@python scripts/probe.py \
--key "$(KEY)" \
--value "$(VALUE)" \
$(if $(FOXDEN), --foxden "$(FOXDEN)") \
$(if $(DATA), --data "$(DATA)") \
$(if $(CATALOG), --catalog "$(CATALOG)") \
$(if $(LIMIT), --limit "$(LIMIT)") \
$(if $(DRY_RUN), --dry-run) \
$(if $(VERBOSE), --verbose)
# Usage: make probe-doi DID="/beamline=3a/btr=test-123-a/cycle=2026-1/sample_name=PAT-7271" \
# DOI="10.5281/zenodo.123456" \
# DOI_URL="https://doi.org/10.5281/zenodo.123456"
# make probe-doi DID="..." DOI="..." DOI_URL="..." INGEST=1 VERBOSE=1
.PHONY: probe-doi
probe-doi: ## Trace FOXDEN DOI→identity-service credential flow (DID= DOI= DOI_URL=)
@test -n "$(DID)" || (echo "Usage: make probe-doi DID=<did> DOI=<doi> DOI_URL=<url>"; exit 1)
@test -n "$(DOI)" || (echo "Usage: make probe-doi DID=<did> DOI=<doi> DOI_URL=<url>"; exit 1)
@test -n "$(DOI_URL)" || (echo "Usage: make probe-doi DID=<did> DOI=<doi> DOI_URL=<url>"; exit 1)
@python scripts/probe_doi.py \
--did "$(DID)" \
--doi "$(DOI)" \
--doi-url "$(DOI_URL)" \
$(if $(IDENTITY), --identity "$(IDENTITY)") \
$(if $(DATA), --data "$(DATA)") \
$(if $(FOXDEN), --foxden "$(FOXDEN)") \
$(if $(INGEST), --ingest) \
$(if $(VERBOSE), --verbose)
.PHONY: health
health: ## HTTP health check for all services (alias for status)
@$(MANAGE) status
# ─────────────────────────────────────────────────────────────────────────────
# Clean
# ─────────────────────────────────────────────────────────────────────────────
.PHONY: clean
clean: ## Remove build artefacts (bin/) for all services
@for svc in $(SVC_DIRS); do \
$(MAKE) -C $$svc clean --no-print-directory; \
done
.PHONY: clean/run
clean/run: ## Remove PID and log files (.run/ .logs/)
@rm -rf .run .logs
@printf '$(GREEN)✓ .run/ and .logs/ removed$(RESET)\n'
.PHONY: clean/all
clean/all: stop clean clean/run ## Stop services + remove all generated files