Skip to content

Commit 4d8f9f3

Browse files
committed
add(CI): MySQL and PgSQL
1 parent 83722c4 commit 4d8f9f3

5 files changed

Lines changed: 78 additions & 19 deletions

File tree

‎.github/docker/ci/Dockerfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# installer, the migrations and the seeded data, and the built in web server is
77
# enough to prove the installed site answers. Which web server serves it is what
88
# the Salo images in .github/docker/Dockerfile are for.
9-
ARG PHP_VERSION=8.4
9+
ARG PHP_VERSION=8.3
1010
FROM php:${PHP_VERSION}-cli
1111

1212
# libpq/libzip/libicu are the build inputs of the extensions below; the -dev

‎.github/docker/ci/README.md‎

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,27 @@ Clean up with `docker compose -f .github/docker/ci/docker-compose.yml --profile
1818
<mysql|pgsql> down -v`. The container works on a copy of the tree, not a bind
1919
mount, so a run leaves the working tree alone.
2020

21-
`PHP_VERSION`, `MYSQL_IMAGE_TAG` and `POSTGRES_IMAGE_TAG` override the defaults
22-
(PHP 8.4, MySQL 9.7 LTS, PostgreSQL 18.6 LTS). CI runs both databases against
23-
PHP 8.3 and 8.4 — see the `install` job in `.github/workflows/ci.yml`.
21+
`PHP_VERSION`, `MYSQL_IMAGE_TAG`, `POSTGRES_IMAGE_TAG`, `MYSQL_PORT` and
22+
`POSTGRES_PORT` override the defaults (PHP 8.3, MySQL 9.7 LTS, PostgreSQL 18.6
23+
LTS, the servers' own ports).
24+
25+
## What CI runs
26+
27+
The `install` job in `.github/workflows/ci.yml` does not use the image above.
28+
It starts only the database service from this compose file — an official image,
29+
pulled, never built — and runs `install-and-smoke.sh` directly on the runner,
30+
whose PHP `shivammathur/setup-php` already provides with `pdo_mysql` and
31+
`pdo_pgsql` prebuilt. Building the image there would spend two or three minutes
32+
per leg compiling extensions the runner hands over ready-made, on every push.
33+
34+
The script only needs `EVO_DB_*` and a reachable server, so both paths run the
35+
same checks; the image is what makes a local run reproducible on a machine with
36+
no PHP on it, and what pins the PHP version when a version question is the one
37+
being investigated.
38+
39+
One PHP version, both databases: what the job proves is the installer's MySQL
40+
and PostgreSQL paths, which do not vary with the PHP minor. 8.3 and 8.4 are both
41+
covered by the analysis and unit test jobs.
2442

2543
## What a run asserts
2644

‎.github/docker/ci/docker-compose.yml‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ services:
1414
profiles: [mysql]
1515
# 9.7 is the LTS of the MySQL 9 series.
1616
image: mysql:${MYSQL_IMAGE_TAG:-9.7}
17+
# Published so the installer can also be driven from the host - which is
18+
# what CI does, to avoid building a PHP image for something the runner
19+
# already has. The install-* services below reach it over the network
20+
# compose creates and ignore this.
21+
ports:
22+
- "${MYSQL_PORT:-3306}:3306"
1723
environment:
1824
MYSQL_ROOT_PASSWORD: secret
1925
# No MYSQL_DATABASE on purpose: the installer is meant to create the
@@ -29,6 +35,8 @@ services:
2935
pgsql:
3036
profiles: [pgsql]
3137
image: postgres:${POSTGRES_IMAGE_TAG:-18.6}
38+
ports:
39+
- "${POSTGRES_PORT:-5432}:5432"
3240
environment:
3341
POSTGRES_USER: evo
3442
POSTGRES_PASSWORD: secret
@@ -49,7 +57,7 @@ services:
4957
context: ../../..
5058
dockerfile: .github/docker/ci/Dockerfile
5159
args:
52-
PHP_VERSION: ${PHP_VERSION:-8.4}
60+
PHP_VERSION: ${PHP_VERSION:-8.3}
5361
depends_on:
5462
mysql:
5563
condition: service_healthy
@@ -67,7 +75,7 @@ services:
6775
context: ../../..
6876
dockerfile: .github/docker/ci/Dockerfile
6977
args:
70-
PHP_VERSION: ${PHP_VERSION:-8.4}
78+
PHP_VERSION: ${PHP_VERSION:-8.3}
7179
depends_on:
7280
pgsql:
7381
condition: service_healthy

‎.github/docker/ci/install-and-smoke.sh‎

100644100755
File mode changed.

‎.github/workflows/ci.yml‎

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,32 +93,65 @@ jobs:
9393
run: composer test -- --compact
9494

9595
install:
96-
name: Install on ${{ matrix.db }} (PHP ${{ matrix.php }})
96+
name: Install on ${{ matrix.db }}
9797
runs-on: ubuntu-latest
9898
strategy:
9999
fail-fast: false
100100
matrix:
101101
# The two database servers the CLI installer supports besides sqlite,
102102
# each on its current long term release. The sqlite path is covered by
103103
# the build workflow, which installs on it to produce the nightly zip.
104-
db: [mysql, pgsql]
105-
php: ['8.3', '8.4']
104+
# One PHP version only: what this job proves is the installer's MySQL
105+
# and PostgreSQL paths, and those do not vary with the PHP minor. The
106+
# matrix above already runs the analysis and the tests on both.
107+
include:
108+
- db: mysql
109+
user: root
110+
password: secret
111+
- db: pgsql
112+
user: evo
113+
password: secret
106114
env:
107115
COMPOSE: .github/docker/ci/docker-compose.yml
108-
PHP_VERSION: ${{ matrix.php }}
109116
steps:
110117
- uses: actions/checkout@v7
111118

112-
# Everything happens inside the containers: a PHP image with pdo_mysql and
113-
# pdo_pgsql, next to the database server. See .github/docker/ci/ for what
114-
# the run asserts - it fails on any PHP diagnostic, on missing or wrong
115-
# seeded data, and on a site that does not answer.
119+
# Only the database server runs in a container, straight from its official
120+
# image - nothing is built here. The installer itself runs on the runner's
121+
# own PHP, which already carries the PDO drivers; building a PHP image for
122+
# it would cost minutes per leg to reproduce what setup-php hands over
123+
# prebuilt. .github/docker/ci/ still describes the full containerised run
124+
# for local use.
125+
- name: Start ${{ matrix.db }}
126+
run: docker compose -f "$COMPOSE" --profile ${{ matrix.db }} up -d --wait ${{ matrix.db }}
127+
128+
# error_log to stderr for the same reason the CI image sets it: the
129+
# installer runs the migrations inside an output buffer it later discards,
130+
# so a warning raised during one only reaches the log the script greps if
131+
# PHP also writes it outside that buffer.
132+
- name: Setup PHP
133+
uses: shivammathur/setup-php@v2
134+
with:
135+
php-version: '8.3'
136+
extensions: ${{ env.PHP_EXTENSIONS }}, pdo_mysql, pdo_pgsql
137+
ini-values: error_reporting=E_ALL, display_errors=On, display_startup_errors=On, log_errors=On, error_log=/dev/stderr
138+
coverage: none
139+
tools: composer:v2
140+
141+
# core/vendor is committed, so there is no composer step: the script calls
142+
# the installer with --skipComposer=y. See .github/docker/ci/ for what the
143+
# run asserts - it fails on any PHP diagnostic, on missing or wrong seeded
144+
# data, and on a site that does not answer.
116145
- name: Install and smoke test
117-
run: |
118-
docker compose -f "$COMPOSE" --profile ${{ matrix.db }} up \
119-
--build \
120-
--abort-on-container-exit \
121-
--exit-code-from install-${{ matrix.db }}
146+
env:
147+
EVO_APP_DIR: ${{ github.workspace }}
148+
EVO_DB_TYPE: ${{ matrix.db }}
149+
EVO_DB_HOST: 127.0.0.1
150+
EVO_DB_USER: ${{ matrix.user }}
151+
EVO_DB_PASSWORD: ${{ matrix.password }}
152+
EVO_DB_NAME: evolution
153+
EVO_DB_PREFIX: evo_
154+
run: .github/docker/ci/install-and-smoke.sh
122155

123156
- name: Database server log
124157
if: failure()

0 commit comments

Comments
 (0)