-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
98 lines (76 loc) · 2.71 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
### Development
SRC_DIRS := backend metrics-exporter fixtures
.PHONY: install
install: ## Install Python development dependencies
pip install -r backend/dev-requirements.txt
.PHONY: db
db: ## Set up test database
[ `docker ps -f 'name=postgres_backend_db' --format '{{ .ID }}' | wc -l` -gt 0 ] && docker stop postgres_backend_db; true
docker run --name postgres_backend_db --rm \
-e POSTGRES_DB=backend_default \
-e POSTGRES_USER=backend \
-e POSTGRES_PASSWORD=backend \
-p 5432:5432 -d postgres:latest
.PHONY: test
test: ## Run tests
cd backend && \
pytest -n auto --cov-report= -m "not serial" && \
pytest --cov-report= -m "serial"
.PHONY: coverage
coverage: test ## Report test coverage
cd backend && coverage report
.PHONY: format
format: ## Format code
black $(SRC_DIRS)
isort $(SRC_DIRS)
.PHONY: lint
lint: ## Perform a static analysis of the code
flake8 $(SRC_DIRS)
bandit --ini=.bandit
mypy
.PHONY: shell
shell: ## Start a Python shell for the Django project
python backend/manage.py shell
.PHONY: migrations
migrations: ## Create missing Django migrations, if any. See also: check-migrations.
python backend/manage.py makemigrations --settings backend.settings.test
.PHONY: check-migrations
check-migrations: ## Check whether there are missing Django migrations
python backend/manage.py makemigrations --dry-run --check --no-input --settings backend.settings.test
.PHONY: quickstart
quickstart: ## Quickstart for local dev
cd backend && DJANGO_SETTINGS_MODULE=backend.settings.localdev ISOLATED=1 sh dev-startup.sh
.PHONY: fixtures
fixtures:
python backend/manage.py generate_fixtures --settings backend.settings.localdev
### gRPC
ORCHESTRATOR_ROOT?=../orchestrator
UNAME_S := $(shell uname -s)
GRPC_CLIENT_DIR := ./backend/orchestrator
ifeq ($(UNAME_S),Linux)
SED_BINARY = sed
endif
ifeq ($(UNAME_S),Darwin)
SED_BINARY = gsed
endif
.PHONY: orchestrator-grpc
orchestrator-grpc: ## Generate Python gRPC client files (ORCHESTRATOR_ROOT variable may override the default orchestrator path)
python -m grpc_tools.protoc -I ${ORCHESTRATOR_ROOT}/lib/asset/ \
--python_out=$(GRPC_CLIENT_DIR) \
--grpc_python_out=$(GRPC_CLIENT_DIR) \
--mypy_out=$(GRPC_CLIENT_DIR) \
--mypy_grpc_out=$(GRPC_CLIENT_DIR) \
${ORCHESTRATOR_ROOT}/lib/asset/*.proto
${SED_BINARY} -i -E 's/^import.*_pb2/from . \0/' $(GRPC_CLIENT_DIR)/*_pb2*.py
### Documentation
.PHONY: docs
docs: ## Generate documentation
$(MAKE) -C docs
.PHONY: docs-charts
docs-charts: ## Generate Helm chart documentation
$(MAKE) -C charts doc
### Makefile
.PHONY: help
help: ## Display this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.DEFAULT_GOAL := help