-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
53 lines (43 loc) · 1.57 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
# Copyright (c) 2022 CloudZero - ALL RIGHTS RESERVED - PROPRIETARY AND CONFIDENTIAL
# Unauthorized copying of this file and/or project, via any medium is strictly prohibited.
# Direct all questions to [email protected]
ERROR_COLOR = \033[1;31m
INFO_COLOR = \033[1;32m
WARN_COLOR = \033[1;33m
NO_COLOR = \033[0m
PYTHON_VERSION_SUPPORTED := 3.8 3.9 3.10
PYTHON_VERSION_SHELL := $(shell python --version | cut -f2 -d' ' | cut -f1,2 -d'.')
check-python-version:
ifeq ($(findstring $(PYTHON_VERSION_SHELL),$(PYTHON_VERSION_SUPPORTED)),)
@printf "$(WARN_COLOR)You have python $(ERROR_COLOR)$(PYTHON_VERSION_SHELL)$(WARN_COLOR); you need python one of $(INFO_COLOR)($(PYTHON_VERSION_SUPPORTED))$(NO_COLOR).\n"
@exit 1
else
@printf "$(INFO_COLOR)OK!$(NO_COLOR) Shell version $(PYTHON_VERSION_SHELL) in ($(PYTHON_VERSION_SUPPORTED)).\n"
endif
VIRTUALENV := venv
$(VIRTUALENV): check-python-version
@python -m venv $(VIRTUALENV)
PYTHON_ARGS := . $(VIRTUALENV)/bin/activate && PYTHONPATH=.
LIBS := $(VIRTUALENV)/lib/python$(PYTHON_VERSION_SHELL)/site-packages
REQUIREMENTS := requirements.txt
.PHONY: init
init: $(LIBS)
$(LIBS): $(VIRTUALENV) $(REQUIREMENTS)
@$(PYTHON_ARGS) pip install -r $(REQUIREMENTS)
@touch $(LIBS)
.PHONY: run
run: $(LIBS)
@$(PYTHON_ARGS) python src/functions/handler.py --goal $(goal)
.PHONY: evaluate
evaluate: count ?= 100
evaluate: $(LIBS)
@$(PYTHON_ARGS) python src/functions/handler.py --evaluate $(count)
.PHONY: test
test:
@$(PYTHON_ARGS) pytest tests
.PHONY: lint
lint:
@$(PYTHON_ARGS) flake8 src tests
@$(PYTHON_ARGS) mypy src tests
.PHONY: check
check: lint test