Skip to content

Commit 508f391

Browse files
committed
chore: add workflow from testing repo
1 parent 261637b commit 508f391

4 files changed

Lines changed: 159 additions & 15 deletions

File tree

.github/workflows/ecr-release.yml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
name: Upload Testing SDK Emulator Image
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
env:
12+
package_path: packages/aws-durable-execution-sdk-python-testing
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+
platform: linux/amd64
29+
- arch: arm64
30+
platform: linux/arm64
31+
32+
steps:
33+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
with:
35+
ref: ${{ github.event.release.tag_name }}
36+
37+
- name: Set up Python
38+
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
39+
with:
40+
python-version: "3.13"
41+
42+
- name: Install Hatch
43+
run: python -m pip install --upgrade hatch==1.16.5
44+
45+
- name: Set up QEMU for multi-platform builds
46+
if: matrix.arch == 'arm64'
47+
uses: docker/setup-qemu-action@v3
48+
with:
49+
platforms: arm64
50+
51+
- name: Build distribution
52+
working-directory: ${{ env.package_path }}
53+
run: hatch build
54+
55+
- name: Get version from __about__.py
56+
id: version
57+
run: |
58+
VERSION=$(grep "^__version__" "${{ env.package_path }}/src/aws_durable_execution_sdk_python_testing/__about__.py" | cut -d'"' -f2)
59+
echo "VERSION=$VERSION"
60+
echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
61+
62+
- name: Configure AWS Credentials
63+
uses: aws-actions/configure-aws-credentials@v4
64+
with:
65+
role-to-assume: ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }}
66+
aws-region: ${{ env.aws_region }}
67+
68+
- name: Login to Amazon ECR
69+
id: login-ecr-public
70+
uses: aws-actions/amazon-ecr-login@v2
71+
with:
72+
registry-type: public
73+
74+
- name: Build, tag, and push image to Amazon ECR
75+
id: build-publish
76+
shell: bash
77+
env:
78+
ECR_REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
79+
ECR_REPOSITORY: ${{ env.ecr_repository_name }}
80+
PER_ARCH_IMAGE_TAG: v${{ steps.version.outputs.VERSION }}-${{ matrix.arch }}
81+
run: |
82+
docker build --platform "${{ matrix.platform }}" --provenance false "${{ env.package_path }}" -f "${{ env.package_path }}/Dockerfile" -t "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
83+
docker push "$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG"
84+
echo "ecr_registry_repository=$ECR_REGISTRY/$ECR_REPOSITORY" >> "$GITHUB_OUTPUT"
85+
echo "full_image_${{ matrix.arch }}=$ECR_REGISTRY/$ECR_REPOSITORY:$PER_ARCH_IMAGE_TAG" >> "$GITHUB_OUTPUT"
86+
87+
create-ecr-manifest-per-arch:
88+
runs-on: ubuntu-latest
89+
needs: [build-and-upload-image-to-ecr]
90+
steps:
91+
- name: Configure AWS Credentials
92+
uses: aws-actions/configure-aws-credentials@v4
93+
with:
94+
role-to-assume: ${{ secrets.ECR_UPLOAD_IAM_ROLE_ARN }}
95+
aws-region: ${{ env.aws_region }}
96+
97+
- name: Login to Amazon ECR
98+
uses: aws-actions/amazon-ecr-login@v2
99+
with:
100+
registry-type: public
101+
102+
- name: Create and push explicit version manifest
103+
run: |
104+
docker manifest create "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
105+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
106+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}"
107+
docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
108+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
109+
--arch arm64 \
110+
--os linux
111+
docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}" \
112+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
113+
--arch amd64 \
114+
--os linux
115+
docker manifest push "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}:v${{ needs.build-and-upload-image-to-ecr.outputs.version }}"
116+
117+
- name: Create and push latest manifest
118+
run: |
119+
docker manifest create "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
120+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
121+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}"
122+
docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
123+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_arm64 }}" \
124+
--arch arm64 \
125+
--os linux
126+
docker manifest annotate "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}" \
127+
"${{ needs.build-and-upload-image-to-ecr.outputs.full_image_x86_64 }}" \
128+
--arch amd64 \
129+
--os linux
130+
docker manifest push "${{ needs.build-and-upload-image-to-ecr.outputs.ecr_registry_repository }}"

.github/workflows/pypi-publish.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
path: packages/aws-durable-execution-sdk-python
2727
- name: aws-durable-execution-sdk-python-otel
2828
path: packages/aws-durable-execution-sdk-python-otel
29+
- name: aws-durable-execution-sdk-python-testing
30+
path: packages/aws-durable-execution-sdk-python-testing
2931

