-
Notifications
You must be signed in to change notification settings - Fork 176
/
Makefile
104 lines (84 loc) · 2.66 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
include ../scripts/push.mk
include ../scripts/python.mk
# using bash instead of /bin/bash in SHELL prevents macOS optimizing away our PATH update
SHELL := bash
PATH := $(shell cd .. && yarn bin):$(PATH)
SHX := npx shx
# add yarn CLI dev deps to PATH (for cross platform POSIX commands via shx)
PATH := $(shell cd .. && yarn bin):$(PATH)
ot_project := $(OPENTRONS_PROJECT)
project_rs_default = $(if $(ot_project),$(ot_project),robot-stack)
project_ir_default = $(if $(ot_project),$(ot_project),ot3)
port ?= 34000
tests ?= tests
test_opts ?=
wheel_file = $(call python_get_wheelname,update-server,$(project_rs_default),otupdate)
sdist_file = $(call python_get_sdistname,update-server,$(project_rs_default),otupdate)
# Find the branch, sha, version that will be used to update the VERSION.json file
version_file = $(call python_get_git_version,update-server,$(project_rs_default),update-server)
# Host key location for robot
ssh_key ?= $(default_ssh_key)
# Other SSH args for robot
ssh_opts ?= $(default_ssh_opts)
.PHONY: setup
setup:
$(pipenv) sync $(pipenv_opts)
$(pipenv) run pip freeze
.PHONY: dev
dev: export ENABLE_VIRTUAL_SMOOTHIE := true
dev:
$(python) -m otupdate --log-level debug --port $(port)
.PHONY: clean
clean:
$(SHX) rm -rf \
build \
dist \
.coverage \
coverage.xml \
'*.egg-info' \
'**/__pycache__' \
'**/*.pyc'
.PHONY: teardown
teardown:
$(pipenv) --rm
.PHONY: test
test:
$(python) -m pytest $(test_opts) $(tests)
.PHONY: lint
lint:
$(python) -m mypy otupdate tests
$(python) -m black --check ./otupdate ./tests
$(python) -m flake8 otupdate tests
.PHONY: format
format:
$(python) -m black otupdate tests
.PHONY: wheel
wheel: export OPENTRONS_PROJECT=$(project_rs_default)
wheel: clean
$(python) setup.py bdist_wheel
$(SHX) rm -rf build
$(SHX) ls dist
.PHONY: sdist
sdist: export OPENTRONS_PROJECT=$(project_rs_default)
sdist: clean
$(python) setup.py sdist
$(SHX) rm -rf build
$(SHX) ls dist
.PHONY: bootstrap
bootstrap: wheel
curl -X POST \
-H "Content-Type: multipart/form-data" \
-F "whl=@$(wheel_file)" \
http:https://$(host):31950/server/update/bootstrap
.PHONY: restart
restart:
curl -X POST http:https://$(host):31950/server/restart
.PHONY: push
push: wheel
$(call push-python-package,$(host),$(ssh_key),$(ssh_opts),dist/$(wheel_file))
$(call push-systemd-unit,$(host),$(ssh_key),$(ssh_opts),./opentrons-update-server.service)
$(call restart-service,$(host),$(ssh_key),$(ssh_opts),opentrons-update-server)
.PHONY: push-ot3
push-ot3: sdist
$(call push-python-sdist,$(host),$(ssh_key),$(ssh_opts),dist/$(sdist_file),/opt/opentrons-update-server,"otupdate",,,$(version_file))
$(call restart-service,$(host),$(ssh_key),$(ssh_opts),opentrons-update-server)