Skip to content

Commit da056db

Browse files
authored
adjust README to include notes on Makefiles and the CI (#209)
* adjust README to include notes on Makefiles and the CI * fix header link * fix header link * clarify test-ci target * fix formatting * fix formatting * fix formatting
1 parent 0ad6e8a commit da056db

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,52 @@ git pull origin master
7171
```
7272

7373
The above commands use `sparse-checkout` to only pull the sample you are interested in. You can find the name of the sample directory in the table above.
74+
75+
# Developer Notes
76+
77+
## Makefiles for samples
78+
All samples should have a Makefile to unify the execution of the otherwise heterogeneous samples.
79+
It needs to fulfill two criteria:
80+
- The sample should be executable independently, since it can be checked out on its own (see [Checking out a single sample](#checking-out-a-single-sample)).
81+
- It should contain a `test-ci` target to be executed automatically within the CI pipeline. This step needs to take care of all infrastructure tasks (starting/stopping/logs/etc) in addition to any sample commands executed.
82+
83+
A typical Makefile looks like this:
84+
```bash
85+
export AWS_ACCESS_KEY_ID ?= test
86+
export AWS_SECRET_ACCESS_KEY ?= test
87+
export AWS_DEFAULT_REGION=us-east-1
88+
SHELL := /bin/bash
89+
90+
usage: ## Show this help
91+
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
92+
93+
install: ## Install dependencies
94+
@which localstack || pip install localstack
95+
@which awslocal || pip install awscli-local
96+
## install whatever else you need, like node modules, python packages, etc.
97+
@test -e node_modules || npm install
98+
@test -e .venv || (python3 -m venv .venv; source .venv/bin/activate; pip install -r requirements.txt)
99+
100+
run: ## Run the actual sample steps/commands. This assumes LocalStack is up and running.
101+
./run.sh
102+
103+
start: ## Start LocalStack in detached mode
104+
localstack start -d
105+
106+
stop: ## Stop the Running LocalStack container
107+
@echo
108+
localstack stop
109+
110+
ready: ## Make sure the LocalStack container is up
111+
@echo Waiting on the LocalStack container...
112+
@localstack wait -t 30 && echo LocalStack is ready to use! || (echo Gave up waiting on LocalStack, exiting. && exit 1)
113+
114+
logs: ## Save the logs in a separate file, since the LS container will only contain the logs of the last sample run.
115+
@localstack logs > logs.txt
116+
117+
test-ci: ## Execute the necessary targets in the correct order for an automatic execution.
118+
make start install ready run; return_code=`echo $$?`;\
119+
make logs; make stop; exit $$return_code;
120+
121+
.PHONY: usage install run start stop ready logs test-ci
122+
```

0 commit comments

Comments
 (0)