forked from Opentrons/opentrons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·254 lines (200 loc) · 6.55 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
251
252
253
254
# opentrons platform makefile
# https://github.com/Opentrons/opentrons
# make OT_PYTHON available
include ./scripts/python.mk
API_DIR := api
APP_SHELL_DIR := app-shell
APP_SHELL_ODD_DIR := app-shell-odd
COMPONENTS_DIR := components
DISCOVERY_CLIENT_DIR := discovery-client
G_CODE_TESTING_DIR := g-code-testing
LABWARE_LIBRARY_DIR := labware-library
NOTIFY_SERVER_DIR := notify-server
PROTOCOL_DESIGNER_DIR := protocol-designer
SHARED_DATA_DIR := shared-data
UPDATE_SERVER_DIR := update-server
ROBOT_SERVER_DIR := robot-server
HARDWARE_DIR := hardware
USB_BRIDGE_DIR := usb-bridge
PYTHON_DIRS := $(API_DIR) $(UPDATE_SERVER_DIR) $(NOTIFY_SERVER_DIR) $(ROBOT_SERVER_DIR) $(SHARED_DATA_DIR)/python $(G_CODE_TESTING_DIR) $(HARDWARE_DIR) $(USB_BRIDGE_DIR)
# This may be set as an environment variable (and is by CI tasks that upload
# to test pypi) to add a .dev extension to the python package versions. If
# empty, no .dev extension is appended, so this definition is here only as
# documentation
BUILD_NUMBER ?=
# watch, coverage, update snapshot, and warning suppresion variables for tests and linting
watch ?= false
cover ?= true
updateSnapshot ?= false
quiet ?= false
FORMAT_FILE_GLOB = ".*.@(js|ts|tsx|yml)" "**/*.@(ts|tsx|js|json|md|yml)"
ifeq ($(watch), true)
cover := false
endif
# run at usage (=), not on makefile parse (:=)
# todo(mm, 2021-03-17): Deduplicate with scripts/python.mk.
usb_host=$(shell yarn run -s discovery find -i 169.254)
# install all project dependencies
.PHONY: setup
setup: setup-js setup-py
# front-end dependecies handled by yarn
.PHONY: setup-js
setup-js:
yarn config set network-timeout 60000
yarn
$(MAKE) -C $(APP_SHELL_DIR) setup
$(MAKE) -C $(APP_SHELL_ODD_DIR) setup
$(MAKE) -C $(SHARED_DATA_DIR) setup-js
PYTHON_SETUP_TARGETS := $(addsuffix -py-setup, $(PYTHON_DIRS))
.PHONY: setup-py
setup-py:
$(OT_PYTHON) -m pip install pipenv==2021.5.29
$(MAKE) $(PYTHON_SETUP_TARGETS)
%-py-setup:
$(MAKE) -C $* setup
# uninstall all project dependencies
# tear down JS after Python, because Python cleanup depends on JS dep shx
.PHONY: teardown
teardown:
$(MAKE) teardown-py
$(MAKE) teardown-js
.PHONY: teardown-js
teardown-js: clean-js
yarn shx rm -rf "**/node_modules"
PYTHON_TEARDOWN_TARGETS := $(addsuffix -py-teardown, $(PYTHON_DIRS))
.PHONY: teardown-py
teardown-py: $(PYTHON_TEARDOWN_TARGETS)
%-py-teardown: %-py-clean
$(MAKE) -C $* teardown
# clean all project output
.PHONY: clean
clean: clean-js clean-py
.PHONY: clean-js
clean-js: clean-ts
$(MAKE) -C $(DISCOVERY_CLIENT_DIR) clean
$(MAKE) -C $(COMPONENTS_DIR) clean
PYTHON_CLEAN_TARGETS := $(addsuffix -py-clean, $(PYTHON_DIRS))
.PHONY: clean-py
clean-py: $(PYTHON_CLEAN_TARGETS)
%-py-clean:
$(MAKE) -C $* clean
.PHONY: deploy-py
deploy-py: export twine_repository_url = $(twine_repository_url)
deploy-py: export pypi_username = $(pypi_username)
deploy-py: export pypi_password = $(pypi_password)
deploy-py:
$(MAKE) -C $(API_DIR) deploy
$(MAKE) -C $(SHARED_DATA_DIR) deploy-py
.PHONY: push-api
push-api: export host = $(usb_host)
push-api:
$(if $(host),@echo "Pushing to $(host)",$(error host variable required))
$(MAKE) -C $(API_DIR) push
.PHONY: push-update-server
push-update-server: export host = $(usb_host)
push-update-server:
$(if $(host),@echo "Pushing to $(host)",$(error host variable required))
$(MAKE) -C $(UPDATE_SERVER_DIR) push
.PHONY: push
push: export host=$(usb_host)
push:
$(if $(host),@echo "Pushing to $(host)",$(error host variable required))
# TODO (amit, 2021-09-28): re-enable when opentrons-hardware is worth deploying.
# $(MAKE) -C $(HARDWARE_DIR) push-no-restart
# sleep 1
$(MAKE) -C $(API_DIR) push-no-restart
sleep 1
$(MAKE) -C $(SHARED_DATA_DIR) push-no-restart
sleep 1
$(MAKE) -C $(UPDATE_SERVER_DIR) push
sleep 1
$(MAKE) -C $(NOTIFY_SERVER_DIR) push
sleep 1
$(MAKE) -C $(ROBOT_SERVER_DIR) push
.PHONY: push-ot3
push-ot3:
$(if $(host),@echo "Pushing to $(host)",$(error host variable required))
$(MAKE) -C $(API_DIR) push-no-restart-ot3
$(MAKE) -C $(HARDWARE_DIR) push-no-restart-ot3
$(MAKE) -C $(SHARED_DATA_DIR) push-no-restart-ot3
$(MAKE) -C $(NOTIFY_SERVER_DIR) push-no-restart-ot3
$(MAKE) -C $(ROBOT_SERVER_DIR) push-ot3
$(MAKE) -C $(UPDATE_SERVER_DIR) push-ot3
$(MAKE) -C $(USB_BRIDGE_DIR) push-ot3
.PHONY: term
term: export host = $(usb_host)
term:
$(if $(host),@echo "Connecting to $(host)",$(error host variable required))
$(MAKE) -C $(API_DIR) term
# all tests
.PHONY: test
test: test-py test-js
# tests that may be run on windows
.PHONY: test-windows
test-windows: test-js test-py-windows
.PHONY: test-e2e
test-e2e:
$(MAKE) -C $(LABWARE_LIBRARY_DIR) test-e2e
$(MAKE) -C $(PROTOCOL_DESIGNER_DIR) test-e2e
.PHONY: test-py-windows
test-py-windows:
$(MAKE) -C $(HARDWARE_DIR) test
$(MAKE) -C $(API_DIR) test
$(MAKE) -C $(SHARED_DATA_DIR) test-py
.PHONY: test-py
test-py: test-py-windows
$(MAKE) -C $(UPDATE_SERVER_DIR) test
$(MAKE) -C $(ROBOT_SERVER_DIR) test
$(MAKE) -C $(NOTIFY_SERVER_DIR) test
$(MAKE) -C $(G_CODE_TESTING_DIR) test
$(MAKE) -C $(USB_BRIDGE_DIR) test
.PHONY: test-js
test-js:
yarn jest \
--coverage=$(cover) \
--watch=$(watch) \
--updateSnapshot=$(updateSnapshot) \
--ci=$(if $(CI),true,false)
# lints and typechecks
.PHONY: lint
lint: lint-py lint-js lint-json lint-css check-js circular-dependencies-js
PYTHON_LINT_TARGETS = $(addsuffix -py-lint, $(PYTHON_DIRS))
.PHONY: lint-py
lint-py: $(PYTHON_LINT_TARGETS)
%-py-lint:
$(MAKE) -C $* lint
.PHONY: lint-js
lint-js:
yarn eslint --quiet=$(quiet) ".*.@(js|ts|tsx)" "**/*.@(js|ts|tsx)"
yarn prettier --ignore-path .eslintignore --check $(FORMAT_FILE_GLOB)
.PHONY: lint-json
lint-json:
yarn eslint --max-warnings 0 --ext .json .
.PHONY: lint-css
lint-css:
yarn stylelint "**/*.css" "**/*.js"
.PHONY: format
format: format-js format-py
PYTHON_FORMAT_TARGETS := $(addsuffix -py-format, $(PYTHON_DIRS))
.PHONY: format-py
format-py: $(PYTHON_FORMAT_TARGETS)
%-py-format:
$(MAKE) -C $* format
.PHONY: format-js
format-js:
yarn prettier --ignore-path .eslintignore --write $(FORMAT_FILE_GLOB)
.PHONY: check-js
check-js: build-ts
.PHONY: build-ts
build-ts:
yarn tsc --build
.PHONY: clean-ts
clean-ts:
yarn tsc --build --clean
# TODO: Ian 2019-12-17 gradually add components and shared-data
.PHONY: circular-dependencies-js
circular-dependencies-js:
yarn madge $(and $(CI),--no-spinner --no-color) --circular protocol-designer/src/index.tsx
yarn madge $(and $(CI),--no-spinner --no-color) --circular step-generation/src/index.ts
yarn madge $(and $(CI),--no-spinner --no-color) --circular labware-library/src/index.tsx
yarn madge $(and $(CI),--no-spinner --no-color) --circular app/src/index.tsx