forked from cookiecutter/cookiecutter-django
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
108 lines (78 loc) · 3.39 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
# -----------------------------------------------------------------------------
# Generate help output when running just `make`
# -----------------------------------------------------------------------------
.DEFAULT_GOAL := help
define PRINT_HELP_PYSCRIPT
import re, sys
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print("%-20s %s" % (target, help))
endef
export PRINT_HELP_PYSCRIPT
help:
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
# -----------------------------------------------------------------------------
# Variables
# -----------------------------------------------------------------------------
venv=.venv
BAKE_OPTIONS=--no-input
# -----------------------------------------------------------------------------
# Environment
# -----------------------------------------------------------------------------
env: ## Install virtualenv for development (uses `pyenv`)
python3 -m venv ${venv}
@echo "Virtual environment created. Activate with: source ${venv}/bin/activate"
@echo "Install dependencies with: pip install ."
env_remove: ## Remove virtual environment
deactivate
rm -rf ${venv}
env_from_scratch: env_remove env ## Create environment from scratch
# -----------------------------------------------------------------------------
# Pip
# -----------------------------------------------------------------------------
pip_install: ## Install requirements
python3 -m pip install -U pip
python3 -m pip install .
# -----------------------------------------------------------------------------
# Cookiecutter
# -----------------------------------------------------------------------------
bake: ## Generate project using defaults
cookiecutter $(BAKE_OPTIONS) . --overwrite-if-exists
watch: bake ## Generate project using defaults and watch for changes
watchmedo shell-command -p '*.*' -c 'make bake -e BAKE_OPTIONS=$(BAKE_OPTIONS)' -W -R -D \{{cookiecutter.package_name}}/
replay: BAKE_OPTIONS=--replay # Replay last cookiecutter run and watch for changes
replay: watch
;
eat: ## Remove generated project
rm -rf my_awesome_project
# -----------------------------------------------------------------------------
# Git
# -----------------------------------------------------------------------------
fetch_upstream: ## Fetch upstream changes
git fetch upstream
preview_upstream: ## Preview changes from upstream
git difftool master upstream/master -y
merge_upstream: ## Merge upstream changes into master
git fetch upstream
git checkout master
git merge upstream/master
# -----------------------------------------------------------------------------
# Testing
# -----------------------------------------------------------------------------
pytest: ## Run tests
pytest -vx tests
pytest_generation: ## Run tests for cookiecutter generation
pytest -vx tests/test_cookiecutter_generation.py
# pytest_verbose: ## Run tests in verbose mode
# pytest -vvs
# coverage: ## Run tests with coverage
# coverage run -m pytest && coverage html
# coverage_verbose: ## Run tests with coverage in verbose mode
# coverage run -m pytest -vss && coverage html
# coverage_skip: ## Run tests with coverage and skip covered
# coverage run -m pytest -vs && coverage html --skip-covered
# open_coverage: ## Open coverage report
# open htmlcov/index.html
# -----------------------------------------------------------------------------