-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile
86 lines (71 loc) · 3.62 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
# Compiles some basic usage analytics
analytics:
@cd scripts && poetry run python3 ./analytics.py
# Deletes old users that have never logged any data
cleanup_zombie_users:
@cd scripts && poetry run python3 ./cleanup_zombie_users.py
# Makes notifications_send.zip
scripts/cloudformation/lambdas/notifications_send.zip: scripts/cloudformation/lambdas/notifications_send/*
@cd scripts/cloudformation/lambdas/notifications_send &&\
mkdir -p package &&\
pip install -r requirements.txt --target ./package > /dev/null
@echo "🍄 notifications_send dependencies installed successfully! 🍄"
@cd scripts/cloudformation/lambdas/notifications_send/package &&\
rm -r __pycache__ &&\
zip -r ../../notifications_send.zip . > /dev/null &&\
cd .. &&\
zip ../notifications_send.zip index.py > /dev/null
@echo "🍄 notifications_send.zip made successfully! 🍄"
# Generates the CloudFormation file
infra/cloudformation.yml: scripts/cloudformation/*.py scripts/cloudformation/**/*.py
@cd scripts && poetry run python3 cloudformation/main.py
@echo "🍄 CloudFormation template built successfully! 🍄"
# Builds and validates the CloudFormation template
cloudformation/test: infra/cloudformation.yml
@cd scripts && poetry run cfn-lint ../infra/cloudformation.yml
@echo "🍄 CloudFormation template linted successfully! 🍄"
@aws s3 cp --quiet infra/cloudformation.yml s3://moodtracker-cloudformation
@echo "🍄 CloudFormation template uploaded to S3 successfully! 🍄"
@./bin/test-cloudformation.sh
# Deploy infrastructure
deploy: cloudformation/test deploy/notifications_send
@./bin/deploy.sh
# Deployment dry run to view potential changes
deploy/dry-run: cloudformation/test
@aws cloudformation deploy --capabilities CAPABILITY_IAM --no-execute-changeset --s3-bucket moodtracker-cloudformation --stack-name moodtracker --template-file infra/cloudformation.yml
deploy/notifications_send: scripts/cloudformation/lambdas/notifications_send.zip
@aws s3 cp --quiet scripts/cloudformation/lambdas/notifications_send.zip s3://moodtracker-cloudformation/lambdas/notifications_send.zip
@echo "🍄 notifications_send.zip uploaded to S3 successfully! 🍄"
@aws lambda update-function-code --function-name MoodTrackerWebNotificationsSend --s3-bucket moodtracker-cloudformation --s3-key lambdas/notifications_send.zip > /dev/null
@echo "🍄 MoodTrackerWebNotificationsSend lambda updated successfully! 🍄"
# Print this help message
help:
@echo
@awk '/^#/ {c=substr($$0,3); next} c && /^([a-zA-Z].+):/{ print " \033[32m" $$1 "\033[0m",c }{c=0}' $(MAKEFILE_LIST) |\
sort |\
column -s: -t |\
less -R
# Install all dependencies
init: init/ci
@echo "⏳ Installing Python dependencies... ⏳"
@cd scripts && poetry install
@echo "🍄 Python dependencies successfully installed! 🍄"
# Install all Node.js dependencies
init/ci:
@echo "⏳ Installing Node.js dependencies... ⏳"
@cd client && npm i
@echo "🍄 Node.js dependencies successfully installed! 🍄"
# Updates the CloudFormation stack policy
stack-policy:
@aws cloudformation set-stack-policy --stack-name moodtracker --stack-policy-body file://infra/stack-policy.json
@echo "🍄 CloudFormation stack policy updated successfully! 🍄"
# Run the project locally
start:
@cd client && npm start
# Run all tests
test: cloudformation/test
@cd client && npm t && echo "🍄 All tests pass! 🍄"
# Runs all CI tests (CloudFormation checks and e2e tests not yet supported)
test/ci:
@cd client && npm run test-ci && echo "🍄 All tests pass! 🍄"
.PHONY: analytics cleanup_zombie_users cloudformation/test deploy deploy/dry-run deploy/notifications_send help init init/ci stack-policy start test test/ci