Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
88 lines (64 loc) · 3.89 KB
/
Copy pathMakefile
File metadata and controls
88 lines (64 loc) · 3.89 KB
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
# Serverlesspresso with Lambda durable functions on LocalStack.
# Run `make` to list the targets. Each target prints the commands it runs.
# lstk reads .lstk/config.toml when it runs from this directory.
SHELL := /bin/bash
STACK ?= durable-serverlesspresso
FRONTEND_URL ?= http://durable-serverlesspresso-frontend.s3-website.localhost.localstack.cloud:4566
# Set TIMEOUTS=15 to shorten the barista acceptance and completion timeouts (default 120 s)
TIMEOUTS ?=
export STACK FRONTEND_URL
export STACK_NAME := $(STACK)
output = $(shell lstk --non-interactive aws cloudformation describe-stacks --stack-name $(STACK) --query "Stacks[0].Outputs[?OutputKey=='$(1)'].OutputValue" --output text 2>/dev/null)
FUNCTION = $(call output,DurableFunctionName)
LATEST_EXECUTION = $(shell lstk --non-interactive aws lambda list-durable-executions-by-function --function-name $(FUNCTION) --query 'sort_by(DurableExecutions,&StartTimestamp)[-1].DurableExecutionArn' --output text 2>/dev/null)
.DEFAULT_GOAL := help
.PHONY: help install start stop status build deploy frontend urls executions history \
test-unit test test-ui test-all reset restart-demo destroy running deployed
help: ## List the targets
@grep -E '^[a-z-]+:.*## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "} {printf " make %-14s %s\n", $$1, $$2}'
install: ## Install the frontend and test dependencies
cd frontend && npm install
cd src/coffee-orders && npm install
cd tests && npm install && npx playwright install chromium
start: ## Start LocalStack
lstk start
stop: ## Stop LocalStack
lstk stop
status: ## Show the emulator and the deployed resources
lstk status
# Checks that run before the targets that need them
running:
@lstk --non-interactive status >/dev/null 2>&1 || { echo "LocalStack is not running. Run 'make start' first."; exit 1; }
deployed: running
@lstk --non-interactive aws cloudformation describe-stacks --stack-name $(STACK) >/dev/null 2>&1 || { echo "The $(STACK) stack is not deployed. Run 'make deploy' first."; exit 1; }
build: ## Build the Lambda functions with SAM
lstk sam build
deploy: running build ## Deploy the stack and open the coffee shop
lstk sam deploy --template-file .aws-sam/build/template.yaml --stack-name $(STACK) --resolve-s3 --capabilities CAPABILITY_IAM --no-confirm-changeset --no-fail-on-empty-changeset$(if $(TIMEOUTS), --parameter-overrides AcceptanceTimeoutSeconds=$(TIMEOUTS) CompletionTimeoutSeconds=$(TIMEOUTS))
scripts/seed-config.sh
frontend: deployed ## Build the Vue frontend and host it on an S3 website
scripts/deploy-frontend-s3.sh
@$(MAKE) --no-print-directory urls
urls: ## Print the attendee and barista URLs
@echo "Attendee: $(FRONTEND_URL)/attendee"
@echo "Barista: $(FRONTEND_URL)/barista"
executions: deployed ## List the durable executions of the order workflow
lstk aws lambda list-durable-executions-by-function --function-name $(FUNCTION) --query 'DurableExecutions[].[DurableExecutionName,Status]' --output table
history: deployed ## Show the event history of the latest durable execution
lstk aws lambda get-durable-execution-history --durable-execution-arn $(LATEST_EXECUTION) --query 'Events[].[EventType,Name]' --output table
test-unit: ## Run the unit tests (durable SDK test runner, no LocalStack needed)
cd src/coffee-orders && npx jest
test: deployed ## Run the integration tests against LocalStack
cd tests && npm test
test-ui: reset ## Run the Playwright test against the S3 website
cd tests && npx playwright test
test-all: ## Deploy with 15 s timeouts and run every test
$(MAKE) deploy TIMEOUTS=15
$(MAKE) frontend test-unit test test-ui
reset: deployed ## Delete all orders and open the store
scripts/reset-demo.sh
restart-demo: deployed ## Show an order surviving `lstk restart` (needs persistence on)
scripts/demo-restart.sh
destroy: ## Delete the stack
lstk aws cloudformation delete-stack --stack-name $(STACK)
lstk aws cloudformation wait stack-delete-complete --stack-name $(STACK)