-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
141 lines (115 loc) · 3.96 KB
/
Makefile
File metadata and controls
141 lines (115 loc) · 3.96 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
MAKEFLAGS += --warn-undefined-variables
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.DEFAULT_GOAL := help
.DELETE_ON_ERROR:
.SUFFIXES:
.SECONDARY:
# environment variables
.EXPORT_ALL_VARIABLES:
ifdef LINKML_ENVIRONMENT_FILENAME
include ${LINKML_ENVIRONMENT_FILENAME}
else
include config.public.mk
endif
RUN = uv run
SCHEMA_NAME = $(LINKML_SCHEMA_NAME)
SOURCE_SCHEMA_PATH = $(LINKML_SCHEMA_SOURCE_PATH)
SOURCE_SCHEMA_DIR = $(dir $(SOURCE_SCHEMA_PATH))
SRC = src
DEST = project
PYMODEL = $(SRC)/$(SCHEMA_NAME)/datamodel
DOCDIR = docs
DOCTEMPLATES = $(SRC)/docs/doc-templates
# Use += to append variables from the variables file
CONFIG_YAML =
ifdef LINKML_GENERATORS_CONFIG_YAML
CONFIG_YAML += "--config-file"
CONFIG_YAML += ${LINKML_GENERATORS_CONFIG_YAML}
endif
GEN_DOC_ARGS =
ifdef LINKML_GENERATORS_DOC_ARGS
GEN_DOC_ARGS += ${LINKML_GENERATORS_DOC_ARGS}
endif
# basename of a YAML file in model/
.PHONY: all clean setup gen-project gendoc new-rig validate-rigs
# note: "help" MUST be the first target in the file,
# when the user types "make" they should get help info
help: status
@echo ""
@echo "make install -- install dependencies"
@echo "make test -- runs tests"
@echo "make lint -- perform linting"
@echo "make testdoc -- builds docs and runs local test server"
@echo "make new-rig -- create a new RIG from template (requires INFORES and NAME)"
@echo "make validate-rigs -- validate all RIG files against the schema"
@echo "make help -- show this help"
@echo ""
# install any dependencies required for building
install:
uv sync --extra dev
.PHONY: install
all: site
site: gen-project gendoc
%.yaml: gen-project
deploy: all mkd-gh-deploy
# generates all project files
gen-project: $(PYMODEL)
$(RUN) gen-project ${CONFIG_YAML} -d $(DEST) $(SOURCE_SCHEMA_PATH) && mv $(DEST)/*.py $(PYMODEL)
test: test-schema test-python validate-rigs gendoc
test-schema:
$(RUN) gen-project ${CONFIG_YAML} -d tmp $(SOURCE_SCHEMA_PATH)
test-python:
$(RUN) python -m pytest
lint:
$(RUN) linkml-lint $(SOURCE_SCHEMA_PATH)
# Test documentation locally
serve: mkd-serve
# Python datamodel
$(PYMODEL):
mkdir -p $@
$(DOCDIR):
mkdir -p $@
gendoc: $(DOCDIR)
cp $(SOURCE_SCHEMA_PATH) $(DOCDIR) ; \
cp $(SRC)/docs/files/*.md $(DOCDIR) ; \
if ls $(SRC)/docs/files/*.yaml 1> /dev/null 2>&1; then cp $(SRC)/docs/files/*.yaml $(DOCDIR); fi ; \
cp -r $(SRC)/docs/images $(DOCDIR)/images ; \
$(RUN) python $(SRC)/scripts/rig_to_markdown.py --input-dir $(SRC)/docs/rigs --output-dir $(DOCDIR) ; \
$(RUN) python $(SRC)/scripts/generate_rig_index.py --rig-dir $(SRC)/docs/rigs --template-dir $(DOCTEMPLATES) --input-file $(SRC)/docs/files/rig_index.md --output-file $(DOCDIR)/rig_index.md ; \
if ls $(SRC)/docs/rigs/*.yaml 1> /dev/null 2>&1; then cp $(SRC)/docs/rigs/*.yaml $(DOCDIR)/; fi ; \
$(RUN) gen-doc ${GEN_DOC_ARGS} -d $(DOCDIR) --template-directory $(DOCTEMPLATES) $(SOURCE_SCHEMA_PATH)
testdoc: gendoc serve
MKDOCS = $(RUN) mkdocs
mkd-%:
$(MKDOCS) $*
# only necessary if setting up via cookiecutter
.cruft.json:
echo "creating a stub for .cruft.json. IMPORTANT: setup via cruft not cookiecutter recommended!" ; \
touch $@
# Create a new RIG from template
# Usage: make new-rig INFORES=infores:ctd NAME="CTD Chemical-Disease Associations"
new-rig:
ifndef INFORES
$(error INFORES is required. Usage: make new-rig INFORES=infores:example NAME="Example RIG")
endif
ifndef NAME
$(error NAME is required. Usage: make new-rig INFORES=infores:example NAME="Example RIG")
endif
$(RUN) python $(SRC)/scripts/create_rig.py --infores "$(INFORES)" --name "$(NAME)"
# Validate all RIG files against the schema
validate-rigs:
@echo "Validating RIG files against schema..."
@for rig_file in $(SRC)/docs/rigs/*.yaml; do \
if [ -f "$$rig_file" ]; then \
echo "Validating $$rig_file"; \
$(RUN) linkml-validate --schema $(SOURCE_SCHEMA_PATH) "$$rig_file"; \
fi; \
done
@echo "✓ All RIG files validated successfully"
clean:
rm -rf $(DEST)
rm -rf tmp
rm -fr $(DOCDIR)/*
rm -fr $(PYMODEL)/*
include project.Makefile