/
Makefile
96 lines (77 loc) · 2.98 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
88
89
90
91
92
93
94
95
96
# Determine this makefile's path.
# Be sure to place this BEFORE `include` directives, if any.
THIS_FILE := $(lastword $(MAKEFILE_LIST))
CURRENT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
############################
# Make targets for dsp-tools
############################
.PHONY: dsp-stack
dsp-stack: ## clone the dsp-api git repository and run the dsp-stack
@mkdir -p .tmp
@git clone --branch main --single-branch --depth 1 https://github.com/dasch-swiss/dsp-api.git .tmp/dsp-stack
$(MAKE) -C .tmp/dsp-stack env-file
$(MAKE) -C .tmp/dsp-stack init-db-test
$(MAKE) -C .tmp/dsp-stack stack-up
$(MAKE) -C .tmp/dsp-stack stack-logs-api-no-follow
.PHONY: stack-down
stack-down: ## stop dsp-stack and remove the cloned dsp-api repository
$(MAKE) -C .tmp/dsp-stack stack-down-delete-volumes
@test -x .tmp && rm -rf .tmp
.PHONY: dist
dist: ## generate distribution package
python3 setup.py sdist bdist_wheel
.PHONY: upload
upload: ## upload distribution package to PyPI
python3 -m twine upload dist/*
.PHONY: docs-build
docs-build: ## build docs into the local 'site' folder
mkdocs build
.PHONY: docs-serve
docs-serve: ## serve docs for local viewing
mkdocs serve --dev-addr=0.0.0.0:7979
.PHONY: install-requirements
install-requirements: ## install requirements
python3 -m pip install --upgrade pip
pip3 install -r requirements.txt
pip3 install -r docs/requirements.txt
pip3 install -r dev-requirements.txt
.PHONY: install
install: ## install from source (runs setup.py)
python3 -m pip install --upgrade pip
pip3 install -e .
.PHONY: test
test: dsp-stack ## run all tests
pytest test/
$(MAKE) stack-down
.PHONY: test-no-stack
test-no-stack: ## run tests without starting the stack (if a dsp-stack is already running)
pytest test/
.PHONY: test-end-to-end
test-end-to-end: dsp-stack ## run e2e tests
pytest test/e2e/
$(MAKE) stack-down
.PHONY: test-end-to-end-ci
test-end-to-end-ci: dsp-stack ## run e2e tests on GitHub CI, where it isn't possible nor necessary to remove .tmp
pytest test/e2e/
.PHONY: test-end-to-end-no-stack
test-end-to-end-no-stack: ## run e2e tests without starting the dsp-stack (if a dsp-stack is already running)
pytest test/e2e/
.PHONY: test-unittests
test-unittests: ## run unit tests
pytest test/unittests/
.PHONY: clean
clean: ## clean local project directories
@rm -rf dist/ build/ site/ dsp_tools.egg-info/
.PHONY: help
help: ## show this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort
.PHONY: freeze-requirements
freeze-requirements: ## update (dev-)requirements.txt and setup.py based on pipenv's Pipfile.lock
pipenv run pipenv requirements > requirements.txt
sed -i '' 's/==/~=/g' requirements.txt
pipenv run pipenv requirements --dev-only > dev-requirements.txt
sed -i '' 's/==/~=/g' dev-requirements.txt
pipenv run pipenv-setup sync
sed -i '' 's/==/~=/g' setup.py
autopep8 --global-config pyproject.toml --aggressive --in-place setup.py
.DEFAULT_GOAL := help