Skip to content

Commit ac76913

Browse files
authored
Add workflows for cloudpod release + testing (#9)
1 parent 6ae08e9 commit ac76913

File tree

4 files changed

+215
-2
lines changed

4 files changed

+215
-2
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
on:
2+
workflow_dispatch:
3+
inputs:
4+
release-tag:
5+
type: string
6+
required: true
7+
description: This will be the version of the release, but will also be used as 'tag' for the localstack docker image
8+
push:
9+
paths-ignore:
10+
- 'README.md'
11+
branches:
12+
- main
13+
14+
permissions:
15+
contents: write
16+
17+
name: Create Release
18+
jobs:
19+
release:
20+
name: Create Release for Cloud Pod
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v2
25+
26+
- name: Set up Python 3.9
27+
id: setup-python
28+
uses: actions/setup-python@v2
29+
with:
30+
python-version: 3.9
31+
32+
- name: Set up Project
33+
run: |
34+
pip install -r requirements-dev.txt
35+
36+
- name: Start LocalStack
37+
env:
38+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
39+
run: |
40+
pip install localstack awscli-local[ver1]
41+
docker pull localstack/localstack-pro:${{ inputs.release-tag || 'latest'}}
42+
# Start LocalStack in the background
43+
localstack start -d
44+
# Wait 30 seconds for the LocalStack container to become ready before timing out
45+
echo "Waiting for LocalStack startup..."
46+
localstack wait -t 30
47+
echo "Startup complete"
48+
49+
- name: Deploy infrastructure
50+
run: |
51+
bin/deploy.sh
52+
53+
- name: Run Tests
54+
env:
55+
AWS_DEFAULT_REGION: us-east-1
56+
AWS_REGION: us-east-1
57+
AWS_ACCESS_KEY_ID: test
58+
AWS_SECRET_ACCESS_KEY: test
59+
run: |
60+
pytest tests
61+
62+
- name: Save the Cloud Pod
63+
uses: HarshCasper/cloud-pod-save@v0.1.0
64+
with:
65+
name: 'release-pod.zip'
66+
location: 'disk'
67+
68+
- name: Prepare Release Notes
69+
run: |
70+
echo "This release includes the Cloud Pod of the sample created with LocalStack Version \`${{ inputs.release-tag || 'latest'}}\`." > Release.txt
71+
echo "You can download the \`release-pod.zip\` and inject it manually by running \`localstack pod load file://release-pod.zip\`, or use the Cloud Pods Launchpad." >> Release.txt
72+
echo "### Cloud Pods Launchpad" >> Release.txt
73+
echo "You can click the Launchpad to inject the the pod into your running LocalStack instance using the WebUI:" >> Release.txt
74+
echo "[![LocalStack Pods Launchpad](https://localstack.cloud/gh/launch-pod-badge.svg)](https://app.localstack.cloud/launchpad?url=https://github.com/$GITHUB_REPOSITORY/releases/download/${{ inputs.release-tag || 'latest'}}/release-pod.zip)" >> Release.txt
75+
76+
- name: Create Release
77+
id: create_release
78+
uses: softprops/action-gh-release@v1
79+
with:
80+
tag_name: "${{ inputs.release-tag || 'latest'}}"
81+
name: "Cloud Pod for LocalStack Version '${{ inputs.release-tag || 'latest'}}'"
82+
body_path: ./Release.txt
83+
files: |
84+
./release-pod.zip

.github/workflows/integration-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
4747
run: |
4848
pip install localstack awscli-local[ver1]
49-
docker pull localstack/localstack
49+
docker pull localstack/localstack-pro
5050
# Start LocalStack in the background
5151
LS_LOG=trace localstack start -d
5252
# Wait 30 seconds for the LocalStack container to become ready before timing out

.github/workflows/test_cloudpods.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Test Released Cloud Pods
2+
3+
on:
4+
schedule:
5+
# “At 00:00 on Saturday.”
6+
- cron: "0 0 * * 6"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
get-releases:
14+
name: Retrieve Released Cloud Pods
15+
runs-on: ubuntu-latest
16+
outputs:
17+
matrix: ${{ steps.set-matrix.outputs.matrix }}
18+
steps:
19+
- id: set-matrix
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
run: |
23+
output=$(gh api repos/$GITHUB_REPOSITORY/releases | jq -r '[.[] | select(.tag_name|startswith("v")|not) | .tag_name]')
24+
output=$(echo $output | tr '\n' ' ')
25+
echo "matrix=$output" >> $GITHUB_OUTPUT
26+
27+
test-pod-release:
28+
needs: get-releases
29+
runs-on: ubuntu-latest
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
tag: ${{ fromJson(needs.get-releases.outputs.matrix) }}
34+
steps:
35+
# checkout to run the tests later on
36+
- name: Checkout
37+
uses: actions/checkout@v3
38+
39+
- name: Retrieve Pod
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
run: |
43+
# TODO the download url seems to follow the pattern $GITHUB_REPOSITORY/releases/download/{TAG}/{ASSET_NAME}
44+
# alternatively we can query the asset-id, and browser_download_url, but it seems like an overhead
45+
# asset_id=$(gh api repos/$GITHUB_REPOSITORY/releases/tags/latest | jq -r '.assets[]' | jq --arg DB $DB -c 'select(.name=="release-pod-\( $DB ).zip") | .id)
46+
# download_url=$(gh api repos/$GITHUB_REPOSITORY/releases/assets/$asset_id | jq -r ".browser_download_url")
47+
download_url="https://github.com/$GITHUB_REPOSITORY/releases/download/${{ matrix.tag }}/release-pod.zip"
48+
curl -L $download_url --output release-pod.zip
49+
ls -la
50+
51+
- name: Setup Python
52+
uses: actions/setup-python@v4
53+
with:
54+
python-version: '3.9'
55+
56+
- name: Start LocalStack
57+
env:
58+
DEBUG: 1
59+
POD_LOAD_CLI_TIMEOUT: 300
60+
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
61+
run: |
62+
pip install localstack awscli-local[ver1]
63+
docker pull localstack/localstack-pro:${{ matrix.tag }}
64+
# Start LocalStack in the background
65+
localstack start -d
66+
# Wait 30 seconds for the LocalStack container to become ready before timing out
67+
echo "Waiting for LocalStack startup..."
68+
localstack wait -t 30
69+
echo "Startup complete"
70+
71+
- name: Inject Pod
72+
run: |
73+
localstack pod load file://release-pod.zip
74+
75+
- name: Run Tests
76+
env:
77+
AWS_DEFAULT_REGION: us-east-1
78+
AWS_REGION: us-east-1
79+
AWS_ACCESS_KEY_ID: test
80+
AWS_SECRET_ACCESS_KEY: test
81+
run: |
82+
pip install -r requirements-dev.txt
83+
pytest tests
84+
85+
- name: Show Logs
86+
if: failure()
87+
run: |
88+
localstack logs
89+
90+
- name: Send a Slack notification
91+
if: failure() || github.event_name != 'pull_request'
92+
uses: ravsamhq/notify-slack-action@v2
93+
with:
94+
status: ${{ job.status }}
95+
token: ${{ secrets.GITHUB_TOKEN }}
96+
notification_title: "{workflow} has {status_message}"
97+
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}>"
98+
footer: "Linked Repo <{repo_url}|{repo}> | <{run_url}|View Workflow run>"
99+
notify_when: "failure"
100+
env:
101+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
102+
103+
- name: Prevent Workflows from getting Stale
104+
if: always()
105+
uses: gautamkrishnar/keepalive-workflow@v1
106+
with:
107+
# this message should prevent automatic triggering of workflows
108+
# see https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
109+
commit_message: "[skip ci] Automated commit by Keepalive Workflow to keep the repository active"

