Skip to content

Commit 1cd7468

Browse files
SilanHehsilan
andauthored
feat: publish emulator image directly from testing library (#196)
Create emulator image from the python testing library. The image tag will be the aws-durable-sdk-python-testing version with v prefixing it, e.g. v1.1.1. --------- Co-authored-by: hsilan <hsilan@amazon.com>
1 parent 029a324 commit 1cd7468

5 files changed

Lines changed: 180 additions & 1 deletion

File tree

.github/workflows/deploy-examples.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ jobs:
6262

6363
- name: Install Hatch
6464
run: pip install hatch
65-
6665
- name: Build examples
6766
run: hatch run examples:build
6867

.github/workflows/ecr-release.yml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
name: ecr-release.yml
2+
on:
3+
release:
4+
types: [published]
5+
6+
permissions:
7+
contents: read
8+
id-token: write # This is required for requesting the JWT
9+
10+
env:
11+
path_to_dockerfile: "Dockerfile"
12+
docker_build_dir: "."
13+
aws_region: "us-east-1"
14+
ecr_repository_name: "durable-functions/aws-durable-execution-emulator"
15+
16+
jobs:
17+
build-and-upload-image-to-ecr:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
full_image_arm64: ${{ steps.build-publish.outputs.full_image_arm64 }}
21+
full_image_x86_64: ${{ steps.build-publish.outputs.full_image_x86_64 }}
22+
ecr_registry_repository: ${{ steps.build-publish.outputs.ecr_registry_repository }}
23+
version: ${{ steps.version.outputs.VERSION }}
24+
strategy:
25+
matrix:
26+
include:
27+
- arch: x86_64
28+
- arch: arm64
29+
steps:
30+
- uses: actions/checkout@v6
31+
- name: Set up Python
32+
uses: actions/setup-python@v6
33+
with:
34+
python-version: "3.13"
35+
- name: Install dependencies
36+
run: |
37+
python -m pip install --upgrade pip
38+
pip install hatch
39+
- name: Set up QEMU for multi-platform builds
40+
if: matrix.arch == 'arm64'
41+
uses: docker/setup-qemu-action@v3
42+
with:
43+
platforms: arm64
44+
- name: Build distribution
45+
run: hatch build
46+
- name: Get version from __about__.py
47+
id: version
48+
run: |
49+
VERSION=$(grep "^__version__" src/aws_durable_execution_sdk_python_testing/__about__.py | cut -d'"' -f2)
50+
echo "VERSION=$VERSION"
51+
echo "VERSION=${VERSION}" >> $GITHUB_OUTPUT
52+
- name: Configure AWS Credentials
53+
uses: aws-actions/configure-aws-credentials@v4
54+
with:
55+
role-to-assume: ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }}
56+
aws-region: ${{ env.aws_region }}
57+
- name: Login to Amazon ECR
58+
id: login-ecr-public
59+
uses: aws-actions/amazon-ecr-login@v2
60+
with:
61+
registry-type: public
62+
- name: Build, tag, and push image to Amazon ECR
63+
id: build-publish
64+
shell: bash
65+
env:
66+
ECR_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
67+
ECR_REPOSITORY: ${{ env.ecr_repository_name }}
68+
PER_ARCH_IMAGE_TAG: "v${{ steps.version.outputs.VERSION }}-${{ matrix.arch }}"
69+
run: |
70+
if [ "${{ matrix.arch }}" = "x86_64" ]; then
71+
docker build --platform linux/amd64 --provenance false "${{ env.docker_build_dir }}" -f "${{ env.path_to_dockerfile }}" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
72+
else
73+
docker build --platform linux/arm64 --provenance false "${{ env.docker_build_dir }}" -f "${{ env.path_to_dockerfile }}" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
74+
fi
75+
docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
76+
echo "IMAGE $PER_ARCH_IMAGE_TAG is pushed to $ECR_REGISTRY/$ECR_REPOSITORY"
77+
echo "image_tag=$PER_ARCH_IMAGE_TAG"
78+
echo "full_image=$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
79+
echo "ecr_registry_repository=$ECR_REGISTRY/$ECR_REPOSITORY" >> $GITHUB_OUTPUT
80+
echo "full_image_${{ matrix.arch }}=$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG" >> $GITHUB_OUTPUT
81+
create-ecr-manifest-per-arch:
82+
runs-on: ubuntu-latest
83+
needs: [build-and-upload-image-to-ecr]
84+
steps:
85+
- name: Grab image, registry/repository name, version from previous steps
86+
id: ecr_names
87+
env:
88+
ECR_REGISTRY_REPOSITORY: ${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}
89+
FULL_IMAGE_ARM64: ${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}
90+
FULL_IMAGE_X86_64: ${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}
91+
VERSION: ${{ needs.build-and-upload-image-to-ecr.outputs.version }}
92+
run: |
93+
echo "full_image_arm64=$FULL_IMAGE_ARM64"
94+
echo "ecr_registry_repository=$ECR_REGISTRY_REPOSITORY"
95+
echo "full_image_x86_64=$FULL_IMAGE_X86_64"
96+
echo "version=$VERSION"
97+
- name: Configure AWS Credentials
98+
uses: aws-actions/configure-aws-credentials@v4
99+
with:
100+
role-to-assume: ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }}
101+
aws-region: ${{ env.aws_region }}
102+
- name: Login to Amazon ECR
103+
id: login-ecr-public
104+
uses: aws-actions/amazon-ecr-login@v2
105+
with:
106+
registry-type: public
107+
- name: Create ECR manifest with explicit tag
108+
id: create-ecr-manifest-explicit
109+
run: |
110+
docker manifest create "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
111+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
112+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}"
113+
- name: Annotate ECR manifest with explicit arm64 tag
114+
id: annotate-ecr-manifest-explicit-arm64
115+
run: |
116+
docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
117+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
118+
--arch arm64 \
119+
--os linux
120+
- name: Annotate ECR manifest with explicit amd64 tag
121+
id: annotate-ecr-manifest-explicit-amd64
122+
run: |
123+
docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
124+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
125+
--arch amd64 \
126+
--os linux
127+
- name: Push ECR manifest with explicit version
128+
id: push-ecr-manifest-explicit
129+
run: |
130+
docker manifest push "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}"
131+
- name: Create ECR manifest with latest tag
132+
id: create-ecr-manifest-latest
133+
run: |
134+
docker manifest create "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
135+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
136+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}"
137+
- name: Annotate ECR manifest with latest tag arm64
138+
id: annotate-ecr-manifest-latest-arm64
139+
run: |
140+
docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
141+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
142+
--arch arm64 \
143+
--os linux
144+
- name: Annotate ECR manifest with latest tag amd64
145+
id: annotate-ecr-manifest-latest-amd64
146+
run: |
147+
docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
148+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
149+
--arch amd64 \
150+
--os linux
151+
- name: Push ECR manifest with latest
152+
id: push-ecr-manifest-latest
153+
run: |
154+
docker manifest push "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}"

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,6 @@ dist/
3535

