Skip to content

Commit 6687879

Browse files
authored
revamp the github action workflows (#43)
* fix the preview workflow * fix * fix * test against a branch * remove the branch * fix integration test with auth token * try running on macos * setup docker on macos * run macOS tests only on schedule * remove cloud pods release workflow * reform the cloud pods action * remove keepalive workflow
1 parent 5978d86 commit 6687879

File tree

4 files changed

+101
-152
lines changed

4 files changed

+101
-152
lines changed

.github/workflows/cloudpod_release.yml

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

.github/workflows/integration-test.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ on:
2222
type: choice
2323
options:
2424
- ubuntu-latest
25-
- macos-latest
25+
- macos-13
2626

2727

2828
jobs:
2929
run-it-tests-job:
3030
runs-on: ${{ inputs.runner-os || 'ubuntu-latest' }}
3131
steps:
3232
- name: Checkout
33-
uses: actions/checkout@v2
33+
uses: actions/checkout@v4
3434

3535
- name: Set up Python 3.11
3636
id: setup-python
@@ -39,9 +39,9 @@ jobs:
3939
python-version: 3.11
4040

4141
- name: Docker setup (macos only)
42-
id: setup-docker-mac
4342
if: ${{ runner.os == 'macOS' }}
4443
run: |
44+
brew install colima
4545
brew install docker
4646
colima start
4747
@@ -50,14 +50,15 @@ jobs:
5050
pip install -r requirements-dev.txt
5151
5252
- name: Start LocalStack
53-
uses: LocalStack/[email protected].2
53+
uses: LocalStack/[email protected].4
5454
with:
5555
image-tag: 'latest'
5656
use-pro: 'true'
5757
configuration: LS_LOG=trace
5858
install-awslocal: 'true'
5959
env:
60-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
60+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
61+
6162
- name: Build lambdas
6263
run: |
6364
bin/build_lambdas.sh

.github/workflows/preview_create.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
- ./*.md
88
- LICENSE
99
- .circleci/*
10-
- .gitlab-ci.yml
1110

1211
jobs:
1312
test:
@@ -30,20 +29,16 @@ jobs:
3029
pip install awscli-local
3130
3231
- name: Deploy Preview
33-
uses: LocalStack/setup-localstack@v0.2.2
32+
uses: LocalStack/setup-localstack@main
3433
env:
35-
AWS_DEFAULT_REGION: us-east-1
36-
AWS_REGION: us-east-1
37-
AWS_ACCESS_KEY_ID: test
38-
AWS_SECRET_ACCESS_KEY: test
39-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
34+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
4035
with:
4136
github-token: ${{ secrets.GITHUB_TOKEN }}
4237
state-backend: ephemeral
4338
state-action: start
44-
skip-ephemeral-stop: 'true'
4539
include-preview: 'true'
40+
install-awslocal: 'true'
4641
preview-cmd: |
4742
# Add your custom deployment commands here.
4843
# Below is an example for the Image resizer application.
49-
bin/build_lambdas.sh && deployment/awslocal/deploy.sh
44+
bin/build_lambdas.sh && deployment/awslocal/deploy.sh

.github/workflows/test_cloudpods.yml

Lines changed: 91 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,109 @@
1-
name: Test Released Cloud Pods
1+
name: Create and Test LocalStack Cloud Pod
22

33
on:
44
schedule:
5-
# At 00:00 on Saturday.
5+
# At 00:00 on Saturday.
66
- cron: "0 0 * * 6"
7+
push:
8+
branches:
9+
- main
10+
pull_request:
11+
branches:
12+
- main
713
workflow_dispatch:
814

915
permissions:
1016
contents: write
17+
actions: read
1118

1219
jobs:
13-
get-releases:
14-
name: Retrieve Released Cloud Pods
20+
create-pod:
21+
name: Create Cloud Pod
1522
runs-on: ubuntu-latest
1623
outputs:
17-
matrix: ${{ steps.set-matrix.outputs.matrix }}
24+
pod_artifact_name: cloud-pod-${{ github.run_id }}
1825
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
26+
- name: Checkout Code
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Python
30+
uses: actions/setup-python@v5
31+
with:
32+
python-version: '3.11'
33+
34+
- name: Install Dependencies
35+
run: |
36+
pip install -r requirements-dev.txt --upgrade
37+
38+
- name: Start LocalStack
39+
uses: LocalStack/setup-localstack@main
40+
with:
41+
use-pro: 'true'
42+
install-awslocal: 'true'
43+
env:
44+
DEBUG: 1
45+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
46+
47+
- name: Deploy Infrastructure (Example)
48+
run: |
49+
bin/build_lambdas.sh && deployment/awslocal/deploy.sh
3850
39-
# Loading it manually as we're storing the state as a release and not an artifact
40-
- name: Retrieve Pod
51+
- name: Export LocalStack State (Cloud Pod)
52+
id: export_state
4153
env:
42-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
4355
run: |
44-
# TODO the download url seems to follow the pattern $GITHUB_REPOSITORY/releases/download/{TAG}/{ASSET_NAME}
45-
# alternatively we can query the asset-id, and browser_download_url, but it seems like an overhead
46-
# 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)
47-
# download_url=$(gh api repos/$GITHUB_REPOSITORY/releases/assets/$asset_id | jq -r ".browser_download_url")
48-
download_url="https://github.com/$GITHUB_REPOSITORY/releases/download/${{ matrix.tag }}/release-pod.zip"
49-
curl -L $download_url --output release-pod.zip
50-
ls -la
56+
echo "Exporting LocalStack state..."
57+
localstack state export cloud-pod.zip
58+
ls -la cloud-pod.zip # Verify the file exists
59+
echo "pod_artifact_name=cloud-pod-${{ github.run_id }}" >> $GITHUB_OUTPUT
60+
61+
- name: Upload Cloud Pod Artifact
62+
uses: actions/upload-artifact@v4
63+
with:
64+
name: ${{ steps.export_state.outputs.pod_artifact_name }}
65+
path: cloud-pod.zip
66+
retention-days: 1
67+
68+
test-pod:
69+
name: Test Cloud Pod
70+
needs: create-pod
71+
runs-on: ubuntu-latest
72+
steps:
73+
- name: Checkout Code
74+
uses: actions/checkout@v4
5175

5276
- name: Setup Python
53-
uses: actions/setup-python@v4
77+
uses: actions/setup-python@v5
5478
with:
5579
python-version: '3.11'
5680

81+
- name: Install Test Dependencies
82+
run: |
83+
pip install -r requirements-dev.txt --upgrade
84+
5785
- name: Start LocalStack
58-
uses: LocalStack/setup-localstack@v0.2.2
86+
uses: LocalStack/setup-localstack@main
5987
with:
60-
image-tag: ${{ matrix.tag }}
6188
use-pro: 'true'
6289
install-awslocal: 'true'
6390
env:
6491
DEBUG: 1
6592
POD_LOAD_CLI_TIMEOUT: 300
66-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
93+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
94+
95+
- name: Download Cloud Pod Artifact
96+
uses: actions/download-artifact@v4
97+
with:
98+
name: ${{ needs.create-pod.outputs.pod_artifact_name }}
6799

68-
- name: Inject Pod
100+
- name: Inject Pod (Import State)
69101
env:
70-
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
102+
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
71103
run: |
72-
localstack state import release-pod.zip
104+
echo "Importing LocalStack state from cloud-pod.zip..."
105+
ls -la # Check if download was successful
106+
localstack state import cloud-pod.zip
73107
74108
- name: Run Tests
75109
env:
@@ -78,11 +112,10 @@ jobs:
78112
AWS_ACCESS_KEY_ID: test
79113
AWS_SECRET_ACCESS_KEY: test
80114
run: |
81-
pip install -r requirements-dev.txt
82115
pytest tests
83116
84-
- name: Show Logs
85-
if: failure()
117+
- name: Show LocalStack Logs
118+
if: always()
86119
run: |
87120
localstack logs
88121
@@ -99,10 +132,18 @@ jobs:
99132
env:
100133
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
101134

102-
- name: Prevent Workflows from getting Stale
103-
if: always()
104-
uses: gautamkrishnar/keepalive-workflow@v1
135+
- name: Generate a Diagnostic Report
136+
if: failure()
137+
run: |
138+
curl -s localhost:4566/_localstack/diagnose | gzip -cf > diagnose.json.gz
139+
140+
- name: Upload the Diagnostic Report
141+
if: failure()
142+
uses: actions/upload-artifact@v4
105143
with:
106-
# this message should prevent automatic triggering of workflows
107-
# see https://docs.github.com/en/actions/managing-workflow-runs/skipping-workflow-runs
108-
commit_message: "[skip ci] Automated commit by Keepalive Workflow to keep the repository active"
144+
name: diagnose.json.gz
145+
path: ./diagnose.json.gz
146+
147+
- name: Prevent Workflow from becoming Stale
148+
if: always() && github.ref == 'refs/heads/main'
149+
uses: liskin/gh-workflow-keepalive@v1

0 commit comments

Comments
 (0)