-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
588 lines (525 loc) · 23.2 KB
/
Makefile
File metadata and controls
588 lines (525 loc) · 23.2 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# SimpulseID Credentials Makefile
# ================================
.PHONY: setup install generate validate lint format test story check all clean help \
release-artifacts \
_help_general _help_setup _help_install _help_validate _help_lint _help_format _help_test _help_story \
_setup_default _setup_submodules _install_default _install_dev _install_docs \
_validate_all _validate_simpulseid _validate_harbour \
_lint_default _lint_md _format_default _format_md \
_test_all _test_harbour _test_simpulseid _test_cov \
_story_all _story_simpulseid _story_harbour _story_sign _story_verify
OMB_SUBMODULE_DIR := submodules/harbour-credentials/submodules/ontology-management-base
HARBOUR_SUBMODULE_DIR := submodules/harbour-credentials
LINKML_SUBMODULE_DIR := $(OMB_SUBMODULE_DIR)/submodules/linkml/packages/linkml
# Absolute path to repo root — used when cd'ing into submodules to reference
# back to top-level paths (avoids fragile ../../../../ paths).
REPO_ROOT := $(abspath .)
# Allow callers to override the venv path/tooling.
VENV ?= .venv
# OS detection for cross-platform support (Windows vs Unix)
ifeq ($(OS),Windows_NT)
ifndef CI
ifneq ($(wildcard ../../.venv/Scripts/python.exe),)
VENV := ../../.venv
endif
endif
VENV_BIN := $(VENV)/Scripts
VENV_PYTHON := $(VENV_BIN)/python.exe
ifdef CI
PYTHON ?= python
else
PYTHON ?= $(VENV_PYTHON)
endif
BOOTSTRAP_PYTHON ?= python
ACTIVATE_SCRIPT := $(VENV_BIN)/activate
ACTIVATE_HINT := PowerShell: $(subst /,\,$(VENV_BIN))\Activate.ps1; Git Bash: source $(ACTIVATE_SCRIPT)
PYTHONPATH_SEP := ;
else
ifneq ($(wildcard ../../.venv/bin/python3),)
VENV := ../../.venv
endif
VENV_BIN := $(VENV)/bin
VENV_PYTHON := $(VENV_BIN)/python3
ifdef CI
PYTHON ?= python3
else
PYTHON ?= $(VENV_PYTHON)
endif
BOOTSTRAP_PYTHON ?= python3
ACTIVATE_SCRIPT := $(VENV_BIN)/activate
ACTIVATE_HINT := source $(ACTIVATE_SCRIPT)
PYTHONPATH_SEP := :
endif
# Absolute path to Python (for use after cd into subdirectories).
# In CI, PYTHON is a bare command ('python3') so resolve via PATH;
# locally it is a relative venv path so abspath works.
# When a parent Makefile passes an already-absolute Windows path
# (containing ':'), $(abspath) would mangle it — skip in that case.
ifdef CI
PYTHON_ABS := $(shell command -v $(PYTHON))
else ifneq ($(findstring :,$(PYTHON)),)
PYTHON_ABS := $(PYTHON)
else
PYTHON_ABS := $(abspath $(PYTHON))
endif
# Tooling inside the selected virtual environment
PIP := "$(PYTHON)" -m pip
PRECOMMIT := "$(PYTHON)" -m pre_commit
PYTEST := "$(PYTHON)" -m pytest
# Check if dev environment is set up (skipped in CI)
define check_dev_setup
@if [ -z "$$CI" ] && [ ! -f "$(PYTHON)" ]; then \
echo ""; \
echo "ERROR: Development environment not set up."; \
echo ""; \
echo "Please run first:"; \
echo " make setup"; \
echo ""; \
exit 1; \
fi
@if ! "$(PYTHON)" -c "import linkml, harbour; from importlib.metadata import version; version('credentials'); version('ontology-management-base')" 2>/dev/null; then \
echo ""; \
echo "ERROR: Dev dependencies not installed."; \
echo ""; \
echo "Please run:"; \
echo " make setup"; \
echo ""; \
exit 1; \
fi
endef
EXAMPLES := $(wildcard examples/simpulseid-*.json)
DID_FIXTURES := $(wildcard examples/did-ethr/*.json)
SIMPULSEID_VALIDATE_PATH ?=
GROUPED_COMMANDS := setup install validate lint format test story
PRIMARY_GOAL := $(firstword $(MAKECMDGOALS))
SUBCOMMAND_GOALS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
# Grouped command mode: treat trailing goals as subcommands
ifneq ($(filter $(PRIMARY_GOAL),$(GROUPED_COMMANDS)),)
.PHONY: $(SUBCOMMAND_GOALS)
$(SUBCOMMAND_GOALS):
@:
else
help: ## Show this help
@"$(MAKE)" --no-print-directory _help_general
endif
# Default target
_help_general:
@echo "SimpulseID Credentials - Available Commands"
@echo ""
@echo "Installation:"
@echo " make setup - Create venv, install all dependencies, setup submodules"
@echo " make setup help - Show setup subcommands"
@echo " make install - Install package (user mode)"
@echo " make install help - Show install subcommands"
@echo ""
@echo "Artifacts:"
@echo " make generate - Generate OWL/SHACL/context from LinkML"
@echo " make validate - Run Harbour + SimpulseID validation"
@echo " make validate help - Show validate subcommands"
@echo " make check - Generate + validate"
@echo ""
@echo "Linting:"
@echo " make lint - Run pre-commit checks"
@echo " make lint help - Show lint subcommands"
@echo " make format - Format code with ruff"
@echo " make format help - Show format subcommands"
@echo ""
@echo "Testing:"
@echo " make test - Run all tests"
@echo " make test help - Show test subcommands"
@echo " make story - Run the full Harbour + SimpulseID signing/verification storyline"
@echo " make story help - Show story subcommands"
@echo ""
@echo "Compound:"
@echo " make all - Full end-to-end: setup, lint, check, test"
@echo ""
@echo "Cleaning:"
@echo " make clean - Remove generated artifacts and caches"
_help_setup:
@echo "Setup subcommands:"
@echo " make setup - Create venv, install dependencies, and setup submodules"
@echo " make setup submodules - Setup the Harbour + ontology submodules in the active environment"
_help_install:
@echo "Install subcommands:"
@echo " make install - Install package (user mode)"
@echo " make install dev - Install with dev dependencies + pre-commit"
@echo " make install docs - Install with docs dependencies (MkDocs)"
_help_validate:
@echo "Validate subcommands:"
@echo " make validate - Run Harbour + SimpulseID validation"
@echo " make validate harbour - Run Harbour SHACL validation in the submodule"
@echo " make validate simpulseid - Run top-level SimpulseID SHACL validation"
@echo " make validate simpulseid SIMPULSEID_VALIDATE_PATH=examples/... - Validate one SimpulseID .json/.jsonld file or folder"
_help_lint:
@echo "Lint subcommands:"
@echo " make lint - Run pre-commit checks"
@echo " make lint md - Lint Markdown files with markdownlint-cli2"
_help_format:
@echo "Format subcommands:"
@echo " make format - Format code with ruff"
@echo " make format md - Auto-fix Markdown lint violations"
_help_test:
@echo "Test subcommands:"
@echo " make test - Run all tests"
@echo " make test harbour - Run harbour-credentials tests only"
@echo " make test simpulseid - Run top-level SimpulseID tests only"
@echo " make test cov - Run tests with coverage report"
_help_story:
@echo "Story subcommands:"
@echo " make story - Run the full Harbour + SimpulseID storyline"
@echo " make story harbour - Run the Harbour storyline in the submodule"
@echo " make story simpulseid - Generate, validate, sign, and verify SimpulseID examples"
@echo " make story sign - Write ignored signed SimpulseID artifacts to examples/signed/"
@echo " make story verify - Verify the signed SimpulseID artifacts with the real verifier"
# ---------- Setup ----------
setup: ## Create venv, install deps, setup submodules
@set -- $(filter-out $@,$(MAKECMDGOALS)); \
subcommand="$${1:-default}"; \
if [ "$$#" -gt 1 ]; then \
echo "ERROR: Too many subcommands for 'make setup': $(filter-out $@,$(MAKECMDGOALS))"; \
echo "Run 'make setup help' for available options."; \
exit 1; \
fi; \
case "$$subcommand" in \
default) "$(MAKE)" --no-print-directory _setup_default ;; \
submodules) "$(MAKE)" --no-print-directory _setup_submodules ;; \
help) "$(MAKE)" --no-print-directory _help_setup ;; \
*) echo "ERROR: Unknown setup subcommand '$$subcommand'"; echo "Run 'make setup help' for available options."; exit 1 ;; \
esac
_setup_default:
@echo "Setting up development environment..."
@echo "Checking Python virtual environment and dependencies..."
ifdef CI
@set -e; \
if "$(PYTHON)" -c "import pre_commit, linkml, harbour; from importlib.metadata import version; version('credentials'); version('ontology-management-base')" >/dev/null 2>&1; then \
echo "OK: Python environment and dependencies are ready via $(PYTHON)"; \
else \
echo "CI environment missing dependencies; bootstrapping..."; \
"$(MAKE)" --no-print-directory setup submodules; \
$(PIP) install -e ".[dev]"; \
$(PRECOMMIT) install; \
fi
else
@set -e; \
if [ ! -f "$(PYTHON)" ]; then \
echo "Python virtual environment not found; bootstrapping..."; \
"$(MAKE)" --no-print-directory "$(ACTIVATE_SCRIPT)"; \
elif "$(PYTHON)" -c "import pre_commit, linkml, harbour; from importlib.metadata import version; version('credentials'); version('ontology-management-base')" >/dev/null 2>&1; then \
echo "OK: Python virtual environment and dependencies are ready at $(VENV)"; \
else \
echo "Python virtual environment found but dependencies are missing; bootstrapping..."; \
"$(MAKE)" --no-print-directory -B "$(ACTIVATE_SCRIPT)"; \
fi
endif
@echo ""
@echo "Setup complete. Activate with: $(ACTIVATE_HINT)"
$(VENV_PYTHON):
@echo "Creating Python virtual environment at $(VENV)..."
@"$(BOOTSTRAP_PYTHON)" -m venv "$(VENV)"
@$(PIP) install --upgrade pip
@echo "OK: Python virtual environment ready"
$(ACTIVATE_SCRIPT): $(VENV_PYTHON)
@echo "Installing submodule dependencies..."
@"$(MAKE)" --no-print-directory setup submodules
@echo "Installing Python dependencies..."
@$(PIP) install -e ".[dev]"
@$(PRECOMMIT) install
@echo "OK: Python development environment ready"
# Setup submodules using the same active venv (pip install preferred, make -C fallback)
_setup_submodules:
@echo "Setting up LinkML from OMB submodule (single source of truth)..."
@set -e; \
if [ -f "$(LINKML_SUBMODULE_DIR)/pyproject.toml" ]; then \
$(PIP) install -e "$(LINKML_SUBMODULE_DIR)"; \
echo "OK: LinkML (ASCS-eV fork) installed from submodule"; \
else \
echo "WARNING: LinkML submodule not found at $(LINKML_SUBMODULE_DIR)"; \
fi
@echo "Setting up harbour-credentials submodule..."
@set -e; \
if [ -f "$(HARBOUR_SUBMODULE_DIR)/pyproject.toml" ]; then \
$(PIP) install -e "$(HARBOUR_SUBMODULE_DIR)[dev]"; \
echo "OK: harbour-credentials submodule setup complete"; \
elif [ -f "$(HARBOUR_SUBMODULE_DIR)/Makefile" ]; then \
"$(MAKE)" --no-print-directory -C "$(HARBOUR_SUBMODULE_DIR)" setup \
VENV="$(abspath $(VENV))" \
PYTHON="$(PYTHON_ABS)"; \
echo "OK: harbour-credentials submodule setup complete"; \
else \
echo "WARNING: Skipping harbour-credentials submodule setup (not found)"; \
fi
@echo "Setting up ontology-management-base submodule..."
@set -e; \
if [ -f "$(OMB_SUBMODULE_DIR)/pyproject.toml" ]; then \
$(PIP) install -e "$(OMB_SUBMODULE_DIR)"; \
echo "OK: ontology-management-base submodule setup complete"; \
elif [ -f "$(OMB_SUBMODULE_DIR)/Makefile" ]; then \
"$(MAKE)" --no-print-directory -C "$(OMB_SUBMODULE_DIR)" setup \
VENV="$(abspath $(VENV))" \
PYTHON="$(PYTHON_ABS)"; \
echo "OK: ontology-management-base submodule setup complete"; \
else \
echo "WARNING: Skipping ontology-management-base submodule setup (not found)"; \
fi
# ---------- Install ----------
install:
@set -- $(filter-out $@,$(MAKECMDGOALS)); \
subcommand="$${1:-default}"; \
if [ "$$#" -gt 1 ]; then \
echo "ERROR: Too many subcommands for 'make install': $(filter-out $@,$(MAKECMDGOALS))"; \
echo "Run 'make install help' for available options."; \
exit 1; \
fi; \
case "$$subcommand" in \
default) "$(MAKE)" --no-print-directory _install_default ;; \
dev) "$(MAKE)" --no-print-directory _install_dev ;; \
docs) "$(MAKE)" --no-print-directory _install_docs ;; \
help) "$(MAKE)" --no-print-directory _help_install ;; \
*) echo "ERROR: Unknown install subcommand '$$subcommand'"; echo "Run 'make install help' for available options."; exit 1 ;; \
esac
_install_default: ## Install package (user mode)
@echo "Installing package in editable mode..."
ifndef CI
@"$(MAKE)" --no-print-directory "$(VENV_PYTHON)"
endif
@$(PIP) install -e $(HARBOUR_SUBMODULE_DIR) -e $(OMB_SUBMODULE_DIR) -e .
@echo "OK: Package installation complete"
_install_dev: ## Install with dev dependencies + pre-commit
@echo "Installing development dependencies..."
ifndef CI
@"$(MAKE)" --no-print-directory "$(VENV_PYTHON)"
endif
@$(PIP) install -e "$(LINKML_SUBMODULE_DIR)" -e "$(HARBOUR_SUBMODULE_DIR)[dev]" -e $(OMB_SUBMODULE_DIR) -e ".[dev]"
ifndef CI
@$(PRECOMMIT) install
endif
@echo "OK: Development dependencies installed"
_install_docs: ## Install with docs dependencies (for MkDocs builds)
@echo "Installing documentation dependencies..."
ifndef CI
@"$(MAKE)" --no-print-directory "$(VENV_PYTHON)"
endif
@$(PIP) install -e "$(HARBOUR_SUBMODULE_DIR)[dev]" -e $(OMB_SUBMODULE_DIR) -e ".[docs]"
@echo "OK: Documentation dependencies installed"
# ---------- Lint ----------
lint:
@set -- $(filter-out $@,$(MAKECMDGOALS)); \
subcommand="$${1:-default}"; \
if [ "$$#" -gt 1 ]; then \
echo "ERROR: Too many subcommands for 'make lint': $(filter-out $@,$(MAKECMDGOALS))"; \
echo "Run 'make lint help' for available options."; \
exit 1; \
fi; \
case "$$subcommand" in \
default) "$(MAKE)" --no-print-directory _lint_default ;; \
md) "$(MAKE)" --no-print-directory _lint_md ;; \
help) "$(MAKE)" --no-print-directory _help_lint ;; \
*) echo "ERROR: Unknown lint subcommand '$$subcommand'"; echo "Run 'make lint help' for available options."; exit 1 ;; \
esac
_lint_default: ## Run pre-commit (ruff, JSON-LD parse, Turtle parse, markdownlint)
$(call check_dev_setup)
@$(PRECOMMIT) run --all-files
_lint_md: ## Lint Markdown files with markdownlint-cli2
@echo "Linting Markdown files..."
@npx --yes markdownlint-cli2
@echo "OK: Markdown lint complete"
format:
@set -- $(filter-out $@,$(MAKECMDGOALS)); \
subcommand="$${1:-default}"; \
if [ "$$#" -gt 1 ]; then \
echo "ERROR: Too many subcommands for 'make format': $(filter-out $@,$(MAKECMDGOALS))"; \
echo "Run 'make format help' for available options."; \
exit 1; \
fi; \
case "$$subcommand" in \
default) "$(MAKE)" --no-print-directory _format_default ;; \
md) "$(MAKE)" --no-print-directory _format_md ;; \
help) "$(MAKE)" --no-print-directory _help_format ;; \
*) echo "ERROR: Unknown format subcommand '$$subcommand'"; echo "Run 'make format help' for available options."; exit 1 ;; \
esac
_format_default: ## Format code with ruff
$(call check_dev_setup)
@"$(PYTHON)" -m ruff check --fix src/ tests/
@"$(PYTHON)" -m ruff format src/ tests/
_format_md: ## Auto-fix Markdown lint violations
@echo "Fixing Markdown files..."
@npx --yes markdownlint-cli2 --fix
@echo "OK: Markdown formatting complete"
# ---------- Generate ----------
generate: ## Generate JSON-LD contexts, SHACL shapes, OWL ontologies from LinkML
$(call check_dev_setup)
@echo "Generating harbour artifacts..."
@cd "$(HARBOUR_SUBMODULE_DIR)" && PYTHONPATH="src/python$(PYTHONPATH_SEP)$$PYTHONPATH" "$(PYTHON_ABS)" src/python/harbour/generate_artifacts.py
@echo "Generating simpulseid artifacts..."
@"$(PYTHON)" src/generate_artifacts.py
# ---------- Validate ----------
validate:
@set -- $(filter-out $@,$(MAKECMDGOALS)); \
subcommand="$${1:-default}"; \
if [ "$$#" -gt 1 ]; then \
echo "ERROR: Too many subcommands for 'make validate': $(filter-out $@,$(MAKECMDGOALS))"; \
echo "Run 'make validate help' for available options."; \
exit 1; \
fi; \
case "$$subcommand" in \
default) "$(MAKE)" --no-print-directory _validate_all ;; \
harbour) "$(MAKE)" --no-print-directory _validate_harbour ;; \
simpulseid) "$(MAKE)" --no-print-directory _validate_simpulseid ;; \
help) "$(MAKE)" --no-print-directory _help_validate ;; \
*) echo "ERROR: Unknown validate subcommand '$$subcommand'"; echo "Run 'make validate help' for available options."; exit 1 ;; \
esac
_validate_simpulseid: ## SHACL-validate SimpulseID examples and DID fixtures
$(call check_dev_setup)
@if [ -n "$(SIMPULSEID_VALIDATE_PATH)" ]; then \
echo "Running SHACL data conformance check on $(SIMPULSEID_VALIDATE_PATH)..." ; \
cd "$(OMB_SUBMODULE_DIR)" && \
target_path="$(REPO_ROOT)/$(SIMPULSEID_VALIDATE_PATH)" ; \
if [ -d "$$target_path" ]; then \
json_count=$$(find "$$target_path" -maxdepth 1 -type f \( -name '*.json' -o -name '*.jsonld' \) | wc -l) ; \
if [ "$$json_count" -eq 0 ]; then \
echo "ERROR: No .json or .jsonld files found under $$target_path" ; \
exit 1 ; \
fi ; \
elif [ -f "$$target_path" ]; then \
case "$$target_path" in \
*.json|*.jsonld) ;; \
*) echo "ERROR: SimpulseID SHACL validation only supports .json/.jsonld files or directories: $$target_path" ; exit 1 ;; \
esac ; \
else \
echo "ERROR: Validation path not found: $$target_path" ; \
exit 1 ; \
fi ; \
"$(PYTHON_ABS)" -m src.tools.validators.validation_suite \
--run check-data-conformance \
--data-paths "$$target_path" \
--artifacts $(REPO_ROOT)/artifacts $(REPO_ROOT)/$(HARBOUR_SUBMODULE_DIR)/artifacts ; \
else \
if [ -n "$(EXAMPLES)" ]; then \
echo "Running SHACL data conformance check on credential examples..." ; \
cd "$(REPO_ROOT)/$(OMB_SUBMODULE_DIR)" && \
"$(PYTHON_ABS)" -m src.tools.validators.validation_suite \
--run check-data-conformance \
--data-paths $(addprefix $(REPO_ROOT)/,$(EXAMPLES)) \
--artifacts $(REPO_ROOT)/artifacts $(REPO_ROOT)/$(HARBOUR_SUBMODULE_DIR)/artifacts ; \
fi ; \
if [ -n "$(DID_FIXTURES)" ]; then \
echo "Running SHACL data conformance check on DID fixtures..." ; \
cd "$(REPO_ROOT)/$(OMB_SUBMODULE_DIR)" && \
"$(PYTHON_ABS)" -m src.tools.validators.validation_suite \
--run check-data-conformance \
--data-paths $(addprefix $(REPO_ROOT)/,$(DID_FIXTURES)) \
--artifacts $(REPO_ROOT)/artifacts $(REPO_ROOT)/$(HARBOUR_SUBMODULE_DIR)/artifacts ; \
fi ; \
fi
_validate_harbour: ## Run Harbour SHACL validation inside the submodule
@echo "Running Harbour validation from root..."
@"$(MAKE)" --no-print-directory -C "$(HARBOUR_SUBMODULE_DIR)" \
validate shacl \
VENV="$(abspath $(VENV))" \
PYTHON="$(PYTHON_ABS)"
@echo "OK: Harbour validation complete"
_validate_all: ## Run Harbour + SimpulseID validation
@echo "Running full repository validation..."
@"$(MAKE)" --no-print-directory _validate_harbour
@"$(MAKE)" --no-print-directory _validate_simpulseid
@echo "OK: Full repository validation complete"
# ---------- Test ----------
test:
@set -- $(filter-out $@,$(MAKECMDGOALS)); \
subcommand="$${1:-default}"; \
if [ "$$#" -gt 1 ]; then \
echo "ERROR: Too many subcommands for 'make test': $(filter-out $@,$(MAKECMDGOALS))"; \
echo "Run 'make test help' for available options."; \
exit 1; \
fi; \
case "$$subcommand" in \
default) "$(MAKE)" --no-print-directory _test_all ;; \
harbour) "$(MAKE)" --no-print-directory _test_harbour ;; \
simpulseid) "$(MAKE)" --no-print-directory _test_simpulseid ;; \
cov) "$(MAKE)" --no-print-directory _test_cov ;; \
help) "$(MAKE)" --no-print-directory _help_test ;; \
*) echo "ERROR: Unknown test subcommand '$$subcommand'"; echo "Run 'make test help' for available options."; exit 1 ;; \
esac
_test_harbour: ## Run harbour-credentials JOSE tests (excludes interop — covered by harbour CI)
@cd "$(HARBOUR_SUBMODULE_DIR)" && PYTHONPATH="src/python$(PYTHONPATH_SEP)$$PYTHONPATH" "$(PYTHON_ABS)" -m pytest tests/ -v --ignore=tests/interop
_test_simpulseid:
$(call check_dev_setup)
@PYTHONPATH="$(HARBOUR_SUBMODULE_DIR)/src/python$(PYTHONPATH_SEP)$$PYTHONPATH" $(PYTEST) tests/ -v
_test_all: ## Run all tests (harbour + main repo)
@"$(MAKE)" --no-print-directory generate
@"$(MAKE)" --no-print-directory _test_harbour
@"$(MAKE)" --no-print-directory _test_simpulseid
_test_cov: ## Run tests with coverage report
$(call check_dev_setup)
@PYTHONPATH="$(HARBOUR_SUBMODULE_DIR)/src/python$(PYTHONPATH_SEP)$$PYTHONPATH" $(PYTEST) tests/ --cov=src --cov-report=html --cov-report=term
story:
@set -- $(filter-out $@,$(MAKECMDGOALS)); \
subcommand="$${1:-default}"; \
if [ "$$#" -gt 1 ]; then \
echo "ERROR: Too many subcommands for 'make story': $(filter-out $@,$(MAKECMDGOALS))"; \
echo "Run 'make story help' for available options."; \
exit 1; \
fi; \
case "$$subcommand" in \
default) "$(MAKE)" --no-print-directory _story_all ;; \
simpulseid) "$(MAKE)" --no-print-directory _story_simpulseid ;; \
harbour) "$(MAKE)" --no-print-directory _story_harbour ;; \
sign) "$(MAKE)" --no-print-directory _story_sign ;; \
verify) "$(MAKE)" --no-print-directory _story_verify ;; \
help) "$(MAKE)" --no-print-directory _help_story ;; \
*) echo "ERROR: Unknown story subcommand '$$subcommand'"; echo "Run 'make story help' for available options."; exit 1 ;; \
esac
_story_sign: ## Sign SimpulseID examples into ignored examples/signed/
$(call check_dev_setup)
@echo "Signing SimpulseID example storylines..."
@rm -rf examples/signed
@"$(PYTHON)" src/sign_examples.py
@echo "OK: Signed example artifacts written to examples/signed/"
_story_verify: ## Verify signed SimpulseID example artifacts
$(call check_dev_setup)
@echo "Verifying SimpulseID signed example storylines..."
@PYTHONPATH="$(HARBOUR_SUBMODULE_DIR)/src/python$(PYTHONPATH_SEP)$$PYTHONPATH" "$(PYTHON)" src/verify_signed_examples.py
@echo "OK: Signed SimpulseID example artifacts verified"
_story_simpulseid: ## Generate, validate, sign, and verify SimpulseID storyline artifacts
@echo "Running SimpulseID storyline..."
@"$(MAKE)" --no-print-directory generate
@"$(MAKE)" --no-print-directory validate simpulseid
@"$(MAKE)" --no-print-directory _story_sign
@"$(MAKE)" --no-print-directory _story_verify
@echo "OK: SimpulseID storyline complete"
_story_harbour: ## Run the Harbour storyline inside the submodule
@echo "Running Harbour storyline from root..."
@"$(MAKE)" --no-print-directory -C "$(HARBOUR_SUBMODULE_DIR)" \
story \
VENV="$(abspath $(VENV))" \
PYTHON="$(PYTHON_ABS)"
@echo "OK: Harbour storyline complete"
_story_all: ## Run the full Harbour + SimpulseID storyline
@echo "Running full repository storyline..."
@"$(MAKE)" --no-print-directory generate
@"$(MAKE)" --no-print-directory _story_harbour
@"$(MAKE)" --no-print-directory _validate_simpulseid
@"$(MAKE)" --no-print-directory _story_sign
@"$(MAKE)" --no-print-directory _story_verify
@echo "OK: Full repository storyline complete"
# ---------- Release Artifacts ----------
RELEASE_DIR ?= site/w3id/ascs-ev/simpulse-id
release-artifacts: ## Copy SimpulseID artifacts to w3id directory structure for GitHub Pages publishing
@echo "Preparing w3id artifact structure..."
@mkdir -p "$(RELEASE_DIR)/v1"
@cp artifacts/simpulseid-core/simpulseid-core.owl.ttl "$(RELEASE_DIR)/v1/ontology.ttl"
@cp artifacts/simpulseid-core/simpulseid-core.shacl.ttl "$(RELEASE_DIR)/v1/shapes.ttl"
@cp artifacts/simpulseid-core/simpulseid-core.context.jsonld "$(RELEASE_DIR)/v1/context.jsonld"
@echo "OK: Artifacts prepared in $(RELEASE_DIR)/"
# ---------- Compound targets ----------
check: generate validate ## Generate artifacts then validate examples
all: setup lint check test ## Full end-to-end: setup, lint, generate, validate, test
# ---------- Clean ----------
clean: ## Remove generated artifacts (keeps venv)
@echo "Cleaning generated files and caches..."
@rm -rf artifacts/simpulseid-core
@rm -rf build/ dist/ *.egg-info/
@rm -rf .pytest_cache/ htmlcov .coverage
@find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
@find . -type f -name "*.pyc" -delete 2>/dev/null || true
@echo "OK: Cleaned"