-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
87 lines (66 loc) · 2.54 KB
/
Makefile
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
# Project constants
PROJECT = rororo
DOCS_DIR = docs
EXAMPLES_DIR = examples
TESTS_DIR = tests
# Setup PYTHONPATH to have all examples
EXAMPLES_SRC_DIRS = $(addsuffix src, $(wildcard $(EXAMPLES_DIR)/*/))
PYTHONPATH = $(shell echo "$(EXAMPLES_SRC_DIRS)" | tr ' ' ':')
# Project vars
PIP_COMPILE ?= pip-compile
TOX ?= tox
# Docs vars
DOCS_HOST ?= localhost
DOCS_PORT ?= 8240
include python.mk
all: install
.PHONY: clean
clean: clean-python
.PHONY: distclean
distclean: clean distclean-python
.PHONY: docs
docs: install $(DOCS_DIR)/requirements.txt $(DOCS_DIR)/requirements-sphinx.txt
$(PYTHON_BIN) -m pip install -r $(DOCS_DIR)/requirements-sphinx.txt
$(PYTHON_BIN) -m sphinx_autobuild --host $(DOCS_HOST) --port $(DOCS_PORT) -b html $(DOCS_DIR)/ $(DOCS_DIR)/_build/
$(DOCS_DIR)/requirements.txt: poetry.lock
$(POETRY) export -f requirements.txt -o $(DOCS_DIR)/requirements.txt --without-hashes
$(DOCS_DIR)/requirements-sphinx.txt: $(DOCS_DIR)/requirements-sphinx.in
$(PIP_COMPILE) -Ur --allow-unsafe $(DOCS_DIR)/requirements-sphinx.in
.PHONY: install
install: install-python
.PHONY: lint
lint: lint-python
.PHONY: lint-and-test
lint-and-test: lint test
.PHONY: lint-only
lint-only: lint-python-only
.PHONY: list-outdated
list-outdated: list-outdated-python
.PHONY: run-example
run-example: install
ifeq ($(EXAMPLE),)
@echo "USAGE: make $@ EXAMPLE=(hobotnica|petstore|simulations|todobackend)"
@exit 1
else
PYTHONPATH=examples/$(EXAMPLE)/src/ $(PYTHON_BIN) -m aiohttp.web $(EXAMPLE).app:create_app
endif
.PHONY: run-example-%
run-example-%: install
@$(MAKE) run-example EXAMPLE=$(subst run-example-,,$@)
.PHONY: test
test: install clean validate test-only
.PHONY: test-only
test-only:
PYTHONPATH=$(PYTHONPATH) TOXENV=$(TOXENV) LEVEL=test $(TOX) $(TOX_ARGS) -- $(TEST_ARGS)
.PHONY: test-%
test-%: install clean
PYTHONPATH=$(PYTHONPATH) TOXENV=$(subst test-,,$@) LEVEL=test $(TOX) $(TOX_ARGS) -- $(TEST_ARGS)
.PHONY: validate
validate: install
$(PYTHON_BIN) -m openapi_spec_validator $(EXAMPLES_DIR)/hobotnica/src/hobotnica/openapi.yaml
$(PYTHON_BIN) -m openapi_spec_validator $(EXAMPLES_DIR)/petstore/src/petstore/petstore-expanded.yaml
$(PYTHON_BIN) -m openapi_spec_validator $(EXAMPLES_DIR)/simulations/src/simulations/openapi.yaml
$(PYTHON_BIN) -m openapi_spec_validator $(EXAMPLES_DIR)/todobackend/src/todobackend/openapi.yaml
$(PYTHON_BIN) -m openapi_spec_validator $(EXAMPLES_DIR)/vc-api/src/vc_api/vc-api.yaml
$(PYTHON_BIN) -m openapi_spec_validator $(TESTS_DIR)/$(PROJECT)/openapi.json
$(PYTHON_BIN) -m openapi_spec_validator $(TESTS_DIR)/$(PROJECT)/openapi.yaml