-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
119 lines (92 loc) · 3.29 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#
# CONVENTIONS:
#
# - targets shall be ordered such that help list rensembles a typical workflow, e.g. 'make devenv tests'
# - add doc to relevant targets
# - internal targets shall start with '.'
# - KISS
#
.DEFAULT_GOAL := help
SHELL := /bin/bash
SIMCORE_DIR := $(CURDIR)/.output/osparc-simcore
OUTPUT_DIR := $(SIMCORE_DIR)/services
TEMPLATE := $(CURDIR)
#-----------------------------------
.PHONY: devenv
.venv:
python3 -m venv $@
# upgrading package managers
$@/bin/pip3 install --upgrade \
pip \
wheel \
setuptools
devenv: .venv requirements.txt ## create a python virtual environment with tools to dev, run and tests cookie-cutter
# installing extra tools
@$</bin/pip3 install -r $(word 2,$^)
# your dev environment contains
@$</bin/pip3 list
@echo "To activate the virtual environment, run 'source $</bin/activate'"
.PHONY: tests
tests: ## tests backed cookie
@pytest -vv \
--exitfirst \
--failed-first \
--durations=0 \
--pdb \
$(CURDIR)/tests
#-----------------------------------
.PHONY: play
.PHONY: simcore-update
simcore-update:
mkdir -p $(SIMCORE_DIR)
# cloning/udpating simcore
python3 -c "import tests.utils as tu; tu.download_latest_simcore_at('$(SIMCORE_DIR)')"
$(OUTPUT_DIR): simcore-update
define cookiecutterrc =
$(shell find $(OUTPUT_DIR) -name ".cookiecutterrc" 2>/dev/null | tail -n 1 )
endef
play: _check_venv_active ## runs cookiecutter into output folder
ifeq (,$(cookiecutterrc))
# baking cookie $(TEMPLATE) onto $<
@cookiecutter --output-dir "$(OUTPUT_DIR)" "$(TEMPLATE)"
else
# replaying cookie-cutter using $(cookiecutterrc)
@cookiecutter --no-input -f \
--config-file="$(cookiecutterrc)" \
--output-dir="$(OUTPUT_DIR)" "$(TEMPLATE)"
endif
@echo "To see generated code, lauch 'code $(wildcard $(OUTPUT_DIR)/*)'"
.PHONY: version-patch version-minor version-major
define _bumpversion
# upgrades as $(subst version-,,$@) version, commits and tags
@bump2version --verbose --list $(subst version-,,$@)
endef
version-patch: ## commits version with bug fixes not affecting the cookiecuter config
$(_bumpversion)
version-minor: ## commits version with backwards-compatible API addition or changes (i.e. can replay)
$(_bumpversion)
version-major: ## commits version with backwards-INcompatible addition or changes
$(_bumpversion)
#-----------------------------------
.PHONY: help
# thanks to https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help: ## this colorful help
@echo "Recipes for '$(notdir $(CURDIR))':"
@echo ""
@awk --posix 'BEGIN {FS = ":.*?## "} /^[[:alpha:][:space:]_-]+:.*?## / {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
.PHONY: clean clean-all
git_clean_args = -dxf -e .vscode/ -e *ignore* -e .venv
clean: ## cleans all unversioned files in project and temp files create by this makefile
# Cleaning unversioned
@git clean -n $(git_clean_args)
@echo -n "Are you sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@echo -n "$(shell whoami), are you REALLY sure? [y/N] " && read ans && [ $${ans:-N} = y ]
@git clean $(git_clean_args)
clean-all: clean ## hard clean including virtual environment
# removing .venv
-@rm -rf .venv
.PHONY: _check_venv_active
_check_venv_active:
# checking whether virtual environment was activated
@python3 -c "import sys; assert sys.base_prefix!=sys.prefix"