Skip to content

Commit a5fb02d

Browse files
committed
Refactor CNPG AGE initialization step to check PostgreSQL readiness before executing SQL commands
1 parent 5d0f55d commit a5fb02d

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

.github/workflows/tests.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,6 @@ jobs:
3030
- age_image: ghcr.io/konnektr-io/age:17-1.6.0-standard-trixie
3131
type: cnpg
3232
steps:
33-
- name: Run CNPG AGE init SQL
34-
if: matrix.type == 'cnpg'
35-
run: |
36-
for i in {1..30}; do
37-
if docker exec postgres-test-cnpg pg_isready -U app -d app; then
38-
echo "PostgreSQL is ready for init";
39-
break;
40-
fi;
41-
echo "Waiting for PostgreSQL (init)...";
42-
sleep 5;
43-
done
44-
docker exec -u app postgres-test-cnpg psql -U app -d app -c "CREATE EXTENSION age;"
45-
docker exec -u app postgres-test-cnpg psql -U app -d app -c "GRANT SELECT ON ag_catalog.ag_graph TO app;"
46-
docker exec -u app postgres-test-cnpg psql -U app -d app -c "GRANT USAGE ON SCHEMA ag_catalog TO app;"
4733
- name: Checkout
4834
uses: actions/checkout@v4
4935

@@ -64,8 +50,24 @@ jobs:
6450
-p 5432:5432 \
6551
-d apache/age:${{ matrix.age_image }}
6652
fi
53+
54+
- name: Run CNPG AGE init SQL
55+
if: matrix.type == 'cnpg'
56+
run: |
57+
for i in {1..30}; do
58+
if docker exec postgres-test-cnpg pg_isready -U app -d app; then
59+
echo "PostgreSQL is ready for init";
60+
break;
61+
fi;
62+
echo "Waiting for PostgreSQL (init)...";
63+
sleep 5;
64+
done
65+
docker exec -u app postgres-test-cnpg psql -U app -d app -c "CREATE EXTENSION age;"
66+
docker exec -u app postgres-test-cnpg psql -U app -d app -c "GRANT SELECT ON ag_catalog.ag_graph TO app;"
67+
docker exec -u app postgres-test-cnpg psql -U app -d app -c "GRANT USAGE ON SCHEMA ag_catalog TO app;"
6768
6869
- name: Wait for PostgreSQL to be ready
70+
if: matrix.type != 'cnpg'
6971
run: |
7072
for i in {1..30}; do
7173
if docker exec postgres-test-${{ matrix.age_image }} pg_isready -U postgres -d app; then

0 commit comments

Comments
 (0)