-
Notifications
You must be signed in to change notification settings - Fork 26
616 lines (538 loc) · 23.4 KB
/
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
# This is a basic workflow to help you get started with Actions
name: Integration Tests
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the main branch.
on:
push:
branches: [main]
paths:
[
'.github/workflows/tests.yml',
'src/**',
'test/**',
'package.json',
'yarn.lock',
'jest.config.js',
'jest-environment-fail-fast.js',
'Dockerfile',
]
pull_request:
branches: [main]
paths:
[
'.github/workflows/tests.yml',
'src/**',
'test/**',
'package.json',
'yarn.lock',
'jest.config.js',
'jest-environment-fail-fast.js',
'Dockerfile',
]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
lint:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Set up Node.js
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Install dependencies
run: yarn --prefer-offline
- name: Run linter check
run: yarn lint
style:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
# Set up Node.js
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Install dependencies
run: yarn --prefer-offline
- name: Run code style check
run: yarn style
setup-common-test:
runs-on: ubuntu-latest
outputs:
common-tests: ${{ steps['set-common-tests'].outputs['common-tests'] }}
set-common-test-names: ${{ steps['set-common-test-names'].outputs['common-test-names'] }}
steps:
- uses: actions/checkout@v3
- run: yarn --prefer-offline
- id: set-common-tests
name: Set common tests
run: >
echo "common-tests=$(npx jest **/common/* --listTests --json | jq -c 'map({(. | split("/") | .[-1] | split(".") | .[0] | gsub( "-"; "_") | ascii_upcase | tostring): .}) | add')" >> $GITHUB_OUTPUT
- id: set-common-test-names
name: Set common test names
run: echo "common-test-names=$(npx jest **/common/* --listTests --json | jq -c 'map(split("/") | .[-1] | split(".") | .[0] | gsub( "-"; "_") | ascii_upcase | tostring)')" >> $GITHUB_OUTPUT
common-test:
runs-on: ubuntu-latest
needs:
- setup-common-test
name: common.test.${{ matrix.common }}
strategy:
fail-fast: false
matrix:
common: ${{ fromJson(needs.setup-common-test.outputs['set-common-test-names']) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Install dependencies
run: yarn --prefer-offline
- name: Run common tests
uses: nick-fields/retry@v2
with:
max_attempts: 2
retry_on: error
timeout_minutes: 30
command: yarn coverage $(echo $COMMONS | jq -r '."${{matrix.common}}"')
env:
IASQL_ENV: test
COMMONS: ${{ needs.setup-common-test.outputs['common-tests'] }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_TESTING }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_TESTING }}
A0_IASQL_API_TOKEN: ${{ secrets.A0_IASQL_API_TOKEN }}
setup-basic-integration-test:
runs-on: ubuntu-latest
outputs:
basic-integration-tests: ${{ steps['set-basic-integration-tests'].outputs['basic-integration-tests'] }}
set-basic-integration-test-names: ${{ steps['set-basic-integration-test-names'].outputs['basic-integration-test-names'] }}
steps:
- uses: actions/checkout@v3
- run: yarn --prefer-offline
- id: set-basic-integration-tests
name: Set basic integration tests
run: >
echo "basic-integration-tests=$(npx jest **/basic_integration/* --listTests --json | jq -c 'map({(. | split("/") | .[-1] | split(".") | .[0] | gsub( "-"; "_") | ascii_upcase | tostring): .}) | add')" >> $GITHUB_OUTPUT
- id: set-basic-integration-test-names
name: Set basic integration test names
run: echo "basic-integration-test-names=$(npx jest **/basic_integration/* --listTests --json | jq -c 'map(split("/") | .[-1] | split(".") | .[0] | gsub( "-"; "_") | ascii_upcase | tostring)')" >> $GITHUB_OUTPUT
basic-integration-test:
runs-on: ubuntu-latest
needs:
- setup-basic-integration-test
name: basic-integration.test.${{ matrix.basic-integration }}
strategy:
fail-fast: false
matrix:
basic-integration: ${{ fromJson(needs.setup-basic-integration-test.outputs['set-basic-integration-test-names']) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Install dependencies
run: yarn --prefer-offline
- name: Determine Test Account To Use
id: determine-test-account
env:
SECRET_HEADER: ${{ secrets.SECRET_HEADER }}
LAMBDA_FUNCTION: 'https://22quullhnmsrttacexxc74uium0nndzo.lambda-url.us-east-2.on.aws/'
run: |
RESPONSE=$(curl -X POST -H "Content-Type: text/plain" -H "${SECRET_HEADER}" -d '1' ${LAMBDA_FUNCTION} 2>/dev/null)
echo $RESPONSE
ACCOUNT_INDEX=$(echo $RESPONSE | jq '.[0]' || exit 1)
echo "account_index=$(echo ${ACCOUNT_INDEX})" >> $GITHUB_OUTPUT
- name: Run basic-integration tests
uses: nick-fields/retry@v2
with:
max_attempts: 2
retry_on: error
timeout_minutes: 15
command: |
export AWS_ACCESS_KEY_ID=$(echo "${ACCESS_KEY_IDS}" | jq -r ".[${ACCOUNT_INDEX}]")
export AWS_SECRET_ACCESS_KEY=$(echo "${SECRET_ACCESS_KEYS}" | jq -r ".[${ACCOUNT_INDEX}]")
yarn coverage $(echo $TESTS | jq -r '."${{matrix.basic-integration}}"')
env:
IASQL_ENV: test
TESTS: ${{ needs.setup-basic-integration-test.outputs['basic-integration-tests'] }}
ACCOUNT_INDEX: ${{ steps['determine-test-account'].outputs['account_index'] }}
ACCESS_KEY_IDS: ${{ secrets.ACCESS_KEY_IDS }}
SECRET_ACCESS_KEYS: ${{ secrets.SECRET_ACCESS_KEYS }}
A0_IASQL_API_TOKEN: ${{ secrets.A0_IASQL_API_TOKEN }}
- name: Return test account
if: always()
env:
SECRET_HEADER: ${{ secrets.SECRET_HEADER }}
ACCOUNT_INDEX: ${{ steps['determine-test-account'].outputs['account_index'] }}
LAMBDA_FUNCTION: 'https://22quullhnmsrttacexxc74uium0nndzo.lambda-url.us-east-2.on.aws/'
run: |
curl -X POST -H "Content-Type: application/json" -H "${SECRET_HEADER}" -H "x-iasql-drop: true" -d "[${ACCOUNT_INDEX}]" ${LAMBDA_FUNCTION}
readonly-test:
runs-on: ubuntu-latest
name: readonly tests
steps:
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Install dependencies
run: yarn --prefer-offline
- name: Run read-only tests
uses: nick-fields/retry@v2
with:
max_attempts: 2
retry_on: error
timeout_minutes: 40
command: yarn coverage **/readonly/*
env:
IASQL_ENV: test
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_READONLY_TESTING }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_READONLY_TESTING }}
A0_IASQL_API_TOKEN: ${{ secrets.A0_IASQL_API_TOKEN }}
upgrade-test:
runs-on: ubuntu-latest
name: iasql_upgrade test
steps:
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Install dependencies
run: yarn --prefer-offline
- name: Run common tests
uses: nick-fields/retry@v2
with:
max_attempts: 2
timeout_minutes: 30
retry_on: error
command: ./test/upgrade/run-upgrade.sh
env:
IASQL_ENV: test
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_TESTING }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_TESTING }}
A0_IASQL_API_TOKEN: ${{ secrets.A0_IASQL_API_TOKEN }}
setup-module-test:
runs-on: ubuntu-latest
outputs:
test-modules: ${{ steps['set-test-modules'].outputs['test-modules'] }}
set-test-module-names: ${{ steps['set-test-module-names'].outputs['test-module-names'] }}
registry-image-tag: ${{ steps['set-registry-image-tag'].outputs['registry-image-tag'] }}
steps:
- uses: actions/checkout@v3
- run: yarn --prefer-offline
- id: set-test-modules
name: Set modules tests
run: >
echo "test-modules=$(npx jest **/modules/* --listTests --json | jq -c 'map({(. | split("/") | .[-1] | split(".") | .[0] | gsub( "-"; "_") | ascii_upcase | tostring): .}) | add')" >> $GITHUB_OUTPUT
- id: set-test-module-names
name: Set modules tests names
run: echo "test-module-names=$(npx jest **/modules/* --listTests --json | jq -c 'map(split("/") | .[-1] | split(".") | .[0] | gsub( "-"; "_") | ascii_upcase | tostring)')" >> $GITHUB_OUTPUT
- id: set-registry-image-tag
name: Set registry image tag
run: echo "registry-image-tag=ghcr.io/iasql/iasql:$GITHUB_SHA" >> $GITHUB_OUTPUT
build-and-push:
runs-on: ubuntu-latest
outputs:
image-size: ${{ steps['get-image-size'].outputs['image-size'] }}
needs:
- setup-module-test
steps:
- uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker-build
uses: docker/build-push-action@v3
with:
context: .
push: true
cache-from: type=gha
cache-to: type=gha
tags: ${{ needs.setup-module-test.outputs.registry-image-tag }}
module-test:
runs-on: ubuntu-latest
needs:
- setup-module-test
- build-and-push
name: module test ${{ matrix.module }}
strategy:
fail-fast: false
matrix:
module: ${{ fromJson(needs.setup-module-test.outputs['set-test-module-names']) }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Determine Test Account To Use
id: determine-test-account
env:
SECRET_HEADER: ${{ secrets.SECRET_HEADER }}
LAMBDA_FUNCTION: 'https://22quullhnmsrttacexxc74uium0nndzo.lambda-url.us-east-2.on.aws/'
run: |
RESPONSE=$(curl -X POST -H "Content-Type: text/plain" -H "${SECRET_HEADER}" -d '1' ${LAMBDA_FUNCTION} 2>/dev/null)
echo $RESPONSE
ACCOUNT_INDEX=$(echo $RESPONSE | jq '.[0]' || exit 1)
echo "account_index=$(echo ${ACCOUNT_INDEX})" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pre-clean Test Account
id: pre-clean-test-account
uses: nick-fields/retry@v2
env:
IASQL_ENV: ci
ACCOUNT_INDEX: ${{ steps['determine-test-account'].outputs['account_index'] }}
ACCESS_KEY_IDS: ${{ secrets.ACCESS_KEY_IDS }}
SECRET_ACCESS_KEYS: ${{ secrets.SECRET_ACCESS_KEYS }}
PSQL_CONN: postgres://postgres:test@localhost:5432/iasql
with:
max_attempts: 2
retry_on: error
timeout_minutes: 30
command: |
# Establish needed secrets
export AWS_ACCESS_KEY_ID=$(echo "${ACCESS_KEY_IDS}" | jq -r ".[${ACCOUNT_INDEX}]")
export AWS_SECRET_ACCESS_KEY=$(echo "${SECRET_ACCESS_KEYS}" | jq -r ".[${ACCOUNT_INDEX}]")
# Spin up IaSQL container and a postgres instance
# Temporarily export the server port until it's only the Postgres port needed
docker run -p 5432:5432 -e IASQL_ENV=ci --name iasql ghcr.io/iasql/iasql:$GITHUB_SHA &
while ! psql postgres://postgres:test@localhost:5432/iasql_metadata -b -q -c "SELECT iasql_engine_health()"; do sleep 1 && echo -n .; done;
# connect `iasql` db to aws account for `apply`
echo "\nCreating an iasql db..."
connectres=$(psql "postgres://postgres:test@localhost:5432/iasql_metadata" -t -c "SELECT json_agg(c)->0 FROM iasql_connect('iasql') as c;")
username=$(jq -r '.user' <<<"$connectres")
password=$(jq -r '.password' <<<"$connectres")
# Setup Account
echo "\nInstalling aws_account..."
psql $PSQL_CONN -c "
select iasql_install(
'aws_account'
);
";
echo "\nAttaching credentials..."
psql $PSQL_CONN -c "
INSERT INTO aws_credentials (access_key_id, secret_access_key)
VALUES ('${AWS_ACCESS_KEY_ID}', '${AWS_SECRET_ACCESS_KEY}');
";
# Start transaction
echo "\nStarting transaction..."
psql $PSQL_CONN -c "
select * from iasql_begin();
";
# Start transaction
echo "\nSynchronizing..."
psql $PSQL_CONN -c "
SELECT * FROM iasql_commit();
";
echo "\nInstalling all modules in iasql db..."
psql $PSQL_CONN -c "
select iasql_install(
variadic array(select module_name from iasql_modules_list())
);
";
# Remove delete protection from clusters
echo "\nStarting transaction..."
psql postgres://$username:$password@localhost:5432/iasql -c "select * from iasql_begin();"
# Remove delete protection
echo "\nDisable delete protection..."
psql "postgres://$username:$password@localhost:5432/iasql" -c "UPDATE db_cluster SET delete_protection=FALSE;"
echo "\nApply removal..."
psql $PSQL_CONN -c "select * from iasql_commit();" ; docker logs $(docker ps -a --filter "name=iasql" --format "{{.Names}}")
# Start transaction
echo "\nStarting transaction..."
psql postgres://$username:$password@localhost:5432/iasql -c "select * from iasql_begin();"
# Delete all records
echo "\nDelete all records..."
psql "postgres://$username:$password@localhost:5432/iasql" -c "select * from delete_all_records();"
echo "\nApply..."
psql $PSQL_CONN -c "select * from iasql_commit();" ; docker logs $(docker ps -a --filter "name=iasql" --format "{{.Names}}")
# Shut down the container
docker container stop iasql
- name: Install dependencies
run: yarn --prefer-offline
- name: Run modules tests
timeout-minutes: 90
uses: nick-fields/retry@v2
env:
IASQL_ENV: test
MODULES: ${{ needs.setup-module-test.outputs['test-modules'] }}
ACCOUNT_INDEX: ${{ steps['determine-test-account'].outputs['account_index'] }}
ACCESS_KEY_IDS: ${{ secrets.ACCESS_KEY_IDS }}
SECRET_ACCESS_KEYS: ${{ secrets.SECRET_ACCESS_KEYS }}
STAGING_ACCESS_KEY_ID: ${{ secrets.STAGING_ACCESS_KEY_ID }}
STAGING_SECRET_ACCESS_KEY: ${{ secrets.STAGING_SECRET_ACCESS_KEY }}
GH_PAT: ${{ secrets.GH_PAT }}
with:
max_attempts: 3
retry_on: error
timeout_minutes: 90
command: |
export AWS_ACCESS_KEY_ID=$(echo "${ACCESS_KEY_IDS}" | jq -r ".[${ACCOUNT_INDEX}]")
export AWS_SECRET_ACCESS_KEY=$(echo "${SECRET_ACCESS_KEYS}" | jq -r ".[${ACCOUNT_INDEX}]")
yarn test $(echo $MODULES | jq -r '."${{matrix.module}}"')
- name: Return test account
if: always()
env:
SECRET_HEADER: ${{ secrets.SECRET_HEADER }}
ACCOUNT_INDEX: ${{ steps['determine-test-account'].outputs['account_index'] }}
LAMBDA_FUNCTION: 'https://22quullhnmsrttacexxc74uium0nndzo.lambda-url.us-east-2.on.aws/'
run: |
curl -X POST -H "Content-Type: application/json" -H "${SECRET_HEADER}" -H "x-iasql-drop: true" -d "[${ACCOUNT_INDEX}]" ${LAMBDA_FUNCTION}
get-pr-debug-info:
needs:
- build-and-push
runs-on: ubuntu-latest
# only run if a PR exists
if: ${{ github.event.pull_request }}
outputs:
install-time: ${{ steps.install-all-modules.outputs.set-install-time }}
uninstall-time: ${{ steps.install-all-modules.outputs.set-uninstall-time }}
compressed-image-size: ${{ steps.install-all-modules.outputs.compressed-image-size }}
uncompressed-image-size: ${{ steps.install-all-modules.outputs.uncompressed-image-size }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
cache: 'yarn'
- name: Determine Test Account To Use
id: determine-test-account
env:
SECRET_HEADER: ${{ secrets.SECRET_HEADER }}
LAMBDA_FUNCTION: 'https://22quullhnmsrttacexxc74uium0nndzo.lambda-url.us-east-2.on.aws/'
run: |
RESPONSE=$(curl -X POST -H "Content-Type: text/plain" -H "${SECRET_HEADER}" -d '1' ${LAMBDA_FUNCTION} 2>/dev/null)
echo $RESPONSE
ACCOUNT_INDEX=$(echo $RESPONSE | jq '.[0]' || exit 1)
echo "account_index=$(echo ${ACCOUNT_INDEX})" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install and Uninstall all modules
id: install-all-modules
env:
IASQL_ENV: ci
ACCOUNT_INDEX: ${{ steps['determine-test-account'].outputs['account_index'] }}
ACCESS_KEY_IDS: ${{ secrets.ACCESS_KEY_IDS }}
SECRET_ACCESS_KEYS: ${{ secrets.SECRET_ACCESS_KEYS }}
PSQL_CONN: postgres://postgres:test@localhost:5432/iasql
run: |
# Establish needed secrets
export AWS_ACCESS_KEY_ID=$(echo "${ACCESS_KEY_IDS}" | jq -r ".[${ACCOUNT_INDEX}]")
export AWS_SECRET_ACCESS_KEY=$(echo "${SECRET_ACCESS_KEYS}" | jq -r ".[${ACCOUNT_INDEX}]")
# Spin up IaSQL container and a postgres instance
# Temporarily export the server port until it's only the Postgres port needed
docker pull ghcr.io/iasql/iasql:$GITHUB_SHA
compressed_image_size=$(docker manifest inspect -v ghcr.io/iasql/iasql:$GITHUB_SHA | jq -r '[ .SchemaV2Manifest.layers[].size ] | add')
echo "compressed-image-size=$(numfmt --to=iec --suffix=B --format='%.2f' $compressed_image_size)" >> $GITHUB_OUTPUT
uncompressed_image_size=$(docker image inspect ghcr.io/iasql/iasql:$GITHUB_SHA | jq -r '.[0].Size')
echo "uncompressed-image-size=$(numfmt --to=iec --suffix=B --format="%.2f" $uncompressed_image_size)" >> $GITHUB_OUTPUT
docker run -p 5432:5432 -e IASQL_ENV=ci --name iasql ghcr.io/iasql/iasql:$GITHUB_SHA &
while ! psql postgres://postgres:test@localhost:5432/iasql_metadata -b -q -c "SELECT iasql_engine_health()"; do sleep 1 && echo -n .; done;
# connect `iasql` db to aws account for `apply`
echo "\nCreating an iasql db..."
connectres=$(psql "postgres://postgres:test@localhost:5432/iasql_metadata" -t -c "SELECT json_agg(c)->0 FROM iasql_connect('iasql') as c;")
username=$(jq -r '.user' <<<"$connectres")
password=$(jq -r '.password' <<<"$connectres")
# Setup Account
echo "\nInstalling aws_account..."
psql $PSQL_CONN -c "
select iasql_install(
'aws_account'
);
";
echo "\nAttaching credentials..."
psql $PSQL_CONN -c "
INSERT INTO aws_credentials (access_key_id, secret_access_key)
VALUES ('${AWS_ACCESS_KEY_ID}', '${AWS_SECRET_ACCESS_KEY}');
";
# Start transaction
echo "\nStarting transaction..."
psql $PSQL_CONN -c "
select * from iasql_begin();
";
# Start transaction
echo "\nSynchronizing..."
psql $PSQL_CONN -c "
SELECT * FROM iasql_commit();
";
echo "\nInstalling all modules in iasql db..."
start=`date +%s.%N`
psql $PSQL_CONN -c "
select iasql_install(
variadic array(select module_name from iasql_modules_list())
);
";
end=`date +%s.%N`
echo "set-install-time=$( echo "$end - $start" | bc -l )" >> $GITHUB_OUTPUT
echo "\nUninstalling all modules in iasql db..."
start=`date +%s.%N`
psql $PSQL_CONN -c "
select iasql_uninstall(
variadic array(select module_name from iasql_modules_list())
);
";
end=`date +%s.%N`
echo "set-uninstall-time=$( echo "$end - $start" | bc -l )" >> $GITHUB_OUTPUT
# Shut down the container
docker container stop iasql
- name: Return test account
if: always()
env:
SECRET_HEADER: ${{ secrets.SECRET_HEADER }}
ACCOUNT_INDEX: ${{ steps['determine-test-account'].outputs['account_index'] }}
LAMBDA_FUNCTION: 'https://22quullhnmsrttacexxc74uium0nndzo.lambda-url.us-east-2.on.aws/'
run: |
curl -X POST -H "Content-Type: application/json" -H "${SECRET_HEADER}" -H "x-iasql-drop: true" -d "[${ACCOUNT_INDEX}]" ${LAMBDA_FUNCTION}
log-pr-debug-info:
runs-on: ubuntu-latest
needs:
- get-pr-debug-info
steps:
- uses: actions/checkout@v3
- uses: actions/github-script@v6
env:
COMPRESSED_IMAGE_SIZE: ${{ needs.get-pr-debug-info.outputs['compressed-image-size'] }}
UNCOMPRESSED_IMAGE_SIZE: ${{ needs.get-pr-debug-info.outputs['uncompressed-image-size'] }}
INSTALL_TIME: ${{ needs.get-pr-debug-info.outputs.install-time }}
UNINSTALL_TIME: ${{ needs.get-pr-debug-info.outputs.uninstall-time }}
with:
script: |
const script = require('./src/scripts/log-image-size.js')
await script({github, context, core})