Skip to content

Commit 20c18a4

Browse files
committed
refactor: Update runtime test scripts and workflows for PostgreSQL version compatibility
1 parent 45ed32c commit 20c18a4

9 files changed

Lines changed: 20 additions & 33 deletions

File tree

.docker/runtime-test.sh

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,19 @@ POSTGRES_VERSION="${POSTGRES_VERSION:-18}"
66
IMAGE="${IMAGE:-postgres-extensor-runtime-test}"
77
CONTAINER_NAME="${CONTAINER_NAME:-postgres-extensor-runtime-test-$$}"
88

9-
cleanup() {
10-
docker rm -f "${CONTAINER_NAME}" >/dev/null 2>&1 || true
11-
}
12-
13-
trap cleanup EXIT
9+
trap 'docker rm -f "${CONTAINER_NAME}" >/dev/null 2>&1 || true' EXIT
1410

1511
if [ "${SKIP_BUILD:-false}" != "true" ]; then
1612
docker build -f .docker/Dockerfile -t "${IMAGE}" --build-arg POSTGRES_VERSION="${POSTGRES_VERSION}" .
1713
fi
1814

19-
docker run -d --rm --name "${CONTAINER_NAME}" \
20-
-e POSTGRES_PASSWORD=postgres \
21-
-e POSTGRES_DB=postgres \
22-
"${IMAGE}" >/dev/null
15+
docker run -d --rm --name "${CONTAINER_NAME}" -e POSTGRES_PASSWORD=postgres "${IMAGE}" >/dev/null
2316

24-
for _ in $(seq 1 30); do
25-
if docker exec "${CONTAINER_NAME}" pg_isready -U postgres >/dev/null 2>&1; then
26-
break
27-
fi
17+
echo "Waiting for PostgreSQL to start..."
18+
until docker exec "${CONTAINER_NAME}" pg_isready -U postgres >/dev/null 2>&1; do
2819
sleep 1
2920
done
3021

31-
if ! docker exec "${CONTAINER_NAME}" pg_isready -U postgres >/dev/null 2>&1; then
32-
echo "PostgreSQL did not become ready in time" >&2
33-
exit 1
34-
fi
35-
36-
docker exec -i "${CONTAINER_NAME}" psql -v ON_ERROR_STOP=1 -U postgres -d postgres <<'SQL'
37-
CREATE EXTENSION IF NOT EXISTS vector;
38-
CREATE EXTENSION IF NOT EXISTS pgmq;
39-
CREATE EXTENSION IF NOT EXISTS postgis;
40-
41-
SELECT extname FROM pg_extension WHERE extname IN ('vector','pgmq','postgis');
42-
SELECT name FROM pg_available_extensions WHERE name IN ('pg_stat_statements');
43-
SQL
22+
echo "Running SQL tests..."
23+
docker exec -i "${CONTAINER_NAME}" psql -v ON_ERROR_STOP=1 -U postgres < .docker/runtime-test.sql
24+
echo "Tests passed successfully!"

.docker/runtime-test.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CREATE EXTENSION IF NOT EXISTS vector;
2+
CREATE EXTENSION IF NOT EXISTS pgmq;
3+
CREATE EXTENSION IF NOT EXISTS postgis;
4+
5+
SELECT extname FROM pg_extension WHERE extname IN ('vector','pgmq','postgis');
6+
SELECT name FROM pg_available_extensions WHERE name IN ('pg_stat_statements');

.github/workflows/docker-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
postgres_version: ["latest", "18", "17", "16", "15", "14", "13"]
14+
postgres_version: ["latest", "18", "17", "16", "15", "14"]
1515
fail-fast: false
1616

1717
steps:

.github/workflows/pr-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
runs-on: ubuntu-latest
1919
strategy:
2020
matrix:
21-
postgres_version: ["latest", "18", "17", "16", "15", "14", "13"]
21+
postgres_version: ["latest", "18", "17", "16", "15", "14"]
2222
platform: ["linux/amd64"]
2323
fail-fast: false
2424

extensions/builddeps_install.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
var buildDepsInstall = plyd.New(
1111
"build-deps-install",
1212
plyd.NewHandlersList(
13-
plyd.NewHandler(">=13.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
13+
plyd.NewHandler(">=14.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
1414
if err := plyd.Run("apt-get update -qq"); err != nil {
1515
return err
1616
}

extensions/builddeps_remove.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
var buildDepsRemove = plyd.New(
1111
"build-deps-remove",
1212
plyd.NewHandlersList(
13-
plyd.NewHandler(">=13.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
13+
plyd.NewHandler(">=14.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
1414
if err := plyd.Run(fmt.Sprintf(
1515
"apt-get remove -y -qq git make gcc postgresql-server-dev-%s",
1616
ins.PostgreSQL.Mayor,

extensions/pgvector.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
var pgvector = plyd.New(
1111
"pgvector",
1212
plyd.NewHandlersList(
13-
plyd.NewHandler(">=13.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
13+
plyd.NewHandler(">=14.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
1414
err := plyd.Run(
1515
"git clone --branch v0.8.2 --depth 1 " +
1616
"https://github.com/pgvector/pgvector.git /tmp/pgvector",

extensions/postgis.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
var postgis = plyd.New(
1111
"postgis",
1212
plyd.NewHandlersList(
13-
plyd.NewHandler(">=13.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
13+
plyd.NewHandler(">=14.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
1414
pkg := fmt.Sprintf("postgresql-%s-postgis-3", ins.PostgreSQL.Mayor)
1515
if err := plyd.Run(fmt.Sprintf("apt-get install -y -qq %s", pkg)); err != nil {
1616
return err

extensions/postgrescontrib.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
var postgresContrib = plyd.New(
1111
"postgres-contrib",
1212
plyd.NewHandlersList(
13-
plyd.NewHandler(">=13.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
13+
plyd.NewHandler(">=14.0.0, <19.0.0", func(ins *instance.InstanceInfo) error {
1414
// In Debian/Ubuntu pgdg distributions, contrib modules are bundled within the main postgresql package.
1515
pkg := fmt.Sprintf("postgresql-%s", ins.PostgreSQL.Mayor)
1616
if err := plyd.Run(fmt.Sprintf("apt-get install -y -qq %s", pkg)); err != nil {

0 commit comments

Comments
 (0)