-
Notifications
You must be signed in to change notification settings - Fork 12
219 lines (195 loc) · 7.97 KB
/
ci.yml
File metadata and controls
219 lines (195 loc) · 7.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
name: LocalStack Test
on:
push:
branches:
- 'main'
pull_request:
paths-ignore:
- ./*.md
- LICENSE
workflow_dispatch:
schedule:
- cron: '48 23 * * 0'
jobs:
localstack-action-version-test:
name: 'Test LocalStack Version with Github Actions'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
# We must hack the action call as remote to be able to use the relative paths
# Could it break with different CWD? 🤔
- name: Start LocalStack
uses: jenseng/dynamic-uses@8bc24f0360175e710da532c4d19eafdbed489a06 # v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"image-tag": "3.2.0",
"install-awslocal": "true",
"configuration": "DEBUG=1",
"use-pro": "true",
}
env:
# intentially left `LOCALSTACK_API_KEY` as env here, to ensure the fallback still works for old version
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
GH_ACTION_VERSION: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.ref_name }}
- name: Run Version Test Against LocalStack
run: |
LS_VERSION=$(docker ps | grep localstack | cut -d " " -f4 | cut -d ":" -f2)
exit $(test "x${LS_VERSION}" = "x3.2.0")
cloud-pods-save-test:
name: 'Test Cloud Pods Action'
runs-on: ubuntu-latest
outputs:
pod-name: ${{ steps.pod_name.outputs.name }}
steps:
- name: ⚡️ Checkout the repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Start LocalStack
uses: jenseng/dynamic-uses@8bc24f0360175e710da532c4d19eafdbed489a06 # v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"image-tag": "latest",
"install-awslocal": "true",
"configuration": "DEBUG=1",
"use-pro": "true",
}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
GH_ACTION_VERSION: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.ref_name }}
- name: Generate random pod name
id: pod_name
run: echo "name=cloud-pods-test-$RANDOM" >> $GITHUB_OUTPUT
- name: Run AWS commands
run: |
awslocal s3 mb s3://test
awslocal sqs create-queue --queue-name test-queue
- name: Save the Cloud Pod
uses: jenseng/dynamic-uses@8bc24f0360175e710da532c4d19eafdbed489a06 # v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"state-name": "${{ steps.pod_name.outputs.name }}",
"state-action": "save",
}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
GH_ACTION_VERSION: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.ref_name }}
- name: Verify Cloud Pod
run: |
localstack pod list | grep ${{ steps.pod_name.outputs.name }}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
load-cloud-pod-test:
name: 'Test Loading Cloud Pod'
runs-on: ubuntu-latest
needs: cloud-pods-save-test
steps:
- name: ⚡️ Checkout the repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Start LocalStack and Load Pod
uses: jenseng/dynamic-uses@8bc24f0360175e710da532c4d19eafdbed489a06 # v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"image-tag": "latest",
"install-awslocal": "true",
"configuration": "DEBUG=1",
"use-pro": "true",
"state-name": "${{ needs.cloud-pods-save-test.outputs.pod-name }}",
"state-action": "load"
}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
GH_ACTION_VERSION: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.ref_name }}
- name: Verify loaded resources
run: |
echo "Verifying S3 bucket..."
awslocal s3 ls | grep "test"
echo "Verifying SQS queue..."
awslocal sqs list-queues | grep "test-queue"
- name: Clean up remote pod
run: localstack pod delete ${{ needs.cloud-pods-save-test.outputs.pod-name }}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
- name: Verify successful cleanup of Cloud Pod
run: |
echo "Verifying that the pod has been deleted..."
if localstack pod list | grep -q ${{ needs.cloud-pods-save-test.outputs.pod-name }}; then
echo "Cleanup failed! Pod ${{ needs.cloud-pods-save-test.outputs.pod-name }} was not deleted."
exit 1
fi
echo "Pod successfully deleted."
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
local-state-save-test:
name: 'Test Local State Save Action'
runs-on: ubuntu-latest
steps:
- name: ⚡️ Checkout the repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Start LocalStack
uses: jenseng/dynamic-uses@8bc24f0360175e710da532c4d19eafdbed489a06 # v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"image-tag": "latest",
"install-awslocal": "true",
"configuration": "DEBUG=1",
"use-pro": "true",
}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
GH_ACTION_VERSION: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.ref_name }}
- name: Run AWS commands
run: |
awslocal s3 mb s3://test-local
awslocal sqs create-queue --queue-name test-queue-local
- name: Save the State Artifact
uses: jenseng/dynamic-uses@8bc24f0360175e710da532c4d19eafdbed489a06 # v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"state-name": "local-pods-test",
"state-action": "save",
"state-backend": "local",
}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
GH_ACTION_VERSION: ${{ (github.event_name == 'pull_request' && github.event.pull_request.head.sha) || github.ref_name }}
local-state-load-test:
name: 'Test Local State Load Action'
needs: local-state-save-test
runs-on: ubuntu-latest
steps:
- name: ⚡️ Checkout the repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
- name: Start LocalStack
uses: jenseng/dynamic-uses@8bc24f0360175e710da532c4d19eafdbed489a06 # v1
with:
uses: LocalStack/setup-localstack@${{ env.GH_ACTION_VERSION }}
with: |-
{
"image-tag": "latest",
"install-awslocal": "true",
"configuration": "DEBUG=1",
"use-pro": "true",
"state-name": "local-pods-test",
"state-action": "load",
"state-backend": "local",
}
env:
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
GH_ACTION_VERSION: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.sha || github.ref_name }}
- name: Run AWS Commands
run: |
echo "Verifying S3 bucket..."
awslocal s3 ls | grep "test-local"
echo "Verifying SQS queue..."
awslocal sqs list-queues | grep "test-queue-local"