Skip to content

Commit 5ff9c69

Browse files
committed
ci(postgresql): stop installing system PG before tests so issue #112 path is exercised
The PostgreSQL integration jobs (postgresql-test, the ts-PostgreSQL step, and proxysql-postgresql) previously did: sudo apt-get install -y postgresql-16 postgresql-client-16 cp -a /usr/lib/postgresql/16/bin/. ~/opt/postgresql/<v>/bin/ cp -a /usr/lib/postgresql/16/lib/. ~/opt/postgresql/<v>/lib/ cp -a /usr/share/postgresql/16/. ~/opt/postgresql/<v>/share/ This created /usr/share/postgresql/16/ on the runner as a side effect of installing the server package. When PG's make_relative_path() failed to relocate SHAREDIR (the issue #112 bug), it fell back to that absolute compiled-in path — which happened to exist because of the install — and the tests passed. The CI was silently testing the wrong layout. This change switches all three jobs to the documented user flow: sudo apt-get install -y libpq5 # only psql's dynamic dep apt-get download postgresql-NN postgresql-client-NN ./dbdeployer unpack --provider=postgresql ... Plus an explicit guard: each step now fails if /usr/share/postgresql/NN/ exists after setup, so this masking can't silently recur. Depends on the fix in PR #117. Without that, the postgresql-test job fails with the timezonesets error — which is exactly the regression this CI change is designed to catch.
1 parent a0d3dff commit 5ff9c69

2 files changed

Lines changed: 61 additions & 31 deletions

File tree