3032
steps:
3133
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -58,6 +60,7 @@ jobs:
5860
package:
5961
- name: aws-durable-execution-sdk-python
6062
- name: aws-durable-execution-sdk-python-otel
63+
- name: aws-durable-execution-sdk-python-testing
6164
permissions:
6265
id-token: write
6366

packages/aws-durable-execution-sdk-python-examples/cli.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,12 @@ def build_examples():
4646
shutil.rmtree(build_dir)
4747
build_dir.mkdir()
4848

49-
# Copy testing library from current environment
50-
try:
51-
import aws_durable_execution_sdk_python_testing
52-
53-
sdk_path = Path(aws_durable_execution_sdk_python_testing.__file__).parent
54-
logger.info("Copying SDK from %s", sdk_path)
55-
shutil.copytree(
56-
sdk_path, build_dir / "aws_durable_execution_sdk_python_testing"
57-
)
58-
except (ImportError, OSError):
59-
logger.exception("Failed to copy testing library")
60-
return False
61-
6249
# Install local packages so their runtime dependencies are included in
6350
# the Lambda deployment package.
6451
runtime_packages = [
6552
packages_dir / "aws-durable-execution-sdk-python",
6653
packages_dir / "aws-durable-execution-sdk-python-otel",
54+
packages_dir / "aws-durable-execution-sdk-python-testing",
6755
]
6856
try:
6957
subprocess.run(

pyproject.toml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"pytest",
1414
"pytest-cov",
1515
"opentelemetry-sdk>=1.20.0",
16-
"aws_durable_execution_sdk_python_testing"
16+
"aws-durable-execution-sdk-python-testing",
1717
]
1818

1919
[tool.hatch.envs.test.scripts]
@@ -27,6 +27,7 @@ addopts = "-v --strict-markers --import-mode=importlib"
2727
testpaths = [
2828
"packages/aws-durable-execution-sdk-python/tests",
2929
"packages/aws-durable-execution-sdk-python-otel/tests",
30+
"packages/aws-durable-execution-sdk-python-testing/tests",
3031
"packages/aws-durable-execution-sdk-python-examples/test",
3132
]
3233
markers = [
@@ -77,11 +78,29 @@ test = "pytest packages/aws-durable-execution-sdk-python-otel/tests {args}"
7778
cov = "pytest --cov-report=term-missing --cov-config=packages/aws-durable-execution-sdk-python-otel/pyproject.toml --cov=packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel packages/aws-durable-execution-sdk-python-otel/tests {args}"
7879
typecheck = "mypy --install-types --non-interactive packages/aws-durable-execution-sdk-python-otel/src/aws_durable_execution_sdk_python_otel packages/aws-durable-execution-sdk-python-otel/tests"
7980

81+
[tool.hatch.envs.dev-testing]
82+
workspace.members = [
83+
"packages/aws-durable-execution-sdk-python",
84+
"packages/aws-durable-execution-sdk-python-testing",
85+
]
86+
dependencies = [
87+
"pytest",
88+
"pytest-cov",
89+
"coverage[toml]",
90+
"mypy>=1.0.0",
91+
]
92+
93+
[tool.hatch.envs.dev-testing.scripts]
94+
test = "pytest packages/aws-durable-execution-sdk-python-testing/tests {args}"
95+
cov = "pytest --cov-report=term-missing --cov-config=packages/aws-durable-execution-sdk-python-testing/pyproject.toml --cov=packages/aws-durable-execution-sdk-python-testing/src/aws_durable_execution_sdk_python_testing --cov-fail-under=95 packages/aws-durable-execution-sdk-python-testing/tests {args}"
96+
typecheck = "mypy --install-types --non-interactive packages/aws-durable-execution-sdk-python-testing/src/aws_durable_execution_sdk_python_testing packages/aws-durable-execution-sdk-python-testing/tests"
97+
8098
[tool.hatch.envs.dev-examples]
8199
workspace.members = [
82100
"packages/aws-durable-execution-sdk-python",
83101
"packages/aws-durable-execution-sdk-python-examples",
84102
"packages/aws-durable-execution-sdk-python-otel",
103+
"packages/aws-durable-execution-sdk-python-testing",
85104
]
86105
dependencies = [
87106
"pytest",
@@ -149,7 +168,11 @@ preview = true
149168
select = ["TID252"] # Enforce absolute imports (ban relative imports)
150169

151170
[tool.ruff.lint.isort]
152-
known-first-party = ["aws_durable_execution_sdk_python", "aws_durable_execution_sdk_python_otel"]
171+
known-first-party = [
172+
"aws_durable_execution_sdk_python",
173+
"aws_durable_execution_sdk_python_otel",
174+
"aws_durable_execution_sdk_python_testing",
175+
]
153176
force-single-line = false
154177
lines-after-imports = 2
155178

0 commit comments

Comments
 (0)