generated from rochacbruno/python-project-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (66 loc) · 2.4 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
.PHONY: help
help: ## Show the help.
@echo "Usage: make <target>"
@echo ""
@echo "Targets:"
@fgrep "##" Makefile | fgrep -v fgrep
.PHONY: install
install: ## Install the project in dev mode.
@echo "Don't forget to run 'make virtualenv' if you got errors."
pip install -e .[test]
.PHONY: runserver
runserver: ## Django run server.
python3 cos_registration_server/manage.py runserver
.PHONY: secretkey
secretkey: ## Generate the django secret key.
python3 -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
.PHONY: fmt
fmt: ## Format code using black & isort.
isort --profile black cos_registration_server/
black -l 79 cos_registration_server/
.PHONY: lint
lint: ## Run pep8, black, mypy linters.
black -l 79 --check cos_registration_server/
flake8 cos_registration_server/ --exclude migrations,tests.py
mypy --strict cos_registration_server
.PHONY: test
test: lint ## Run tests and generate coverage report.
coverage run --source='.' cos_registration_server/manage.py test api devices applications
coverage xml
coverage html
.PHONY: clean
clean: ## Clean unused files.
@find ./ -name '*.pyc' -exec rm -f {} \;
@find ./ -name '__pycache__' -exec rm -rf {} \;
@find ./ -name 'Thumbs.db' -exec rm -f {} \;
@find ./ -name '*~' -exec rm -f {} \;
@rm -rf .cache
@rm -rf .pytest_cache
@rm -rf .mypy_cache
@rm -rf build
@rm -rf dist
@rm -rf *.egg-info
@rm -rf htmlcov
@rm -rf .tox/
@rm -rf docs/_build
.PHONY: virtualenv
virtualenv: ## Create a virtual environment.
@echo "creating virtualenv ..."
@rm -rf .venv
@python3 -m venv .venv
@./.venv/bin/pip install -U pip
@./.venv/bin/pip install -e .[test]
@echo
@echo "!!! Please run 'source .venv/bin/activate' to enable the environment !!!"
.PHONY: release
release: ## Create a new tag for release.
@echo "WARNING: This operation will create s version tag and push to github"
@read -p "Version? (provide the next x.y.z semver) : " TAG
@echo "$${TAG}" > cos_registration_server/cos_registration_server/VERSION
@gitchangelog > HISTORY.md
@git add cos_registration_server/cos_registration_server/VERSION HISTORY.md
@git commit -m "release: version $${TAG} 🚀"
@echo "creating git tag : $${TAG}"
@git tag $${TAG}
@git push -u origin HEAD --tags
@echo "Github Actions will detect the new tag and release the new version."