.github/workflows/integration_tests.yml

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -520,22 +520,32 @@ jobs:
520520
rm -rf "$HOME/sandboxes"/*
521521
echo '{}' > "$HOME/.dbdeployer/sandboxes.json"
522522
523-
- name: Install PostgreSQL for ts tests
523+
- name: Download and unpack PostgreSQL debs for ts tests (no system install)
524524
run: |
525525
# Add PostgreSQL apt repo (PGDG) — required for postgresql-16 on ubuntu-22.04
526526
sudo apt-get install -y curl ca-certificates
527527
sudo install -d /usr/share/postgresql-common/pgdg
528528
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
529529
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
530530
sudo apt-get update
531-
sudo apt-get install -y postgresql-16 postgresql-client-16
532-
sudo systemctl stop postgresql || true
531+
532+
# Install libpq5 only — psql links against it dynamically. We do
533+
# NOT install postgresql-16 itself, since that would put
534+
# /usr/share/postgresql/16/ on the runner and mask issue #112.
535+
sudo apt-get install -y libpq5
536+
537+
# Documented user flow: download the debs, then unpack via dbdeployer.
533538
export HOME="$GITHUB_WORKSPACE/home"
534-
PG_FULL=$(dpkg -s postgresql-16 | grep '^Version:' | sed 's/Version: //' | cut -d'-' -f1)
535-
mkdir -p "$HOME/opt/postgresql/${PG_FULL}/"{bin,lib,share}
536-
cp -a /usr/lib/postgresql/16/bin/. "$HOME/opt/postgresql/${PG_FULL}/bin/"
537-
cp -a /usr/lib/postgresql/16/lib/. "$HOME/opt/postgresql/${PG_FULL}/lib/"
538-
cp -a /usr/share/postgresql/16/. "$HOME/opt/postgresql/${PG_FULL}/share/"
539+
mkdir -p "$HOME"
540+
apt-get download postgresql-16 postgresql-client-16
541+
./dbdeployer unpack --provider=postgresql \
542+
postgresql-16_*.deb postgresql-client-16_*.deb
543+
544+
# Sanity: confirm no system PG install snuck in via dependencies.
545+
if [ -d "/usr/share/postgresql/16" ]; then
546+
echo "FAIL: /usr/share/postgresql/16/ exists — system PG install is masking issue #112"
547+
exit 1
548+
fi
539549
540550
- name: Run ts PostgreSQL tests
541551
env:
@@ -586,20 +596,32 @@ jobs:
586596
- name: Build dbdeployer
587597
run: go build -o dbdeployer .
588598

589-
- name: Install PostgreSQL and set up binaries
590-
run: |
591-
# Install PostgreSQL to get properly configured binaries
592-
sudo apt-get install -y postgresql-${PG_VERSION} postgresql-client-${PG_VERSION}
593-
# Stop the system service — we'll manage our own instances
594-
sudo systemctl stop postgresql || true
595-
# Get full version and copy binaries into dbdeployer's expected layout
596-
PG_FULL=$(dpkg -s postgresql-${PG_VERSION} | grep '^Version:' | sed 's/Version: //' | cut -d'-' -f1)
597-
echo "PostgreSQL version: ${PG_FULL}"
598-
mkdir -p ~/opt/postgresql/${PG_FULL}/{bin,lib,share}
599-
cp -a /usr/lib/postgresql/${PG_VERSION}/bin/. ~/opt/postgresql/${PG_FULL}/bin/
600-
cp -a /usr/lib/postgresql/${PG_VERSION}/lib/. ~/opt/postgresql/${PG_FULL}/lib/
601-
cp -a /usr/share/postgresql/${PG_VERSION}/. ~/opt/postgresql/${PG_FULL}/share/
602-
ls ~/opt/postgresql/${PG_FULL}/bin/
599+
- name: Download and unpack PostgreSQL debs (no system install)
600+
run: |
601+
# Install libpq5 only — psql links against it dynamically at runtime.
602+
# Deliberately DO NOT install postgresql-${PG_VERSION} or
603+
# postgresql-client-${PG_VERSION}: that would create
604+
# /usr/share/postgresql/${PG_VERSION}/ on the runner, which masks
605+
# issue #112 by letting PG fall back to the absolute compiled-in
606+
# SHAREDIR rather than exercising dbdeployer's relocation layout.
607+
sudo apt-get install -y libpq5
608+
609+
# Documented user flow from README:
610+
# apt-get download postgresql-NN postgresql-client-NN
611+
# dbdeployer unpack --provider=postgresql ...
612+
apt-get download postgresql-${PG_VERSION} postgresql-client-${PG_VERSION}
613+
./dbdeployer unpack --provider=postgresql \
614+
postgresql-${PG_VERSION}_*.deb \
615+
postgresql-client-${PG_VERSION}_*.deb
616+
ls ~/opt/postgresql/
617+
618+
# Sanity: confirm we did NOT install postgresql-server side-effects.
619+
# If /usr/share/postgresql/${PG_VERSION}/ exists, the test is no
620+
# longer exercising the relocation path that issue #112 was about.
621+
if [ -d "/usr/share/postgresql/${PG_VERSION}" ]; then
622+
echo "FAIL: /usr/share/postgresql/${PG_VERSION}/ exists — system PG install is masking issue #112"
623+
exit 1
624+
fi
603625
604626
- name: Test init --provider=postgresql
605627
run: |

.github/workflows/proxysql_integration_tests.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -402,16 +402,24 @@ jobs:
402402
- name: Build dbdeployer
403403
run: go build -o dbdeployer .
404404

405-
- name: Install PostgreSQL and set up binaries
405+
- name: Download and unpack PostgreSQL debs (no system install)
406406
run: |
407-
sudo apt-get install -y postgresql-16 postgresql-client-16
408-
sudo systemctl stop postgresql || true
409-
PG_FULL=$(dpkg -s postgresql-16 | grep '^Version:' | sed 's/Version: //' | cut -d'-' -f1)
410-
echo "PostgreSQL version: ${PG_FULL}"
411-
mkdir -p ~/opt/postgresql/${PG_FULL}/{bin,lib,share}
412-
cp -a /usr/lib/postgresql/16/bin/. ~/opt/postgresql/${PG_FULL}/bin/
413-
cp -a /usr/lib/postgresql/16/lib/. ~/opt/postgresql/${PG_FULL}/lib/
414-
cp -a /usr/share/postgresql/16/. ~/opt/postgresql/${PG_FULL}/share/
407+
# Install libpq5 only — psql links against it dynamically at runtime.
408+
# We do NOT install postgresql-16 itself, since that would create
409+
# /usr/share/postgresql/16/ on the runner and mask issue #112.
410+
sudo apt-get install -y libpq5
411+
412+
# Documented user flow: download the debs, then unpack via dbdeployer.
413+
apt-get download postgresql-16 postgresql-client-16
414+
./dbdeployer unpack --provider=postgresql \
415+
postgresql-16_*.deb postgresql-client-16_*.deb
416+
ls ~/opt/postgresql/
417+
418+
# Sanity: confirm no system PG install snuck in via dependencies.
419+
if [ -d "/usr/share/postgresql/16" ]; then
420+
echo "FAIL: /usr/share/postgresql/16/ exists — system PG install is masking issue #112"
421+
exit 1
422+
fi
415423
416424
- name: Test replication with --with-proxysql
417425
run: |

0 commit comments

Comments
 (0)