-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
50 lines (41 loc) · 1.39 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
STACK_NAME ?= rust-products
FUNCTIONS := get-products get-product put-product delete-product dynamodb-streams
ARCH := aarch64-unknown-linux-gnu
ARCH_SPLIT = $(subst -, ,$(ARCH))
.PHONY: build deploy tests
all: build tests-unit deploy tests-integ
ci: build tests-unit
setup:
ifeq (,$(shell which rustc))
$(error "Could not found Rust compiler, please install it")
endif
ifeq (,$(shell which cargo))
$(error "Could not found Cargo, please install it")
endif
ifeq (,$(shell which zig))
$(error "Could not found Zig compiler, please install it")
endif
cargo install cargo-lambda
ifeq (,$(shell which sam))
$(error "Could not found SAM CLI, please install it")
endif
ifeq (,$(shell which artillery))
$(error "Could not found Artillery, it's required for load testing")
endif
build:
cargo lambda build --release --target $(ARCH)
deploy:
if [ -f samconfig.toml ]; \
then sam deploy --stack-name $(STACK_NAME); \
else sam deploy -g --stack-name $(STACK_NAME); \
fi
tests-unit:
cargo test --lib --bins
tests-integ:
RUST_BACKTRACE=1 API_URL=$$(aws cloudformation describe-stacks --stack-name $(STACK_NAME) \
--query 'Stacks[0].Outputs[?OutputKey==`ApiUrl`].OutputValue' \
--output text) cargo test
tests-load:
API_URL=$$(aws cloudformation describe-stacks --stack-name $(STACK_NAME) \
--query 'Stacks[0].Outputs[?OutputKey==`ApiUrl`].OutputValue' \
--output text) artillery run tests/load-test.yml