-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (57 loc) · 1.78 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
.DEV_PROFILE := okdata-dev
.PROD_PROFILE := okdata-prod
GLOBAL_PY := python3
BUILD_VENV ?= .build_venv
BUILD_PY := $(BUILD_VENV)/bin/python
.PHONY: init
init: node_modules $(BUILD_VENV)
node_modules: package.json package-lock.json
npm install
$(BUILD_VENV):
$(GLOBAL_PY) -m venv $(BUILD_VENV)
$(BUILD_PY) -m pip install -U pip
.PHONY: format
format: $(BUILD_VENV)/bin/black
$(BUILD_PY) -m black .
.PHONY: test
test: $(BUILD_VENV)/bin/tox
$(BUILD_PY) -m tox -p auto -o
.PHONY: upgrade-deps
upgrade-deps: $(BUILD_VENV)/bin/pip-compile
$(BUILD_VENV)/bin/pip-compile -U
.PHONY: deploy
deploy: login-dev init format test
@echo "\nDeploying to stage: dev\n"
sls deploy --stage dev --aws-profile $(.DEV_PROFILE)
.PHONY: deploy-prod
deploy-prod: login-prod init format is-git-clean test
sls deploy --stage prod --aws-profile $(.PROD_PROFILE)
.PHONY: undeploy
undeploy: login-dev init
@echo "\nUndeploying stage: dev\n"
sls remove --stage dev --aws-profile $(.DEV_PROFILE)
.PHONY: undeploy-prod
undeploy-prod: login-prod init
@echo "\nUndeploying stage: prod\n"
sls remove --stage prod --aws-profile $(.PROD_PROFILE)
.PHONY: login-dev
login-dev: init
aws sts get-caller-identity --profile $(.DEV_PROFILE) || aws sso login --profile=$(.DEV_PROFILE)
.PHONY: login-prod
login-prod: init
aws sts get-caller-identity --profile $(.PROD_PROFILE) || aws sso login --profile=$(.PROD_PROFILE)
.PHONY: is-git-clean
is-git-clean:
@status=$$(git fetch origin && git status -s -b) ;\
if test "$${status}" != "## main...origin/main"; then \
echo; \
echo Git working directory is dirty, aborting >&2; \
false; \
fi
###
# Python build dependencies
##
$(BUILD_VENV)/bin/pip-compile: $(BUILD_VENV)
$(BUILD_PY) -m pip install -U pip-tools
$(BUILD_VENV)/bin/%: $(BUILD_VENV)
$(BUILD_PY) -m pip install -U $*