-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
250 lines (212 loc) · 5.54 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
.DEFAULT_GOAL := help
include makefiles/colors.mk
include makefiles/help.mk
include makefiles/macros.mk
SHELL := /bin/bash
SOURCE_CMD := source venv/bin/activate
PYTHON := python3.10
#------------------------------------
# Installation
#------------------------------------
BIN_DIR := /usr/local/bin
SHFMT_VERSION := 3.4.3
SHFMT_PATH := ${BIN_DIR}/shfmt
.PHONY: install-shfmt
## Install shfmt | Installation
install-shfmt:
$(call print,Installing shfmt)
@sudo curl https://github.com/mvdan/sh/releases/download/v${SHFMT_VERSION}/shfmt_v${SHFMT_VERSION}_linux_amd64 -Lo ${SHFMT_PATH}
@sudo chmod +x ${SHFMT_PATH}
ACTIONLINT_VERSION := 1.6.13
ACTIONLINT_PATH := ${BIN_DIR}/actionlint
ACTIONLINT_URL := https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz
ACTIONLINT_TMP_DIR := $(shell mktemp -d)
ACTIONLINT_ARCHIVE := actionlint.tar.gz
.PHONY: install-actionlint
## Install actionlint
install-actionlint:
$(call print,Installing actionlint)
@cd ${ACTIONLINT_TMP_DIR} && \
curl ${ACTIONLINT_URL} -Lo ${ACTIONLINT_ARCHIVE} && \
tar -xvf ${ACTIONLINT_ARCHIVE} && \
sudo mv actionlint ${ACTIONLINT_PATH}
.PHONY: install-twine
## Install twine
install-twine:
$(call print,Installing twine)
@sudo pip3 install twine
.PHONY: install-test-deps
## Install test dependencies
install-test-deps: install-shfmt install-actionlint
$(call print,Installing shellcheck)
@sudo apt install shellcheck -y
$(call print,Installing tox)
@sudo pip3 install tox
$(call print,Installing markdownlint-cli)
@sudo npm install -g markdownlint-cli
.PHONY: install-deps
## Install dependencies
install-deps:
$(call print,Installing Python)
@sudo apt install ${PYTHON} ${PYTHON}-venv ${PYTHON}-dev -y
.PHONY: create-venv
## Create virtual environment and install requirements
create-venv:
$(call print,Creating venv)
${PYTHON} -m venv venv
${SOURCE_CMD} && \
pip install -r requirements-dev.txt && \
pip install -e .
.PHONY: create-tox-venv
create-tox-venv:
$(call print,Creating tox venv and installing requirements)
@tox -e py-requirements
.PHONY: create-venvs
create-venvs: create-venv create-tox-venv
.PHONY: bootstrap
## Bootstrap project
bootstrap: create-venvs
#------------------------------------
#------------------------------------
# Scripts
#------------------------------------
.PHONY: pydiatra-script
pydiatra-script:
$(call print,Running pydiatra script)
scripts/pydiatra.sh
#------------------------------------
#------------------------------------
# Tests
#------------------------------------
.PHONY: test
## Run tests | Tests
test: shfmt shellcheck markdownlint actionlint tox
.PHONY: tox
## Run tox
tox:
$(call print,Running tox)
@tox
.PHONY: pydiatra
## Run pydiatra linter
pydiatra:
$(call print,Running pydiatra)
@tox -e py-pydiatra
.PHONY: pylint
## Run pylint linter
pylint:
$(call print,Running pylint)
@tox -e py-pylint
.PHONY: flake8
## Run flake8 linter
flake8:
$(call print,Running flake8)
@tox -e py-flake8
.PHONY: isort
## Run isort linter
isort:
$(call print,Running isort linter)
@tox -e py-isort
.PHONY: bandit
## Run bandit linter
bandit:
$(call print,Running bandit)
@tox -e py-bandit
.PHONY: rstlint
## Run rstlint linter
rstlint:
$(call print,Running rstlint)
@tox -e py-rstlint
.PHONY: pydocstyle
## Run pydocstyle linter
pydocstyle:
$(call print,Running pydocstyle)
@tox -e py-pydocstyle
.PHONY: safety
## Run safety linter
safety:
$(call print,Running safety)
@tox -e py-safety
.PHONY: pytest
## Run pytest
pytest:
$(call print,Running pytest)
@tox -e py-pytest
.PHONY: black
## Run black linter
black:
$(call print,Running black linter)
@tox -e py-black
.PHONY: mypy
## Run mypy linter
mypy:
$(call print,Running mypy)
@tox -e py-mypy
.PHONY: shfmt
## Run shfmt linter
shfmt:
$(call print,Running shfmt linter)
@shfmt -l -d .
.PHONY: shellcheck
## Run shellcheck linter
shellcheck:
$(call print,Running shellcheck)
@shellcheck scripts/*.sh
.PHONY: markdownlint
## Run markdownlint linter
markdownlint:
$(call print,Running markdownlint)
@markdownlint CHANGELOG.md developer_doc.md
.PHONY: actionlint
## Run actionlint linter
actionlint:
$(call print,Running actionlint)
@actionlint
.PHONY: prettier-yaml-lint
## Run yaml linter
prettier-yaml-lint:
$(call print,Running prettier check for yaml)
@yarn run prettier --check ./.github/**/*.yaml
#------------------------------------
#------------------------------------
# Development
#------------------------------------
.PHONY: update-venvs
## Update packages in venv and tox with current requirements | Development
update-venvs:
$(call print,Updating venvs)
@${SOURCE_CMD} && \
pip install -r requirements-dev.txt && \
pip install -e . && \
deactivate && \
source .tox/py/bin/activate && \
pip install -r requirements-dev.txt && \
pip install -e .
.PHONY: format
## Format code
format:
$(call print,Formatting code)
@${SOURCE_CMD} && \
autoflake --remove-all-unused-imports --in-place -r django_tqdm && \
isort django_tqdm demos tests && \
black .
@shfmt -l -w .
@markdownlint CHANGELOG.md developer_doc.md --fix
@prettier --write ./.github/**/*.yaml
.PHONY: delete-venvs
delete-venvs:
$(call print,Deleting venvs)
@rm -rf venv
@rm -rf .tox
.PHONY: recreate-venvs
## Recreate venvs
recreate-venvs: delete-venvs create-venvs
#------------------------------------
#------------------------------------
# Commands
#------------------------------------
.PHONY: build-wheel
## Build wheel | Commands
build-wheel:
$(call print,Building wheel)
@python3 setup.py bdist_wheel
#------------------------------------