Skip to content

Commit 2020ea9

Browse files
committed
Ensure dbs are migrated before seeding
1 parent 4eb839a commit 2020ea9

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
name: "Seed infrastructure links"
22
description:
33
"Seeds infrastructure links needed in e2e tests"
4+
inputs:
5+
db_connection_string:
6+
description: Database connection string
7+
required: false
8+
default: "postgresql://dbadmin:adminpassword@localhost:5432/jore4e2e"
49

510
runs:
611
using: "composite"
@@ -11,50 +16,50 @@ runs:
1116
curl https://raw.githubusercontent.com/HSLdevcom/jore4-ui/main/test-db-manager/src/dumps/infraLinks/infraLinks.sql \
1217
-o infraLinks.sql
1318
14-
- name: Verify that postgresql is up and running
19+
- name: Verify that testdb is up, running and migrated
1520
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
1621
with:
17-
command: "pg_isready -h localhost -p 6432"
22+
command: "[[ $(docker exec testdb psql ${{ inputs.db_connection_string }} -AXqtc \"SELECT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'infrastructure_network' AND tablename = 'infrastructure_link');\") = \"t\" ]]"
1823
# it takes a while for the database to start
1924
retries: 50
2025

21-
- name: Verify that postgresql testdb-e2e1 is up and running
26+
- name: Verify that testdb-e2e1 is up, running and migrated
2227
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
2328
with:
24-
command: "pg_isready -h localhost -p 6532"
29+
command: "[[ $(docker exec testdb-e2e1 psql ${{ inputs.db_connection_string }} -AXqtc \"SELECT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'infrastructure_network' AND tablename = 'infrastructure_link');\") = \"t\" ]]"
2530
# it takes a while for the database to start
2631
retries: 50
27-
28-
- name: Verify that postgresql testdb-e2e2 is up and running
32+
33+
- name: Verify that testdb-e2e2 is up, running and migrated
2934
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
3035
with:
31-
command: "pg_isready -h localhost -p 6533"
36+
command: "[[ $(docker exec testdb-e2e2 psql ${{ inputs.db_connection_string }} -AXqtc \"SELECT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'infrastructure_network' AND tablename = 'infrastructure_link');\") = \"t\" ]]"
3237
# it takes a while for the database to start
3338
retries: 50
3439

35-
- name: Verify that postgresql testdb-e2e3 is up and running
40+
- name: Verify that testdb-e2e3 is up, running and migrated
3641
uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
3742
with:
38-
command: "pg_isready -h localhost -p 6534"
43+
command: "[[ $(docker exec testdb-e2e3 psql ${{ inputs.db_connection_string }} -AXqtc \"SELECT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'infrastructure_network' AND tablename = 'infrastructure_link');\") = \"t\" ]]"
3944
# it takes a while for the database to start
4045
retries: 50
4146

4247
- name: Seed db1 with infrastructure links
4348
shell: bash
4449
run: |
45-
docker exec -i testdb psql postgresql://dbadmin:adminpassword@localhost:5432/jore4e2e < infraLinks.sql
50+
docker exec -i testdb psql ${{ inputs.db_connection_string }} < infraLinks.sql
4651
4752
- name: Seed db2 with infrastructure links
4853
shell: bash
4954
run: |
50-
docker exec -i testdb-e2e1 psql postgresql://dbadmin:adminpassword@localhost:5432/jore4e2e < infraLinks.sql
55+
docker exec -i testdb-e2e1 psql ${{ inputs.db_connection_string }} < infraLinks.sql
5156
5257
- name: Seed db3 with infrastructure links
5358
shell: bash
5459
run: |
55-
docker exec -i testdb-e2e2 psql postgresql://dbadmin:adminpassword@localhost:5432/jore4e2e < infraLinks.sql
60+
docker exec -i testdb-e2e2 psql ${{ inputs.db_connection_string }} < infraLinks.sql
5661
5762
- name: Seed db4 with infrastructure links
5863
shell: bash
5964
run: |
60-
docker exec -i testdb-e2e3 psql postgresql://dbadmin:adminpassword@localhost:5432/jore4e2e < infraLinks.sql
65+
docker exec -i testdb-e2e3 psql ${{ inputs.db_connection_string }} < infraLinks.sql

0 commit comments

Comments
 (0)