forked from artefactory/streamlit_prophet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
148 lines (124 loc) · 3.7 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
SHELL := /usr/bin/env bash
IMAGE := streamlit_prophet
VERSION := latest
NO_CHECK_FLAG = || true
ifeq ($(STRICT), 1)
POETRY_COMMAND_FLAG =
PIP_COMMAND_FLAG =
SAFETY_COMMAND_FLAG =
BANDIT_COMMAND_FLAG =
SECRETS_COMMAND_FLAG =
BLACK_COMMAND_FLAG =
DARGLINT_COMMAND_FLAG =
ISORT_COMMAND_FLAG =
MYPY_COMMAND_FLAG =
else
POETRY_COMMAND_FLAG = $(NO_CHECK_FLAG)
PIP_COMMAND_FLAG = $(NO_CHECK_FLAG)
SAFETY_COMMAND_FLAG = $(NO_CHECK_FLAG)
BANDIT_COMMAND_FLAG = $(NO_CHECK_FLAG)
SECRETS_COMMAND_FLAG = $(NO_CHECK_FLAG)
BLACK_COMMAND_FLAG = $(NO_CHECK_FLAG)
DARGLINT_COMMAND_FLAG = $(NO_CHECK_FLAG)
ISORT_COMMAND_FLAG = $(NO_CHECK_FLAG)
MYPY_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(POETRY_STRICT), 1)
POETRY_COMMAND_FLAG =
else ifeq ($(POETRY_STRICT), 0)
POETRY_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(PIP_STRICT), 1)
PIP_COMMAND_FLAG =
else ifeq ($(PIP_STRICT), 0)
PIP_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(SAFETY_STRICT), 1)
SAFETY_COMMAND_FLAG =
else ifeq ($(SAFETY_STRICT), 0)
SAFETY_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(BANDIT_STRICT), 1)
BANDIT_COMMAND_FLAG =
else ifeq ($(BANDIT_STRICT), 0)
BANDIT_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(SECRETS_STRICT), 1)
SECRETS_COMMAND_FLAG =
else ifeq ($(SECRETS_STRICT), 0)
SECRETS_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(BLACK_STRICT), 1)
BLACK_COMMAND_FLAG =
else ifeq ($(BLACK_STRICT), 0)
BLACK_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(DARGLINT_STRICT), 1)
DARGLINT_COMMAND_FLAG =
else ifeq ($(DARGLINT_STRICT), 0)
DARGLINT_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(ISORT_STRICT), 1)
ISORT_COMMAND_FLAG =
else ifeq ($(ISORT_STRICT), 0)
ISORT_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
ifeq ($(MYPY_STRICT), 1)
MYPY_COMMAND_FLAG =
else ifeq ($(MYPY_STRICT), 0)
MYPY_COMMAND_FLAG = $(NO_CHECK_FLAG)
endif
.PHONY: download-poetry
download-poetry:
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python
.PHONY: install
install:
poetry env use 3.8
poetry lock -n
poetry install -n
ifneq ($(NO_PRE_COMMIT), 1)
poetry run pre-commit install -t pre-commit -t pre-push
endif
.PHONY: check-safety
check-safety:
poetry check$(POETRY_COMMAND_FLAG) && \
poetry run pip check$(PIP_COMMAND_FLAG) && \
poetry run safety check --full-report$(SAFETY_COMMAND_FLAG) && \
poetry run bandit -r streamlit_prophet/$(BANDIT_COMMAND_FLAG)
.PHONY: gitleaks
gitleaks:
commits="$$(git rev-list --ancestry-path $$(git rev-parse $$(git branch -r --sort=committerdate | tail -1))..$$(git rev-parse HEAD))"; \
if [ "$${commits}" != "" ]; then docker run --rm -v $$(pwd):/code/ zricethezav/gitleaks --path=/code/ -v --commits=$$(echo $${commits} | paste -s -d, -); fi;
.PHONY: check-style
check-style:
poetry run black --config pyproject.toml --diff --check ./$(BLACK_COMMAND_FLAG) && \
poetry run darglint -v 2 **/*.py$(DARGLINT_COMMAND_FLAG) && \
poetry run isort --settings-path pyproject.toml --check-only **/*.py$(ISORT_COMMAND_FLAG) && \
poetry run mypy --config-file setup.cfg streamlit_prophet tests/**/*.py$(MYPY_COMMAND_FLAG)
.PHONY: format-code
format-code:
poetry run pre-commit run
.PHONY: test
test:
poetry run pytest
.PHONY: lint
lint: test check-safety check-style
# Example: make docker VERSION=latest
# Example: make docker IMAGE=some_name VERSION=0.1.0
.PHONY: docker
docker:
@echo Building docker $(IMAGE):$(VERSION) ...
docker build \
-t $(IMAGE):$(VERSION) . \
-f ./Dockerfile
# Example: make clean_docker VERSION=latest
# Example: make clean_docker IMAGE=some_name VERSION=0.1.0
.PHONY: clean_docker
clean_docker:
@echo Removing docker $(IMAGE):$(VERSION) ...
docker rmi -f $(IMAGE):$(VERSION)
.PHONY: clean_build
clean_build:
rm -rf build/
.PHONY: clean
clean: clean_build clean_docker