mirror of
https://github.com/p2p-ld/linkml-activitypub.git
synced 2024-12-04 20:44:28 +00:00
190 lines
4.9 KiB
Makefile
190 lines
4.9 KiB
Makefile
MAKEFLAGS += --warn-undefined-variables
|
|
SHELL := bash
|
|
.SHELLFLAGS := -eu -o pipefail -c
|
|
.DEFAULT_GOAL := help
|
|
.DELETE_ON_ERROR:
|
|
.SUFFIXES:
|
|
.SECONDARY:
|
|
|
|
RUN = poetry run
|
|
# get values from about.yaml file
|
|
SCHEMA_NAME = "linkml_activitypub"
|
|
SOURCE_SCHEMA_PATH = "linkml_activitypub/activitypub.yaml"
|
|
AS_SCHEMA_PATH = "linkml_activitypub/activitystreams.yaml"
|
|
AP_SCHEMA_PATH = "linkml_activitypub/activitypub.yaml"
|
|
|
|
SOURCE_SCHEMA_DIR = $(dir $(SOURCE_SCHEMA_PATH))
|
|
SCHEMA_FILES := $(wildcard $(SOURCE_SCHEMA_DIR))
|
|
SRC = src
|
|
DEST = generated
|
|
PYMODEL = $(SCHEMA_NAME)
|
|
DOCDIR = docs
|
|
EXAMPLEDIR = examples
|
|
|
|
GEN_PARGS =
|
|
ifdef LINKML_GENERATORS_PROJECT_ARGS
|
|
GEN_PARGS = ${LINKML_GENERATORS_PROJECT_ARGS}
|
|
endif
|
|
|
|
GEN_DARGS =
|
|
ifdef LINKML_GENERATORS_MARKDOWN_ARGS
|
|
GEN_DARGS = ${LINKML_GENERATORS_MARKDOWN_ARGS}
|
|
endif
|
|
|
|
|
|
# basename of a YAML file in model/
|
|
.PHONY: all clean setup gen-project gen-examples gendoc git-init-add git-init git-add git-commit git-status
|
|
|
|
# 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 setup -- initial setup (run this first)"
|
|
@echo "make site -- makes site locally"
|
|
@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 deploy -- deploys site"
|
|
@echo "make update -- updates linkml version"
|
|
@echo "make help -- show this help"
|
|
@echo ""
|
|
|
|
status: check-config
|
|
@echo "Project: $(SCHEMA_NAME)"
|
|
@echo "Source: $(SOURCE_SCHEMA_PATH)"
|
|
|
|
# generate products and add everything to github
|
|
setup: git-init install gen-project gen-examples gendoc git-add git-commit
|
|
|
|
# install any dependencies required for building
|
|
install:
|
|
poetry install
|
|
.PHONY: install
|
|
|
|
# ---
|
|
# Project Synchronization
|
|
# ---
|
|
#
|
|
# check we are up to date
|
|
check: cruft-check
|
|
cruft-check:
|
|
cruft check
|
|
cruft-diff:
|
|
cruft diff
|
|
|
|
update: update-template update-linkml
|
|
update-template:
|
|
cruft update
|
|
|
|
# todo: consider pinning to template
|
|
update-linkml:
|
|
poetry add -D linkml@latest
|
|
|
|
# EXPERIMENTAL
|
|
create-data-harmonizer:
|
|
npm init data-harmonizer $(SOURCE_SCHEMA_PATH)
|
|
|
|
all: site
|
|
site: gen-project gendoc
|
|
%.yaml: gen-project
|
|
deploy: all mkd-gh-deploy
|
|
|
|
compile-sheets:
|
|
$(RUN) sheets2linkml --gsheet-id $(SHEET_ID) $(SHEET_TABS) > $(SHEET_MODULE_PATH).tmp && mv $(SHEET_MODULE_PATH).tmp $(SHEET_MODULE_PATH)
|
|
|
|
# In future this will be done by conversion
|
|
gen-examples:
|
|
cp src/data/examples/* $(EXAMPLEDIR)
|
|
|
|
# generates all project files
|
|
|
|
gen-project: $(PYMODEL)
|
|
$(RUN) gen-project ${GEN_PARGS} -d $(DEST) $(AS_SCHEMA_PATH)
|
|
$(RUN) gen-project ${GEN_PARGS} -d $(DEST) $(AP_SCHEMA_PATH)
|
|
mv $(DEST)/*.py "${PYMODEL}/dataclass/"
|
|
|
|
gen-pydantic: $(PYMODEL)
|
|
$(RUN) gen-pydantic $(AS_SCHEMA_PATH) --pydantic-version 2 > $(PYMODEL)/activitystreams.py
|
|
$(RUN) gen-pydantic $(AP_SCHEMA_PATH) --pydantic-version 2 > $(PYMODEL)/activitypub.py
|
|
|
|
test: test-schema test-python test-examples
|
|
|
|
test-schema:
|
|
$(RUN) gen-project ${GEN_PARGS} -d tmp $(SOURCE_SCHEMA_PATH)
|
|
|
|
test-python:
|
|
$(RUN) python -m unittest discover
|
|
|
|
lint:
|
|
$(RUN) linkml-lint $(SOURCE_SCHEMA_PATH)
|
|
|
|
check-config:
|
|
@(grep my-datamodel about.yaml > /dev/null && printf "\n**Project not configured**:\n\n - Remember to edit 'about.yaml'\n\n" || exit 0)
|
|
|
|
convert-examples-to-%:
|
|
$(patsubst %, $(RUN) linkml-convert % -s $(SOURCE_SCHEMA_PATH) -C Person, $(shell ${SHELL} find src/data/examples -name "*.yaml"))
|
|
|
|
examples/%.yaml: src/data/examples/%.yaml
|
|
$(RUN) linkml-convert -s $(SOURCE_SCHEMA_PATH) -C Person $< -o $@
|
|
examples/%.json: src/data/examples/%.yaml
|
|
$(RUN) linkml-convert -s $(SOURCE_SCHEMA_PATH) -C Person $< -o $@
|
|
examples/%.ttl: src/data/examples/%.yaml
|
|
$(RUN) linkml-convert -P EXAMPLE=http://example.org/ -s $(SOURCE_SCHEMA_PATH) -C Person $< -o $@
|
|
|
|
test-examples: examples/output
|
|
|
|
examples/output: src/linkml_activitypub
|
|
mkdir -p $@
|
|
$(RUN) linkml-run-examples \
|
|
--output-formats json \
|
|
--output-formats yaml \
|
|
--counter-example-input-directory src/data/examples/invalid \
|
|
--input-directory src/data/examples/valid \
|
|
--output-directory $@ \
|
|
--schema $< > $@/README.md
|
|
|
|
# Test documentation locally
|
|
serve: mkd-serve
|
|
|
|
# Python datamodel
|
|
$(PYMODEL):
|
|
mkdir -p $@
|
|
|
|
|
|
$(DOCDIR):
|
|
mkdir -p $@
|
|
|
|
gendoc: $(DOCDIR)
|
|
cp $(SRC)/docs/*md $(DOCDIR) ; \
|
|
$(RUN) gen-doc ${GEN_DARGS} -d $(DOCDIR) $(SOURCE_SCHEMA_PATH)
|
|
|
|
testdoc: gendoc serve
|
|
|
|
MKDOCS = $(RUN) mkdocs
|
|
mkd-%:
|
|
$(MKDOCS) $*
|
|
|
|
PROJECT_FOLDERS = sqlschema shex shacl protobuf prefixmap owl jsonschema jsonld graphql excel
|
|
git-init-add: git-init git-add git-commit git-status
|
|
git-init:
|
|
git init
|
|
git-add: .cruft.json
|
|
git add .
|
|
git-commit:
|
|
git commit -m 'chore: initial commit' -a
|
|
git-status:
|
|
git status
|
|
|
|
# only necessary if setting up via cookiecutter
|
|
.cruft.json:
|
|
echo "creating a stub for .cruft.json. IMPORTANT: setup via cruft not cookiecutter recommended!" ; \
|
|
touch $@
|
|
|
|
clean:
|
|
rm -rf $(DEST)
|
|
rm -rf tmp
|
|
rm -fr docs/*
|
|
rm -fr $(PYMODEL)/*
|
|
|
|
#include project.Makefile
|