-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (71 loc) · 2.08 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
ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
$(eval $(ARGS):;@:)
MAKEFLAGS += --silent
RUN_WEB = docker-compose run --rm -w /code web
EXEC_WEB = docker-compose exec web
RUN_BOT = docker-compose run --rm -w /code bot
EXEC_BOT = docker-compose exec bot
# HELP COMMANDS
help: ## show this help
@echo 'usage: make [target] [option]'
@echo ''
@echo 'Common sequence of commands:'
@echo '- make build [nocache]'
@echo '- make init'
@echo '- make run'
@echo '- make test [unit | integration]'
@echo '- make lint'
@echo '- make bandit'
@echo '- make audit'
@echo '- make bump [major | minor | patch(default)]'
@echo ''
@echo 'targets:'
@egrep '^(.+)\:\ .*##\ (.+)' ${MAKEFILE_LIST} | sed 's/:.*##/#/' | column -t -c 2 -s '#'
.PHONY : build
build: ## build application containers
ifeq ($(ARGS), nocache)
@ docker-compose build --no-cache
else
@ docker-compose build
endif
init: ## build containers and run fixtures
@ make run
@ $(EXEC_WEB) python manage.py migrate
@ $(EXEC_WEB) sh -c "ls apps/**/fixtures/*.json | xargs -I {} python manage.py loaddata {}"
.PHONY : run
run: ## start the application
@ docker-compose up -d db broker
@ sleep 10
@ docker-compose up -d
.PHONY : test
test: ## run the application tests
ifeq ($(ARGS), unit)
@ $(RUN_WEB) py.test
@ $(RUN_BOT) python -m pytest
else ifeq ($(ARGS), integration)
@ $(RUN_WEB) python manage.py behave --no-capture tests.integration
else
# make test integration
make test unit
endif
.PHONY: lint
lint: ## run linters over the code
@ $(RUN_WEB) /bin/sh -c "isort . && black . && flake8"
@ $(RUN_BOT) /bin/sh -c "isort . && black . && flake8"
.PHONY: bandit
bandit: ## run bandit security linter
@ $(RUN_WEB) bandit
@ $(RUN_BOT) bandit
.PHONY: audit
audit: build ## run package auditor
@ $(RUN_WEB) safety check --full-report
@ $(RUN_BOT) safety check --full-report
.PHONY: shell
shell: run ## run application's shell
@ $(EXEC_WEB) python manage.py shell
.PHONY: bump
bump: ## increase package version
@ $(RUN) python -m "bump" --$(ARGS)
@ git add setup.py
@ git commit -n -m "chore: update pkg version"
@ git push -u