-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
93 lines (74 loc) · 2.09 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
SHELL := /bin/bash -O extglob
venv := .env
payload := dist/lambda-deploy.zip
lambda_name := SuccsRemindersNorthBot
python := python3.11
aws_args ?=
flavors := North South
secrets = $(addsuffix _clientcred.secret,$(flavors))
.PHONY: zip
zip: $(payload)
$(venv):
$(python) -m venv $(@)
$(@)/bin/pip install -e .
dist:
mkdir -p $(@)
.PHONY: clean
clean: ## Clean generated files
clean:
rm -rf dist
.PHONY: update
update: ## Update dependencies and data
update: | $(venv)
$(venv)/bin/pip install --upgrade pip
$(venv)/bin/pip install --upgrade --upgrade-strategy eager -e .
$(payload): $(wildcard *.py) config.ini $(secrets) | $(venv) dist
rm -rf $(@)
zip $(@) $(^) -x \*.pyc
root=$$(pwd); cd $(venv)/lib/$(python)/site-packages && \
zip -r $$root/$(@) ./!(pip*|wheel*|setuptools*|easy_install*) -x \*.pyc
.PHONY: secrets
secrets: $(secrets)
$(secrets): | $(venv)
$(venv)/bin/python auth_setup.py
.PHONY: deploy
deploy: ## Deploy to AWS Lambda
deploy: $(payload)
aws $(aws_args) lambda update-function-code \
--function-name $(lambda_name) \
--zip-file fileb://$$(pwd)/$(<)
.PHONY: invoke
invoke: ## Invoke AWS Lambda
invoke:
aws $(aws_args) lambda invoke \
--function-name $(lambda_name) \
--cli-binary-format raw-in-base64-out \
--payload '{"date": "2023-03-01"}' \
/dev/null
heics = $(wildcard assets/*.HEIC)
.PHONY: assets
assets: ## Generate assets
assets: $(heics:.HEIC=.jpg)
%.jpg: %.HEIC
heif-convert -q 80 $(<) $(@)
.PHONY: deploy-assets
deploy-assets: ## Deploy assets to S3
deploy-assets: assets
aws $(aws_args) s3 sync --exclude '*' --include '*.jpg' assets/ s3://amake-bots/succs
.PHONY: test
test: ## Test locally
test: test-execute test-unittest
.PHONY: test-execute
test-execute: | $(venv)
$(venv)/bin/python succs.py 2023-03-01
$(venv)/bin/python succs.py 2023-03-01 Southern
.PHONY: test-unittest
test-unittest: | $(venv)
$(venv)/bin/python -m unittest tests/test_*.py
.PHONY: help
help: ## Show this help text
$(info usage: make [target])
$(info )
$(info Available targets:)
@awk -F ':.*?## *' '/^[^\t].+?:.*?##/ \
{printf " %-24s %s\n", $$1, $$2}' $(MAKEFILE_LIST)