README.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Serverless image resizer
22

3-
[![LocalStack Pods Launchpad](https://localstack.cloud/gh/launch-pod-badge.svg)](https://app.localstack.cloud/launchpad?url=https://github.com/localstack/serverless-image-resizer/releases/download/v1.0.0/serverless-image-resizer-cloudpod-v1.0.0.zip)
3+
[![LocalStack Pods Launchpad](https://localstack.cloud/gh/launch-pod-badge.svg)](https://app.localstack.cloud/launchpad?url=https://github.com/localstack/sample-serverless-image-resizer-s3-lambda/releases/download/latest/release-pod.zip)
44

55
| Key | Value |
66
|--------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
@@ -243,3 +243,23 @@ deploys the infrastructure to it, and then runs the integration tests.
243243

244244
We appreciate your interest in contributing to our project and are always looking for new ways to improve the developer experience. We welcome feedback, bug reports, and even feature ideas from the community.
245245
Please refer to the [contributing file](CONTRIBUTING.md) for more details on how to get started.
246+
247+
## Cloud Pods
248+
249+
[Cloud Pods](https://docs.localstack.cloud/user-guide/tools/cloud-pods/) are a mechanism that allows you to take a snapshot of the state in your current LocalStack instance, persist it to a storage backend, and easily share it with your team members.
250+
251+
You can convert your current AWS infrastructure state to a Cloud Pod using the `localstack` CLI.
252+
Check out our [Getting Started guide](https://docs.localstack.cloud/user-guide/tools/cloud-pods/getting-started/) and [LocalStack Cloud Pods CLI reference](https://docs.localstack.cloud/user-guide/tools/cloud-pods/pods-cli/) to learn more about Cloud Pods and how to use them.
253+
254+
To inject a Cloud Pod you can use [Cloud Pods Launchpad](https://docs.localstack.cloud/user-guide/tools/cloud-pods/launchpad/) wich quickly injects Cloud Pods into your running LocalStack container.
255+
256+
Click here [![LocalStack Pods Launchpad](https://localstack.cloud/gh/launch-pod-badge.svg)](https://app.localstack.cloud/launchpad?url=https://github.com/localstack/sample-serverless-image-resizer-s3-lambda/releases/download/latest/release-pod.zip) to launch the Cloud Pods Launchpad and inject the Cloud Pod for this application by clicking the `Inject` button.
257+
258+
259+
Alternatively, you can inject the pod by using the `localstack` CLI.
260+
First, you need to download the pod you want to inject from the [releases](https://github.com/localstack/sample-serverless-image-resizer-s3-lambda/releases).
261+
Then run:
262+
263+
```sh
264+
localstack pod load file://$(pwd)/release-pod.zip
265+
```

0 commit comments

Comments
 (0)