Skip to content

Commit a43607c

Browse files
authored
Merge pull request #11 from f34nk/migrate/localstack
Refactor aws-demo to use LocalStack instead of Moto
2 parents 999f1ce + c7059fd commit a43607c

File tree

18 files changed

+95
-1509
lines changed

18 files changed

+95
-1509
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: CI
22

33
env:
44
SMITHY_VERSION: 1.64.0
5+
TERRAFORM_VERSION: 1.10.3
56

67
on:
78
push:
@@ -47,12 +48,26 @@ jobs:
4748
cd smithy-cli-linux-x86_64 && ./install --install-dir /usr/local/bin/
4849
smithy --version
4950
51+
# - name: Install Terraform
52+
# uses: hashicorp/setup-terraform@v3
53+
# with:
54+
# terraform_version: ${{ env.TERRAFORM_VERSION }}
55+
5056
- name: Make Gradle wrapper executable
5157
run: chmod +x gradlew
5258

5359
- name: Run make
5460
run: make
5561

62+
# Compiling unison code in CI requires too much memory
63+
# so we're skipping it for now.
64+
65+
# - name: Run demo (generated code against LocalStack)
66+
# run: make demo
67+
68+
# - name: Run integration test (Unison Share libs against LocalStack)
69+
# run: make integration-test
70+
5671
- name: Upload build artifacts
5772
if: failure()
5873
uses: actions/upload-artifact@v4

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ demo: clean build
7575
# Run the examples/aws-demo against a mocked S3 bucket
7676
#
7777
cd examples/aws-demo && \
78-
make docker/test
78+
make test
7979

8080
.PHONY: integration-test
8181
integration-test:
@@ -84,4 +84,4 @@ integration-test:
8484
# run the examples/aws-demo against a mocked S3 bucket
8585
#
8686
cd examples/aws-demo && \
87-
make docker/integration-test
87+
make integration-test

examples/aws-demo/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
# Build artifacts
55
build/
66
model/*.json
7+
8+
.terraform*
9+
terraform.tfstate*

examples/aws-demo/Dockerfile

Lines changed: 0 additions & 53 deletions
This file was deleted.

examples/aws-demo/Makefile

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# AWS S3 Demo Makefile
2-
# UCM is installed locally via compile.sh (same version as Docker)
2+
# UCM is installed locally via install.sh
33

44
UCM_VERSION ?= 1.0.0
55

66
.PHONY: all
7-
all: generate
7+
all: clean generate
88

99
.PHONY: generate
10-
generate: clean
11-
#
12-
# Download S3 model from AWS SDKs: https://github.com/aws/api-models-aws/blob/main/models/s3/service/2006-03-01/s3-2006-03-01.json
13-
#
14-
wget https://raw.githubusercontent.com/aws/api-models-aws/refs/heads/main/models/s3/service/2006-03-01/s3-2006-03-01.json
15-
mv s3-2006-03-01.json model/
10+
generate: model/s3-2006-03-01.json
1611
#
1712
# Generate Unison code from Smithy model
1813
#
@@ -24,6 +19,10 @@ clean:
2419
rm -rf generated/*.u ./build
2520
rm -f compiled/main.uc
2621
rm -f model/*.json
22+
rm -rf terraform/.terraform
23+
rm -f terraform/.terraform.lock.hcl
24+
rm -f terraform/terraform.tfstate
25+
rm -f terraform/terraform.tfstate.backup
2726

2827
.PHONY: install
2928
install:
@@ -46,23 +45,47 @@ compile-with-lib: install
4645
#
4746
./compile-with-lib.sh
4847

49-
.PHONY: docker/test
50-
docker/test: compile docker/clean
48+
.PHONY: test
49+
test: compiled/main.uc docker/start terraform
5150
#
52-
# Run compiled code in Docker Compose
51+
# Run compiled Unison code against LocalStack
5352
#
54-
UCM_VERSION=$(UCM_VERSION) docker compose build
55-
docker compose run --rm test
53+
./demo.sh
5654

57-
.PHONY: docker/integration-test
58-
docker/integration-test: compile-with-lib docker/clean
55+
.PHONY: integration-test
56+
integration-test: compile-with-lib docker/start terraform
5957
#
6058
# Run compiled code in Docker Compose
6159
#
62-
UCM_VERSION=$(UCM_VERSION) docker compose build
63-
docker compose run --rm test
60+
./demo.sh
61+
62+
# make sure model/s3-2006-03-01.json is available
63+
model/s3-2006-03-01.json:
64+
#
65+
# Download S3 model from AWS SDKs: https://github.com/aws/api-models-aws/blob/main/models/s3/service/2006-03-01/s3-2006-03-01.json
66+
#
67+
wget https://raw.githubusercontent.com/aws/api-models-aws/refs/heads/main/models/s3/service/2006-03-01/s3-2006-03-01.json
68+
mv s3-2006-03-01.json model/
69+
70+
# make sure compiled/main.uc is up to date
71+
compiled/main.uc:
72+
make compile
73+
74+
.PHONY: terraform
75+
terraform:
76+
#
77+
# Run Terraform to create the S3 bucket
78+
#
79+
cd terraform && terraform init && terraform apply -auto-approve
80+
81+
.PHONY: docker/start
82+
docker/start: docker/stop
83+
#
84+
# Run LocalStack in Docker
85+
#
86+
docker run --rm -d -p 4566:4566 -e SERVICES=s3 --name localstack localstack/localstack
6487

65-
.PHONY: docker/clean
66-
docker/clean:
67-
docker compose down --volumes --remove-orphans
68-
docker compose rm --stop --force 2>/dev/null || true
88+
.PHONY: docker/stop
89+
docker/stop:
90+
docker stop localstack &> /dev/null || true
91+
docker rm localstack &> /dev/null || true

examples/aws-demo/compose/moto/Dockerfile

Lines changed: 0 additions & 29 deletions
This file was deleted.

examples/aws-demo/compose/moto/Makefile

Lines changed: 0 additions & 7 deletions
This file was deleted.

examples/aws-demo/compose/moto/entrypoint.sh

Lines changed: 0 additions & 5 deletions
This file was deleted.

examples/aws-demo/compose/moto/pyproject.toml

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)