Skip to content

Commit

Permalink
extend the hello-world example and turn it into a test
Browse files Browse the repository at this point in the history
  • Loading branch information
tavisrudd committed Aug 3, 2017
1 parent 1d6d389 commit 4fd826c
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 13 deletions.
11 changes: 11 additions & 0 deletions Dockerfile.test
@@ -0,0 +1,11 @@
FROM ubuntu
RUN apt-get update && \
apt-get install -y make

COPY iidy /usr/local/bin
COPY examples/ /root/examples
COPY Makefile /root/Makefile
WORKDIR /root/

ENV AWS_PROFILE sandbox
ENV AWS_REGION us-west-2
27 changes: 19 additions & 8 deletions Makefile
@@ -1,11 +1,13 @@
rfind = $(shell find '$(1)' -name '$(2)')

SRC_FILES := Makefile \
src/index.ts \
# TODO add this back in: Makefile
SRC_FILES := src/index.ts \
$(call rfind,src,[^.]*.ts) \
$(call rfind,src,[^.]*.js) \
$(call rfind,src,[^.]*.json)

EXAMPLE_FILES = $(shell find examples/ -type f)

PREREQS_STATEFILE = .make/done_prereqs
DEPS_STATEFILE = .make/done_deps
TESTS_STATEFILE = .make/done_tests
Expand Down Expand Up @@ -59,12 +61,21 @@ $(BUILD_ARTIFACTS) : $(DEPS_STATEFILE) $(SRC_FILES)


# TODO expand this
$(TESTS_STATEFILE) : $(BUILD_ARTIFACTS)
ifeq ($(shell uname),Darwin)
dist/iidy-macos help
else
dist/iidy-linux help
endif
$(TESTS_STATEFILE) : $(BUILD_ARTIFACTS) $(EXAMPLE_FILES)
mkdir -p dist/docker/
cp dist/iidy-linux dist/docker/iidy
cp Dockerfile.test dist/docker/Dockerfile
cp Makefile.test dist/docker/Makefile
cp -a examples dist/docker/
docker build -t iidy-test dist/docker
docker run --rm -v ~/.aws/:/root/.aws/ iidy-test make test
touch $(TESTS_STATEFILE)

# ifeq ($(shell uname),Darwin)
# dist/iidy-macos help
# else
# dist/iidy-linux help
# endif

check_working_dir_is_clean :
git diff --quiet --ignore-submodules HEAD
10 changes: 10 additions & 0 deletions Makefile.test
@@ -0,0 +1,10 @@
.PHONY : test

.DEFAULT_GOAL := test

test:
@iidy help > /dev/null
@cd examples/hello-world/ && make test
# iidy list-stacks
# iidy create-stack examples/hello-world/stack-args.yaml
# iidy list-stacks --region us-east-1
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -233,7 +233,7 @@ $ cat stack-args.yaml
StackName: iidy-demo
Template: ./cfn-template.yaml # details are irrelevant for the demo
Tags:
owner: tavis
owner: your-name
project: iidy-demo
environment: development
lifetime: short
Expand All @@ -245,7 +245,7 @@ $ iidy list-stacks | grep iidy-demo
Wed Aug 02 2017 00:41:49 CREATE_COMPLETE iidy-demo owner=tavis, environment=development, lifetime=short, project=iidy-demo
# edit something in stack-args to demo a simple update-stack
sed s/tavis/Tavis/ stack-args.yaml > stack-args2.yaml
sed s/your-name/Tavis/ stack-args.yaml > stack-args2.yaml
$ iidy update-stack stack-args2.yaml
# ... lots of useful output about what iidy and CloudFormation are doing ...
Expand Down
4 changes: 4 additions & 0 deletions examples/hello-world/.wrap-bash
@@ -0,0 +1,4 @@
#!/bin/bash
echo -e "\033[91mEXECUTING: \033[96m $* \033[0m"

$*
20 changes: 20 additions & 0 deletions examples/hello-world/Makefile
@@ -0,0 +1,20 @@
.PHONY : test

.DEFAULT_GOAL := test

test:
@mkdir -p demo-tmp/
@iidy render stack-args.yaml > demo-tmp/stack-args.yaml
@grep StackName demo-tmp/stack-args.yaml | cut -f 2 -d':' > demo-tmp/stack-name
@cp cfn-template.yaml demo-tmp/

@./.wrap-bash iidy create-stack demo-tmp/stack-args.yaml

@./.wrap-bash iidy list-stacks --region us-west-2 --profile sandbox | grep $$(cat demo-tmp/stack-name)

@./.wrap-bash sed -i.bak s/your-name/Tavis/ demo-tmp/stack-args.yaml
@./.wrap-bash iidy update-stack demo-tmp/stack-args.yaml

@./.wrap-bash iidy delete-stack --region us-west-2 --profile sandbox --yes $$(cat demo-tmp/stack-name)

@rm -r demo-tmp
5 changes: 4 additions & 1 deletion examples/hello-world/cfn-template.yaml
@@ -1,5 +1,8 @@
Parameters:
Name:
Type: String
Resources:
HelloWorld:
Type: AWS::SNS::Topic
Properties:
DisplayName: HelloWorldIIDY
DisplayName: !Sub "Hello ${Name}}"
14 changes: 12 additions & 2 deletions examples/hello-world/stack-args.yaml
@@ -1,7 +1,17 @@
StackName: iidy-demo
$imports:
nameSuffix: random:dashed-name

StackName: iidy-demo-{{nameSuffix}}
Template: ./cfn-template.yaml # details are irrelevant for the demo

Profile: sandbox
Region: us-west-2

Parameters:
Name: world

Tags:
owner: tavis
owner: your-name
project: iidy-demo
environment: development
lifetime: short

0 comments on commit 4fd826c

Please sign in to comment.