forked from Allison-E/pg-age
-
Notifications
You must be signed in to change notification settings - Fork 1
115 lines (105 loc) · 3.89 KB
/
tests.yml
File metadata and controls
115 lines (105 loc) · 3.89 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
name: Run Tests
on:
workflow_dispatch:
pull_request:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- age_image: release_PG16_1.5.0
type: apache
- age_image: release_PG16_1.6.0
type: apache
- age_image: dev_snapshot_PG17
type: apache
- age_image: 16-1.5.0-standard-bookworm
type: cnpg
- age_image: 16-1.5.0-standard-trixie
type: cnpg
- age_image: 16-1.6.0-standard-bookworm
type: cnpg
- age_image: 16-1.6.0-standard-trixie
type: cnpg
- age_image: 17-1.6.0-standard-trixie
type: cnpg
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Start PostgreSQL with AGE extension
run: |
if [ "${{ matrix.type }}" = "cnpg" ]; then
docker run --name postgres-test-${{ matrix.age_image }} \
-e POSTGRES_PASSWORD=app \
-p 5432:5432 \
--shm-size=512mb \
-d ghcr.io/konnektr-io/age:${{ matrix.age_image }} \
bash -c "initdb -D /var/lib/postgresql/data --username=app --pwfile=<(echo app) && \
echo 'host all all 0.0.0.0/0 trust' >> /var/lib/postgresql/data/pg_hba.conf && \
echo 'local all all trust' >> /var/lib/postgresql/data/pg_hba.conf && \
postgres -D /var/lib/postgresql/data \
-c listen_addresses='*'"
else
docker run --name postgres-test-${{ matrix.age_image }} \
-e POSTGRES_USER=app \
-e POSTGRES_PASSWORD=app \
-e POSTGRES_DB=app \
-p 5432:5432 \
-d apache/age:${{ matrix.age_image }}
fi
- name: Run CNPG AGE init SQL
if: matrix.type == 'cnpg'
run: |
for i in {1..30}; do
if docker exec postgres-test-${{ matrix.age_image }} pg_isready -U app -d app; then
echo "PostgreSQL is ready for init";
break;
fi;
echo "Waiting for PostgreSQL (init)...";
sleep 5;
done
echo "Running initialization ..."
docker exec postgres-test-${{ matrix.age_image }} psql -U app -d app -c "CREATE EXTENSION age;"
docker exec postgres-test-${{ matrix.age_image }} psql -U app -d app -c "GRANT SELECT ON ag_catalog.ag_graph TO app;"
docker exec postgres-test-${{ matrix.age_image }} psql -U app -d app -c "GRANT USAGE ON SCHEMA ag_catalog TO app;"
echo "Database initialized successfully"
- name: Wait for PostgreSQL to be ready
if: matrix.type != 'cnpg'
run: |
for i in {1..30}; do
if docker exec postgres-test-${{ matrix.age_image }} pg_isready -U postgres -d app; then
echo "PostgreSQL is ready";
sleep 5;
exit 0;
fi;
echo "Waiting for PostgreSQL...";
sleep 5;
done
echo "PostgreSQL did not become ready in time";
exit 1;
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
6.0.x
8.0.x
9.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test with dotnet
run: |
if [ "${{ matrix.type }}" = "cnpg" ]; then
export CNPG_TEST=true
fi
dotnet test --logger 'GitHubActions' --logger 'console;verbosity=normal' --blame-hang --blame-hang-timeout 5m
- name: Stop PostgreSQL container
if: always()
run: |
docker stop postgres-test-${{ matrix.age_image }} || true
docker rm postgres-test-${{ matrix.age_image }} || true