1
- name : Test Released Cloud Pods
1
+ name : Create and Test LocalStack Cloud Pod
2
2
3
3
on :
4
4
schedule :
5
- # “ At 00:00 on Saturday.”
5
+ # At 00:00 on Saturday.
6
6
- cron : " 0 0 * * 6"
7
+ push :
8
+ branches :
9
+ - main
10
+ pull_request :
11
+ branches :
12
+ - main
7
13
workflow_dispatch :
8
14
9
15
permissions :
10
16
contents : write
17
+ actions : read
11
18
12
19
jobs :
13
- get-releases :
14
- name : Retrieve Released Cloud Pods
20
+ create-pod :
21
+ name : Create Cloud Pod
15
22
runs-on : ubuntu-latest
16
23
outputs :
17
- matrix : ${{ steps.set-matrix.outputs.matrix }}
24
+ pod_artifact_name : cloud-pod- ${{ github.run_id }}
18
25
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
38
50
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
41
53
env :
42
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54
+ LOCALSTACK_AUTH_TOKEN : ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
43
55
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
51
75
52
76
- name : Setup Python
53
- uses : actions/setup-python@v4
77
+ uses : actions/setup-python@v5
54
78
with :
55
79
python-version : ' 3.11'
56
80
81
+ - name : Install Test Dependencies
82
+ run : |
83
+ pip install -r requirements-dev.txt --upgrade
84
+
57
85
- name : Start LocalStack
58
- uses : LocalStack/setup-localstack@v0.2.2
86
+ uses : LocalStack/setup-localstack@main
59
87
with :
60
- image-tag : ${{ matrix.tag }}
61
88
use-pro : ' true'
62
89
install-awslocal : ' true'
63
90
env :
64
91
DEBUG : 1
65
92
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 }}
67
99
68
- - name : Inject Pod
100
+ - name : Inject Pod (Import State)
69
101
env :
70
- LOCALSTACK_API_KEY : ${{ secrets.LOCALSTACK_API_KEY }}
102
+ LOCALSTACK_AUTH_TOKEN : ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
71
103
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
73
107
74
108
- name : Run Tests
75
109
env :
@@ -78,11 +112,10 @@ jobs:
78
112
AWS_ACCESS_KEY_ID : test
79
113
AWS_SECRET_ACCESS_KEY : test
80
114
run : |
81
- pip install -r requirements-dev.txt
82
115
pytest tests
83
116
84
- - name : Show Logs
85
- if : failure ()
117
+ - name : Show LocalStack Logs
118
+ if : always ()
86
119
run : |
87
120
localstack logs
88
121
@@ -99,10 +132,18 @@ jobs:
99
132
env :
100
133
SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
101
134
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
105
143
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