Skip to content

Commit 36164ba

Browse files
committed
Bump self-tests to 4.1 requirements
Trivial for GHA, just change of images to postgres:12, but... Travis changed the PostgreSQL package for version 11 and up so, instead of using the "postgres" user it now uses the "travis" one. And the port is 5433 instead of 5432. We use the existence of the PGVER environmental variable to decide which defaults to use. More yet, the connection via "localhost" (local net) now requires login and password, it used to be trust/peer auth mode (not requiring password). If we want to keep localhost (+ port) working, then we need to edit the pg_hba.conf file to trust/peer the local connections and then restart the database. So, at the end, we are going to use socket connections (host = '') that is perfectly ok for Travis (non dockered database). Only if they haven't been configured another way manually (user, host, port).
1 parent 07755aa commit 36164ba

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232

3333
services:
3434
postgres:
35-
image: postgres:10
35+
image: postgres:12
3636
env:
3737
POSTGRES_USER: 'postgres'
3838
POSTGRES_HOST_AUTH_METHOD: 'trust'

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
language: php
22

33
addons:
4-
postgresql: "10"
4+
postgresql: "12"
5+
apt:
6+
packages:
7+
- postgresql-12
8+
- postgresql-client-12
59

610
services:
711
- mysql
8-
- postgresql
912
- docker
1013

1114
cache:
@@ -18,6 +21,7 @@ php:
1821

1922
env:
2023
global:
24+
- PGVER=12
2125
- IGNORE_PATHS=ignore
2226
- IGNORE_NAMES=ignore_name.php
2327
- MUSTACHE_IGNORE_NAMES=broken.mustache

src/Installer/Database/PostgresDatabase.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@ class PostgresDatabase extends AbstractDatabase
2222

2323
public function getCreateDatabaseCommand()
2424
{
25+
// Travis changed the PostgreSQL package for version 11 and up so, instead of
26+
// using the "postgres" user it now uses the "travis" one. And the port is
27+
// 5433 instead of 5432. We use the existence of the PGVER environmental
28+
// variable to decide which defaults to use.
29+
//
30+
// More yet, the connection via "localhost" (local net) now requires login and
31+
// password, it used to be trust/peer auth mode (not requiring password). If we want to
32+
// keep localhost (+ port) working, then we need to edit the pg_hba.conf file
33+
// to trust/peer the local connections and then restart the database.
34+
//
35+
// So, at the end, we are going to use socket connections (host = '')
36+
// that is perfectly ok for Travis (non dockered database). Only if they
37+
// haven't been configured another way manually (user, host, port).
38+
if ($this->user === 'postgres' && getenv('PGVER') && is_numeric(getenv('PGVER')) && getenv('PGVER') >= 11) {
39+
$this->user = 'travis';
40+
if ($this->port === '') { // Only if the port is not set.
41+
if ($this->host === 'localhost') {
42+
$this->host = ''; // Use sockets or we'll need to edit pg_hba.conf and restart the server. Only if not set.
43+
$this->port = '5433'; // We also need the port to find the correct socket file.
44+
}
45+
}
46+
}
2547
$pass = !empty($this->pass) ? 'env PGPASSWORD='.escapeshellarg($this->pass).' ' : '';
2648
$user = escapeshellarg($this->user);
2749
$host = escapeshellarg($this->host);

0 commit comments

Comments
 (0)