Skip to content

Commit 60a5ab7

Browse files
committed
Add waiting for server start and some refactoring.
1 parent 4527c37 commit 60a5ab7

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

.github/workflows/test.yml

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,53 @@ on:
99

1010
jobs:
1111
test:
12+
runs-on: ubuntu-latest
13+
1214
strategy:
15+
fail-fast: false
1316
matrix:
1417
pg_version: [12, 13, 14, 15, 16, 17]
15-
os: [ubuntu-22.04]
1618
build: [automake, meson]
17-
tests: [sql]
18-
fail-fast: false
19-
runs-on: ubuntu-latest
19+
2020
container:
21-
image: ubuntu:22.04 # main job container
21+
image: ubuntu:22.04
2222
options: --user root
23+
2324
services:
2425
postgres:
2526
image: postgres:${{ matrix.pg_version }}
2627
env:
2728
POSTGRES_PASSWORD: postgres
28-
ports:
29-
- 5432:5432
30-
options: >-
31-
--health-cmd "pg_isready -U postgres"
32-
--health-interval 5s
33-
--health-timeout 5s
34-
--health-retries 5
3529

3630
steps:
37-
# Checkout shared_ispell
38-
- name: Checkout shared_ispell
39-
uses: actions/checkout@v3
31+
- uses: actions/checkout@v3
4032

41-
# Install build tools and headers
42-
- name: Install build tools and PostgreSQL dev headers
33+
- name: Install dependencies
4334
run: |
4435
apt-get update
4536
apt-get install -y wget gnupg lsb-release
4637
47-
# Add PostgreSQL APT repo
4838
echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" \
4939
> /etc/apt/sources.list.d/pgdg.list
5040
5141
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
5242
5343
apt-get update
54-
55-
# Install everything
5644
apt-get install -y \
5745
build-essential automake meson ninja-build pkg-config libxml2-dev \
58-
postgresql-server-dev-${{ matrix.pg_version }}
46+
postgresql-server-dev-${{ matrix.pg_version }} \
47+
postgresql-client-${{ matrix.pg_version }}
5948
60-
# Set PG_CONFIG to container's Postgres
6149
- name: Set PG_CONFIG
62-
run: echo "PG_CONFIG=$(which pg_config)" >> $GITHUB_ENV
50+
run: |
51+
echo "PG_CONFIG=/usr/lib/postgresql/${{ matrix.pg_version }}/bin/pg_config" >> $GITHUB_ENV
6352
64-
# Build shared_ispell (automake)
6553
- name: Build (automake)
6654
if: matrix.build == 'automake'
6755
run: |
6856
make USE_PGXS=1
6957
make USE_PGXS=1 install
7058
71-
# Build shared_ispell (meson)
7259
- name: Build (meson)
7360
if: matrix.build == 'meson'
7461
run: |
@@ -77,21 +64,25 @@ jobs:
7764
meson compile -C builddir
7865
meson install -C builddir
7966
80-
# Create extension
81-
- name: Create extension
67+
- name: Wait for PostgreSQL
8268
run: |
83-
export PGUSER=postgres
84-
export PGPASSWORD=postgres
85-
createdb -h localhost -p 5432 test
86-
psql -h localhost -p 5432 -U postgres -d test -c "CREATE EXTENSION shared_ispell;"
69+
for i in {1..30}; do
70+
if pg_isready -h postgres -U postgres; then
71+
exit 0
72+
fi
73+
sleep 2
74+
done
75+
exit 1
8776
88-
# Run SQL tests
89-
- name: Run SQL tests
77+
- name: Create extension and run SQL tests
9078
run: |
9179
export PGUSER=postgres
9280
export PGPASSWORD=postgres
81+
82+
createdb -h postgres test
83+
psql -h postgres -d test -c "CREATE EXTENSION shared_ispell;"
84+
9385
for f in sql/*.sql; do
9486
echo "Running $f"
95-
psql -h localhost -p 5432 -U postgres -d test -f "$f"
87+
psql -h postgres -d test -f "$f"
9688
done
97-

0 commit comments

Comments
 (0)