-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMakefile
110 lines (88 loc) · 3.49 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
BOLD := \033[1m
RESET := \033[0m
# If you want to use a virtualenv on your machine instead of Docker, set the NO_DOCKER variable to
# something not null. All commands will then be run on your machine instead of being run in the
# Docker container using "docker-compose".
ifndef NO_DOCKER
# Docker
COMPOSE = docker-compose
COMPOSE_RUN = $(COMPOSE) run --rm
COMPOSE_RUN_APP = $(COMPOSE_RUN) app
COMPOSE_TEST = $(COMPOSE) -p videofront-test -f docker/compose/test/docker-compose.yml --project-directory .
COMPOSE_TEST_RUN = $(COMPOSE_TEST) run --rm
COMPOSE_TEST_RUN_APP = $(COMPOSE_TEST_RUN) app
endif
default: help
.PHONY : help
help: ## Show this help
@echo "$(BOLD)VideoFront Makefile$(RESET)"
@echo "Please use 'make $(BOLD)target$(RESET)' where $(BOLD)target$(RESET) is one of:"
@grep -h ':\s\+##' Makefile | column -tn -s# | awk -F ":" '{ print " $(BOLD)" $$1 "$(RESET)" $$2 }'
##########################################################
# Targets that work for Docker or Virtualenv installations
# (you must set the NO_DOCKER environment variable to install without Docker)
lint: ## lint back-end python sources
${MAKE} lint-isort;
${MAKE} lint-black; # black should come after isort just in case they don't agree...
${MAKE} lint-flake8;
${MAKE} lint-pylint;
.PHONY: lint
lint-black: ## lint back-end python sources with black
@echo 'lint:black started…';
@$(COMPOSE_TEST_RUN_APP) black api contrib pipeline transcoding videofront;
.PHONY: lint-black
lint-flake8: ## lint back-end python sources with flake8
@echo 'lint:flake8 started…';
@$(COMPOSE_TEST_RUN_APP) flake8;
.PHONY: lint-flake8
lint-isort: ## automatically re-arrange python imports in back-end code base
@echo 'lint:isort started…';
@$(COMPOSE_TEST_RUN_APP) isort --recursive --atomic .;
.PHONY: lint-isort
lint-pylint: ## lint back-end python sources with pylint
@echo 'lint:pylint started…';
@$(COMPOSE_TEST_RUN_APP) pylint api contrib pipeline transcoding videofront;
.PHONY: lint-pylint
test: ## run back-end tests
@$(COMPOSE_TEST_RUN_APP) pytest
.PHONY: test
.PHONY: migrate
migrate: ## Run django migration for the videofront project.
@echo "$(BOLD)Running migrations$(RESET)"
@$(COMPOSE_RUN_APP) python manage.py migrate
superuser: ## create a Django superuser
@$(COMPOSE_RUN_APP) python manage.py createsuperuser
.PHONY: superuser
.PHONY: dist
dist: ## Build the package
@python setup.py sdist bdist_wheel
.PHONY: clean
clean: ## Clean python build related directories and files
@echo "$(BOLD)Cleaning$(RESET)"
@rm -rf build dist videofront.egg-info
##############################################
# Targets specific to Virtualenv installations
.PHONY: install
install: ## Install the project in the current environment, with its dependencies
@pip install .[aws]
.PHONY: dev
dev: ## Install the project in the current environment, with its dependencies, including the ones needed in a development environment
@pip install -e .[aws,dev,quality,test]
##########################################
# Targets specific to Docker installations
.PHONY: bootstrap
bootstrap: ## Prepare Docker images for the project
@$(COMPOSE) build base;
@$(COMPOSE) build app;
@echo 'Waiting until database is up…';
$(COMPOSE_RUN_APP) dockerize -wait tcp://db:5432 -timeout 60s
${MAKE} migrate;
.PHONY: run
run: ## start the Docker development server
@$(COMPOSE) up -d
stop: ## stop the Docker development server
@$(COMPOSE) stop
.PHONY: stop
logs: ## get the Docker logs
@$(COMPOSE) logs -f
.PHONY: logs