3636
examples/build/*
3737
examples/*.zip
38+
39+
durable-executions.db*
40+
.coverage

Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM python:3.13-slim
2+
3+
# Copy and install the wheel
4+
COPY dist/*.whl /tmp/
5+
RUN pip install --no-cache-dir /tmp/*.whl && rm -rf /tmp/*.whl
6+
7+
# AWS credentials (required for boto3)
8+
ENV AWS_ACCESS_KEY_ID=foo \
9+
AWS_SECRET_ACCESS_KEY=bar \
10+
AWS_DEFAULT_REGION=us-east-1
11+
12+
EXPOSE 9014
13+
14+
CMD ["dex-local-runner", "start-server", \
15+
"--host", "0.0.0.0", \
16+
"--port", "9014", \
17+
"--log-level", "DEBUG", \
18+
"--lambda-endpoint", "http://host.docker.internal:3001", \
19+
"--store-type", "sqlite", \
20+
"--store-path", "/tmp/.durable-executions-local/durable-executions.db"]

src/aws_durable_execution_sdk_python_testing/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
WebRunnerConfig,
1010
)
1111

12+
from aws_durable_execution_sdk_python_testing.__about__ import __version__
13+
1214

1315
__all__ = [
1416
"DurableChildContextTestRunner",
@@ -17,4 +19,5 @@
1719
"DurableFunctionTestRunner",
1820
"WebRunner",
1921
"WebRunnerConfig",
22+
"__version__",
2023
]

0 commit comments

Comments
 (0)