forked from Opentrons/opentrons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·234 lines (191 loc) · 6.03 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
# opentrons platform makefile
# https://github.com/Opentrons/opentrons
# make OT_PYTHON available
include ./scripts/python.mk
# using bash instead of /bin/bash in SHELL prevents macOS optimizing away our PATH update
SHELL := bash
# add node_modules/.bin to PATH
# TODO(mc, 2021-02-12): remove in favor of `yarn run` directly
PATH := $(shell yarn bin):$(PATH)
API_DIR := api
APP_SHELL_DIR := app-shell
COMPONENTS_DIR := components
DISCOVERY_CLIENT_DIR := discovery-client
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
# 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, and update snapshot variables for tests
watch ?= false
cover ?= true
updateSnapshot ?= 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
.PHONY: clean-py
clean-py:
$(MAKE) -C $(API_DIR) clean
$(MAKE) -C $(UPDATE_SERVER_DIR) clean
$(MAKE) -C $(ROBOT_SERVER_DIR) clean
$(MAKE) -C $(SHARED_DATA_DIR) clean
.PHONY: clean-js
clean-js: clean-ts
$(MAKE) -C $(DISCOVERY_CLIENT_DIR) clean
$(MAKE) -C $(COMPONENTS_DIR) clean
.PHONY: setup-py
setup-py:
$(OT_PYTHON) -m pip install pipenv==2020.8.13
$(MAKE) -C $(API_DIR) setup
$(MAKE) -C $(UPDATE_SERVER_DIR) setup
$(MAKE) -C $(NOTIFY_SERVER_DIR) setup
$(MAKE) -C $(ROBOT_SERVER_DIR) setup
$(MAKE) -C $(SHARED_DATA_DIR) setup-py
# front-end dependecies handled by yarn
.PHONY: setup-js
setup-js:
yarn config set network-timeout 60000
yarn
$(MAKE) -j 1 -C $(APP_SHELL_DIR) setup
$(MAKE) -j 1 -C $(SHARED_DATA_DIR) setup-js
# uninstall all project dependencies
.PHONY: teardown
teardown: teardown-py teardown-js
.PHONY: teardown-py
teardown-py:
$(MAKE) -C $(API_DIR) clean teardown
$(MAKE) -C $(ROBOT_SERVER_DIR) clean teardown
$(MAKE) -C $(NOTIFY_SERVER_DIR) clean teardown
$(MAKE) -C $(SHARED_DATA_DIR) clean-py teardown-py
.PHONY: teardown-js
teardown-js: clean-js
yarn shx rm -rf "**/node_modules"
.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-balena
push-api-balena: export host = $(usb_host)
push-api-balena:
$(if $(host),@echo "Pushing to $(host)",$(error host variable required))
$(MAKE) -C $(API_DIR) push-balena
$(MAKE) -C $(API_DIR) restart
.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-api-buildroot
push-api-buildroot: push-api
.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))
$(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: 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 $(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
.PHONY: test-js
test-js:
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
.PHONY: format
format:
ifeq ($(watch),true)
onchange $(FORMAT_FILE_GLOB) -- prettier --ignore-path .eslintignore --write {{changed}}
else
prettier --ignore-path .eslintignore --write $(FORMAT_FILE_GLOB)
endif
.PHONY: lint-py
lint-py:
$(MAKE) -C $(API_DIR) lint
$(MAKE) -C $(UPDATE_SERVER_DIR) lint
$(MAKE) -C $(ROBOT_SERVER_DIR) lint
$(MAKE) -C $(SHARED_DATA_DIR) lint-py
$(MAKE) -C $(NOTIFY_SERVER_DIR) lint
.PHONY: lint-js
lint-js:
eslint ".*.@(js|ts|tsx)" "**/*.@(js|ts|tsx)"
prettier --ignore-path .eslintignore --check $(FORMAT_FILE_GLOB)
.PHONY: lint-json
lint-json:
eslint --max-warnings 0 --ext .json .
.PHONY: lint-css
lint-css:
stylelint "**/*.css" "**/*.js"
.PHONY: check-js
check-js: build-ts
yarn flow $(if $(CI),check,status)
.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:
madge $(and $(CI),--no-spinner --no-color) --circular protocol-designer/src/index.js
madge $(and $(CI),--no-spinner --no-color) --circular step-generation/src/index.js
madge $(and $(CI),--no-spinner --no-color) --circular labware-library/src/index.tsx
madge $(and $(CI),--no-spinner --no-color) --circular app/src/index.js
.PHONY: bump
bump:
@echo "Bumping versions"
lerna version $(or $(version),prerelease)