forked from Rossnkama/crowd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
111 lines (90 loc) · 3.42 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
111
# ENV defaults to local (so that requirements/local.txt are installed), but can be overridden
# (e.g. ENV=production make setup).
ENV ?= local
# PYTHON specifies the python binary to use when creating virtualenv
PYTHON ?= python3.9
export PYTHONPATH := ./lib:$(PYTHONPATH)
# Editor can be defined globally but defaults to nano
EDITOR ?= nano
# By default we open the editor after copying settings, but can be overridden
# (e.g. EDIT_SETTINGS=no make settings).
EDIT_SETTINGS ?= yes
# Get root dir and project dir
PROJECT_ROOT ?= $(PWD)
SITE_ROOT ?= $(PROJECT_ROOT)
BLACK ?= \033[0;30m
RED ?= \033[0;31m
GREEN ?= \033[0;32m
LIGHT_GREEN ?= \033[1;32m
YELLOW ?= \033[0;33m
BLUE ?= \033[0;34m
LIGHT_BLUE ?= \033[1;36m
PURPLE ?= \033[0;35m
CYAN ?= \033[0;36m
GRAY ?= \033[0;37m
COFF ?= \033[0m
INFO ?= $(LIGHT_BLUE)
SUCCESS ?= $(LIGHT_GREEN)
WARNING ?= $(YELLOW)
ERROR ?= $(RED)
DEBUG ?= $(CYAN)
FORMAT ?= $(GRAY)
BOLD ?= \033[1m
DOCKER_COMPOSE = docker-compose
DOCKER_COMPOSE_RUN = $(DOCKER_COMPOSE) run --rm
DOCKER_COMPOSE_DJANGO = $(DOCKER_COMPOSE_RUN) django
.PHONY: all help setup run
.PHONY: pre-commit test
all: help
help:
@echo "+------<<<< Configuration >>>>------+"
@echo ""
@echo "ENV: $(ENV)"
@echo "PYTHON: $(PYTHON)"
@echo "PROJECT_ROOT: $(PROJECT_ROOT)"
@echo "SITE_ROOT: $(SITE_ROOT)"
@echo ""
@echo "+------<<<< Tasks >>>>------+"
@echo ""
@echo "$(CYAN)make setup$(COFF) - Sets up the project in your local machine"
@echo " This includes copying PyCharm files, creating local settings file, and setting up Docker."
@echo ""
@echo "$(CYAN)make pycharm$(COFF) - Copies default PyCharm settings (unless they already exist)"
@echo ""
@echo "$(CYAN)make test$(COFF) - Runs automatic tests on your python code"
@echo ""
@echo "$(CYAN)make pre-commit$(COFF) - Runs automatic code quality tests on your code"
@echo ""
validate-system-packages:
@echo "$(INFO)Validating system packages...$(COFF)"
@which poetry > /dev/null || (echo "$(ERROR)Poetry not found. Please install it. (make setup_env)$(COFF)" && exit 1)
@#which rabbitmqctl > /dev/null || (echo "$(ERROR)RabbitMQ command line tool not found. Please install it.$(COFF)" && exit 1)
@#which docker > /dev/null || (echo "$(ERROR)Docker not found. Please install it.$(COFF)" && exit 1)
@#which docker-compose > /dev/null || (echo "$(ERROR)Docker Compose not found. Please install it.$(COFF)" && exit 1)
@echo "All required system packages are installed."
.env:
@echo "$(CYAN)Creating .env file$(COFF)"
dir_setup: .env
# @audit-info: Added poetry to PATH
setup_poetry:
export PATH="$${PATH}:~/.local/bin" ; \
curl -sSL https://install.python-poetry.org | python3 - ; \
poetry install
setup:
@echo "$(CYAN)Setting up environment$(COFF)"
make setup_poetry
make dir_setup
@echo "$(SUCCESS)==========[ Setup Complete ]============$(COFF)"
test: validate-system-packages
@echo "$(CYAN)Running Tests$(COFF)"
poetry run pytest
test-coverage: validate-system-packages
@echo "$(CYAN)Running Tests$(COFF)"
poetry run pytest --cov=lib/solutions --cov-report term
pre-commit:
@echo "$(CYAN)Running pre-commit$(COFF)"
poetry run pre-commit run --all-files
run:
poetry run python3 examples/simple_sim.py
send_command:
poetry run python3 lib/send_command_to_server.py $(cmd)