-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (45 loc) · 2.16 KB
/
Makefile
File metadata and controls
55 lines (45 loc) · 2.16 KB
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
.PHONY: clean format lint requirements create_environment
.EXPORT_ALL_VARIABLES:
#################################################################################
# GLOBALS
##################################################################################
PROJECT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
PROJECT_NAME = app
PYTHON_INTERPRETER = python3
SRC = enginesdk/
TEST = enginesdk/tests/
#################################################################################
# COMMANDS
##################################################################################
## Delete all compiled Python files
clean:
find . -not -path "./.venv/*" -type f -name "*.py[co]" -exec rm -rf {} \;
find . -not -path "./.venv/*" -type d -name "__pycache__" -exec rm -rf {} \;
find . -not -path "./.venv/*" -type d -name "*.egg-info" -exec rm -rf {} \;
find . -not -path "./.venv/*" -type d -name "dist" -exec rm -rf {} \;
rm -rf htmlcov .coverage .hypothesis
## Format code using black
format:
$(PYTHON_INTERPRETER) -m poetry run black $(SRC)
$(PYTHON_INTERPRETER) -m poetry run isort $(SRC) --profile black
$(PYTHON_INTERPRETER) -m poetry run black $(TEST)
$(PYTHON_INTERPRETER) -m poetry run isort $(TEST) --profile black
## Lint using flake8
lint:
$(PYTHON_INTERPRETER) -m poetry run pylint --fail-under=6 $(SRC) --exit-zero
$(PYTHON_INTERPRETER) -m poetry run flake8 $(SRC) --count --exit-zero --per-file-ignores="__init__.py:F401" --max-complexity=10 --max-line-length=127 --statistics
## Run tests
test:
export MAIN_API_KEY="test-api"
$(PYTHON_INTERPRETER) -m poetry run pytest $(TEST) -s --cov=$(SRC) --cov-report html:./htmlcov --cov-fail-under 60 --log-cli-level DEBUG
$(PYTHON_INTERPRETER) -m poetry run coverage-badge -fo coverage.svg
## Set up the environment using poetry
create_environment:
$(PYTHON_INTERPRETER) -m pip install -U poetry
$(PYTHON_INTERPRETER) -m poetry install
## Build wheel package
build:
$(PYTHON_INTERPRETER) -m poetry build
## Deploy on CloudRun
deploy:
gcloud builds submit . --config=cloudbuild.yaml --substitutions=BRANCH_NAME=local,_REGION=$(REGION),_ENGINE_SLUG=$(ENGINE_SLUG),_MODEL=$(MODEL)