-
Notifications
You must be signed in to change notification settings - Fork 0
202 lines (191 loc) · 7.31 KB
/
functional_tests.yml
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
---
name: functional-tests
on:
workflow_dispatch: {}
schedule:
- cron: '0 0 * * *'
jobs:
functional-tests:
runs-on: ubuntu-latest
env:
ACCOUNT_ID: "891426818781"
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22"
-
name: Build
run: go build
-
name: AppPack Account
run: |
STACK_NAME=apppack-account
AWS_PAGER=""
set -ex
aws cloudformation create-stack \
--stack-name $STACK_NAME \
--template-url https://s3.amazonaws.com/apppack-cloudformations/latest/account.json \
--capabilities CAPABILITY_IAM \
--parameters ParameterKey=Administrators,[email protected]
aws cloudformation wait stack-create-complete \
--stack-name $STACK_NAME
timeout-minutes: 10
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
-
name: AppPack Cluster
run: |
./apppack create cluster \
--aws-credentials \
--region us-east-1 \
--create-region \
--dockerhub-username $DOCKERHUB_USERNAME \
--dockerhub-access-token $DOCKERHUB_ACCESS_TOKEN \
--domain testclusters.apppack.io \
--non-interactive
timeout-minutes: 20
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_ACCESS_TOKEN: ${{ secrets.DOCKERHUB_ACCESS_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Create app
run: |
./apppack create app \
--aws-credentials \
--region us-east-1 \
--non-interactive \
--cluster apppack \
--repository https://github.com/apppackio/apppack-demo-python.git \
--branch main \
--users [email protected] \
app-test
timeout-minutes: 5
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Verify user
run: |
echo "Waiting for user to get created..."
while [ "$(aws dynamodb get-item --table-name apppack --key '{"primary_id": {"S": "USER#[email protected]"}, "secondary_id": {"S": "891426818781#app-test"}}' --query Item)" = "null" ]; do
sleep 10
done
timeout-minutes: 3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.APPPACK_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.APPPACK_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
# TODO: authorize CLI
# -
# name: Deploy app
# run: |
# ./apppack build start -a app-test --wait
# timeout-minutes: 5
# -
# name: Check app
# run: curl --fail https://app-test.testclusters.apppack.io
-
name: Destroy app
run: |
yes apppack-app-app-test | ./apppack destroy app app-test --aws-credentials --region us-east-1
if: always()
timeout-minutes: 5
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy cluster
run: |
yes apppack-cluster-apppack | ./apppack destroy cluster apppack --aws-credentials --region us-east-1
if: always()
timeout-minutes: 10
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Check and Delete CNAME and A Records
if: always()
run: |
hosted_zone_id="Z05906472T84V7X7Q6UDY"
# Record details
cname_record_name="_5b8b09a8917e1fbb8c6aead5121fb550.testclusters.apppack.io"
a_record_name="*.testcluster.apppack.io"
# Function to check and delete a record
delete_record() {
record_name=$1
record_type=$2
echo "Checking if $record_type record '$record_name' exists ..."
record_value=$(aws route53 list-resource-record-sets --hosted-zone-id $hosted_zone_id \
--query "ResourceRecordSets[?Name == '$record_name.']" \
--output text)
if [[ -n "$record_value" ]]; then
echo "$record_type record exists, deleting..."
# Extract the actual value of the record to use in the deletion
record_actual_value=$(aws route53 list-resource-record-sets --hosted-zone-id $hosted_zone_id \
--query "ResourceRecordSets[?Name == '$record_name.'].ResourceRecords[0].Value" \
--output text)
# Delete the record
aws route53 change-resource-record-sets --hosted-zone-id "$hosted_zone_id" \
--change-batch "{
\"Changes\": [{
\"Action\": \"DELETE\",
\"ResourceRecordSet\": {
\"Name\": \"$record_name\",
\"Type\": \"$record_type\",
\"TTL\": 300,
\"ResourceRecords\": [{\"Value\": \"$record_actual_value\"}]
}
}]
}"
echo "$record_type record '$record_name' deleted successfully."
else
echo "$record_type record '$record_name' does not exist, skipping deletion."
fi
}
# Delete CNAME record
delete_record "$cname_record_name" "CNAME"
# Delete A record
delete_record "$a_record_name" "A"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1
-
name: Destroy region
run: |
yes apppack-region-us-east-1 | ./apppack destroy region --aws-credentials --region us-east-1
if: always()
timeout-minutes: 3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Destroy account
run: |
yes apppack-account | ./apppack destroy account --aws-credentials --region us-east-1
if: always()
timeout-minutes: 3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
-
name: Disable account
if: always()
shell: bash
run: |
aws dynamodb delete-item --table-name apppack --key '{
"primary_id": {"S": "ACCT#${{ env.ACCOUNT_ID }}"},
"secondary_id": {"S": "-"}
}'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.APPPACK_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.APPPACK_AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-east-1