Skip to content

Commit d87e9d9

Browse files
authored
Merge pull request #177 from stronk7/prepare_41_tests
Bump self-tests to 4.1 requirements
2 parents 07755aa + 4c896a5 commit d87e9d9

File tree

8 files changed

+57
-9
lines changed

8 files changed

+57
-9
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.dist.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:
@@ -20,6 +23,7 @@ php:
2023

2124
env:
2225
global:
26+
- PGVER=12
2327
- MOODLE_BRANCH=MOODLE_311_STABLE
2428
matrix:
2529
- DB=pgsql

.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

docs/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ The format of this change log follows the advice given at [Keep a CHANGELOG](htt
1212
### Added
1313
- `moodle-plugin-ci install` now provides an option `--db-port` to define a custom database port.
1414

15+
### Changed
16+
- Updated [gha.dist.yml](https://github.com/moodlehq/moodle-plugin-ci/blob/master/gha.dist.yml) and
17+
[.travis.dist.yml](https://github.com/moodlehq/moodle-plugin-ci/blob/master/.travis.dist.yml)
18+
(and documentation) to fulfil [Moodle 4.1 new requirements](https://tracker.moodle.org/browse/MDL-71747).
19+
- ACTION REQUIRED: Review existing integrations running tests against master (4.1dev). There are a few Moodle 4.1 new requirements:
20+
- PHP 7.4 is required (instead of 7.3).
21+
- PostgreSQL 12 is required (instead of 10). Pay special attention to the changes needed for this and Travis!
22+
- MariaDB 10.4 is required (instead of 10.2.29).
23+
- Oracle 19 is required (instead of 11.2).
24+
1525
## [3.3.0] - 2022-06-28
1626
### Added
1727
- PHPUnit code coverage will now automatically fallback between `pcov` => `xdebug` => `phpdbg`, using the "best" one available in the system. Still, if needed to, any of them can be forced, given all their requirements are fulfilled, using the following new options of the 'phpunit' command: `--coverage-pcov`, `--coverage-xdebug` or `--coverage-phpdbg`.

docs/GHAFileExplained.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
# DB services you need for testing.
3232
services:
3333
postgres:
34-
image: postgres:10
34+
image: postgres:12
3535
env:
3636
POSTGRES_USER: 'postgres'
3737
POSTGRES_HOST_AUTH_METHOD: 'trust'

docs/TravisFileExplained.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,15 @@ language: php
1313

1414
# Installs the updated version of PostgreSQL and extra APT packages.
1515
addons:
16-
postgresql: "10"
16+
postgresql: "12"
17+
apt:
18+
packages:
19+
- postgresql-12
20+
- postgresql-client-12
1721

1822
# Ensure DB and docker services are running.
1923
services:
2024
- mysql
21-
- postgresql
2225
- docker
2326

2427
# Cache Composer's and NPM's caches to speed up build times.
@@ -38,6 +41,11 @@ php:
3841
# This section sets up the environment variables for the build.
3942
env:
4043
global:
44+
# This line instructs moodle-plugin-ci the version of PostgreSQL being
45+
# used, because, for PG 11 and up, both the user and the port were
46+
# changed by Travis. With that variable, the tool will switch to
47+
# socketed connections instead of localhost ones.
48+
- PGVER=12
4149
# This line determines which version branch of Moodle to test against.
4250
- MOODLE_BRANCH=MOODLE_311_STABLE
4351
# This matrix is used for testing against multiple databases. So for

gha.dist.yml

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

99
services:
1010
postgres:
11-
image: postgres:10
11+
image: postgres:12
1212
env:
1313
POSTGRES_USER: 'postgres'
1414
POSTGRES_HOST_AUTH_METHOD: 'trust'

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)