44 push :
55 pull_request :
66
7+ env :
8+ PG_MAJOR : " 16"
9+
710jobs :
811 test :
912 runs-on : ubuntu-latest
@@ -13,30 +16,42 @@ jobs:
1316 - name : Install PostgreSQL and development headers
1417 run : |
1518 sudo apt-get update
16- # Server, contrib modules, client library and the PGXS build headers
17- sudo apt-get install -y postgresql postgresql-contrib libpq-dev postgresql-server-dev-all
18-
19- - name : Start PostgreSQL
19+ # The GitHub runner image already has the PGDG apt repo and a newer
20+ # postgresql-common, which conflicts with the archive's
21+ # postgresql-server-dev-all meta-package. Install versioned packages
22+ # so apt stays on the PGDG line.
23+ sudo apt-get install -y \
24+ "postgresql-${PG_MAJOR}" \
25+ "postgresql-server-dev-${PG_MAJOR}" \
26+ libpq-dev
27+
28+ - name : Start the PostgreSQL cluster
2029 run : |
21- # Determine the installed major version and start the default cluster
22- PG_MAJOR=$(pg_config --version | awk '{print $2}' | cut -d. -f1)
23- echo "PG_MAJOR=$PG_MAJOR" >> "$GITHUB_ENV"
24- sudo pg_ctlcluster "$PG_MAJOR" main start
30+ # The cluster may already exist on the runner; create it only if not.
31+ if ! pg_lsclusters -h | awk '{print $1, $2}' | grep -qx "${PG_MAJOR} main"; then
32+ sudo pg_createcluster "${PG_MAJOR}" main
33+ fi
34+ sudo pg_ctlcluster "${PG_MAJOR}" main start || true
35+ # Whatever port the cluster ended up on, route all later steps to it.
36+ PORT=$(pg_lsclusters -h | awk -v v="${PG_MAJOR}" '$1==v && $2=="main" {print $3}')
37+ echo "PGHOST=/var/run/postgresql" >> "$GITHUB_ENV"
38+ echo "PGPORT=$PORT" >> "$GITHUB_ENV"
2539
2640 - name : Create a superuser role for the runner
2741 run : |
2842 # pg_regress connects over the local socket as the current OS user via
2943 # peer authentication, so that user needs a matching superuser role.
30- sudo -u postgres createuser --superuser "$(whoami)"
31- sudo -u postgres createdb "$(whoami)"
44+ sudo -u postgres psql -p "$PGPORT" -d postgres \
45+ -c "CREATE ROLE \"$(whoami)\" SUPERUSER LOGIN;" || true
46+ sudo -u postgres createdb -p "$PGPORT" -O "$(whoami)" "$(whoami)" || true
3247
3348 - name : Build and install the extension
3449 run : |
35- make
36- sudo make install
50+ make PG_CONFIG="/usr/lib/postgresql/${PG_MAJOR}/bin/pg_config"
51+ sudo make PG_CONFIG="/usr/lib/postgresql/${PG_MAJOR}/bin/pg_config" install
3752
3853 - name : Run regression tests
39- run : make installcheck
54+ run : make PG_CONFIG="/usr/lib/postgresql/${PG_MAJOR}/bin/pg_config" installcheck
4055
4156 - name : Show regression diffs on failure
4257 if : failure()
0 commit comments