Skip to content

Commit f7a7635

Browse files
rhoerrclaude
andcommitted
fix(supported-version): model MariaDB as a separate service from MySQL
The `mariadb:11.4` image used by Magento 2.4.9 no longer ships `mysqladmin`, so the existing single MySQL service template (`--health-cmd="mysqladmin ping"`) fails its health check and the `setup-install` lane is torn down at "Initialize containers". A simple swap to `healthcheck.sh --connect --innodb_initialized` would break the `mysql:8.4` lanes (the script is MariaDB-only), so a single template cannot cover both engines. Per @damienwebdev's direction on issue #365, model MariaDB as its own first-class service, mirroring the existing opensearch/elasticsearch and valkey/redis patterns: - `matrix-type.ts`: add `mariadb: string` to `PackageMatrixVersion` - `service-config.ts`: add `mariadbConfig` with the healthcheck.sh command; leave `mysqlConfig` with `mysqladmin ping` - `build-services.ts`: add `getDatabaseChoice()` that prefers mariadb over mysql; emit either `services.mariadb` or `services.mysql` - version JSON: 22 entries that encoded MariaDB by stuffing the image into the `mysql` field now use a top-level `mariadb` key instead - `build-services.spec.ts`: add a database-selection describe block - `amend-matrix-for-next.spec.ts`: fixtures gain `mariadb: ""` to satisfy the new required field - `.github/workflows/integration.yaml`: port lookup falls back from `job.services.mysql.ports['3306']` to the mariadb key - `supported-version/README.md`: include_services description mentions MariaDB alongside MySQL - `dist/index.js`: rebuilt Fixes #365 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent a67df90 commit f7a7635

12 files changed

Lines changed: 160 additions & 51 deletions

File tree

.github/workflows/integration.yaml

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

7575
- name: Allow SQL triggers
7676
run: |
77-
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -prootpassword -e "set global log_bin_trust_function_creators=1;"
77+
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] || job.services.mariadb.ports['3306'] }} -u root -prootpassword -e "set global log_bin_trust_function_creators=1;"
7878
7979
- run: composer create-project --repository-url="${{ inputs.magento_repository }}" "${{ matrix.magento }}" ${{ inputs.magento_directory }} --no-install
8080
shell: bash

supported-version/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ See the [action.yml](./action.yml)
1717
| project | The project to return the supported versions for. Allowed values are `mage-os` and `magento-open-source` | false | 'magento-open-source' |
1818
| custom_versions | The versions you want to support, as a comma-separated string, i.e. 'magento/project-community-edition:2.3.7-p3, magento/project-community-edition:2.4.2-p2' | false | '' |
1919
| recent_time_frame | The time frame (from today) used when `kind` is `recent`. Combination of years (y), months (m), and days (d), e.g. `2y 2m 2d`. | false | '2y' |
20-
| include_services | Whether to include a `services` key in each matrix entry with GitHub Actions service container configurations for MySQL, search engine, RabbitMQ, and cache. | false | 'true' |
20+
| include_services | Whether to include a `services` key in each matrix entry with GitHub Actions service container configurations for the database (MySQL or MariaDB), search engine, RabbitMQ, and cache. | false | 'true' |
2121

2222
## Kinds
2323
- `currently-supported` - The currently supported Magento Open Source versions by Adobe.

supported-version/dist/index.js

Lines changed: 23 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

supported-version/src/matrix/matrix-type.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export interface PackageMatrixVersion {
1414
php: string | number,
1515
composer: string | number,
1616
mysql: string,
17+
mariadb: string,
1718
elasticsearch: string,
1819
opensearch: string,
1920
rabbitmq: string,

supported-version/src/nightly/amend-matrix-for-next.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ describe('amendMatrixForNext', () => {
1111
"php": 8.2,
1212
"composer": "2",
1313
"mysql": "mysql:8.0",
14+
"mariadb": "",
1415
"elasticsearch": "elasticsearch:8.5.3",
1516
"opensearch": "",
1617
"rabbitmq": "rabbitmq:3.11-management",
@@ -36,6 +37,7 @@ describe('amendMatrixForNext', () => {
3637
"php": 8.2,
3738
"composer": "2",
3839
"mysql": "mysql:8.0",
40+
"mariadb": "",
3941
"elasticsearch": "elasticsearch:8.5.3",
4042
"opensearch": "",
4143
"rabbitmq": "rabbitmq:3.11-management",
@@ -63,6 +65,7 @@ describe('amendMatrixForNext', () => {
6365
"php": 8.2,
6466
"composer": "2",
6567
"mysql": "mysql:8.0",
68+
"mariadb": "",
6669
"elasticsearch": "elasticsearch:8.5.3",
6770
"opensearch": "",
6871
"rabbitmq": "rabbitmq:3.11-management",
@@ -88,6 +91,7 @@ describe('amendMatrixForNext', () => {
8891
"php": 8.2,
8992
"composer": "2",
9093
"mysql": "mysql:8.0",
94+
"mariadb": "",
9195
"elasticsearch": "elasticsearch:8.5.3",
9296
"opensearch": "",
9397
"rabbitmq": "rabbitmq:3.11-management",
@@ -115,6 +119,7 @@ describe('amendMatrixForNext', () => {
115119
"php": 8.2,
116120
"composer": "2",
117121
"mysql": "mysql:8.0",
122+
"mariadb": "",
118123
"elasticsearch": "elasticsearch:8.5.3",
119124
"opensearch": "",
120125
"rabbitmq": "rabbitmq:3.11-management",
@@ -131,6 +136,7 @@ describe('amendMatrixForNext', () => {
131136
"php": 8.2,
132137
"composer": "2",
133138
"mysql": "mysql:8.0",
139+
"mariadb": "",
134140
"elasticsearch": "elasticsearch:8.5.3",
135141
"opensearch": "",
136142
"rabbitmq": "rabbitmq:3.11-management",
@@ -156,6 +162,7 @@ describe('amendMatrixForNext', () => {
156162
"php": 8.2,
157163
"composer": "2",
158164
"mysql": "mysql:8.0",
165+
"mariadb": "",
159166
"elasticsearch": "elasticsearch:8.5.3",
160167
"opensearch": "",
161168
"rabbitmq": "rabbitmq:3.11-management",
@@ -172,6 +179,7 @@ describe('amendMatrixForNext', () => {
172179
"php": 8.2,
173180
"composer": "2",
174181
"mysql": "mysql:8.0",
182+
"mariadb": "",
175183
"elasticsearch": "elasticsearch:8.5.3",
176184
"opensearch": "",
177185
"rabbitmq": "rabbitmq:3.11-management",
@@ -199,6 +207,7 @@ describe('amendMatrixForNext', () => {
199207
"php": 8.2,
200208
"composer": "2",
201209
"mysql": "mysql:8.0",
210+
"mariadb": "",
202211
"elasticsearch": "elasticsearch:8.5.3",
203212
"opensearch": "",
204213
"rabbitmq": "rabbitmq:3.11-management",
@@ -224,6 +233,7 @@ describe('amendMatrixForNext', () => {
224233
"php": 8.2,
225234
"composer": "2",
226235
"mysql": "mysql:8.0",
236+
"mariadb": "",
227237
"elasticsearch": "elasticsearch:8.5.3",
228238
"opensearch": "",
229239
"rabbitmq": "rabbitmq:3.11-management",

supported-version/src/services/build-services.spec.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const createTestEntry = (overrides: Partial<PackageMatrixVersion> = {}): Package
66
php: '8.3',
77
composer: '2.7.4',
88
mysql: 'mysql:8.4',
9+
mariadb: '',
910
elasticsearch: 'elasticsearch:8.11.4',
1011
opensearch: 'opensearchproject/opensearch:2.19.1',
1112
rabbitmq: 'rabbitmq:4.0-management',
@@ -20,6 +21,62 @@ const createTestEntry = (overrides: Partial<PackageMatrixVersion> = {}): Package
2021
});
2122

2223
describe('buildServicesForEntry', () => {
24+
describe('database selection', () => {
25+
it('should prefer mariadb when both are available', () => {
26+
const entry = createTestEntry({ mariadb: 'mariadb:11.4' });
27+
const services = buildServicesForEntry(entry);
28+
29+
expect(services.mariadb).toBeDefined();
30+
expect(services.mariadb.image).toBe('mariadb:11.4');
31+
expect(services.mysql).toBeUndefined();
32+
});
33+
34+
it('should fall back to mysql when mariadb is empty', () => {
35+
const entry = createTestEntry();
36+
const services = buildServicesForEntry(entry);
37+
38+
expect(services.mysql).toBeDefined();
39+
expect(services.mysql.image).toBe('mysql:8.4');
40+
expect(services.mariadb).toBeUndefined();
41+
});
42+
43+
it('should not include database when neither is available', () => {
44+
const entry = createTestEntry({ mysql: '', mariadb: '' });
45+
const services = buildServicesForEntry(entry);
46+
47+
expect(services.mysql).toBeUndefined();
48+
expect(services.mariadb).toBeUndefined();
49+
});
50+
51+
it('should use healthcheck.sh for mariadb', () => {
52+
const entry = createTestEntry({ mariadb: 'mariadb:11.4' });
53+
const services = buildServicesForEntry(entry);
54+
55+
expect(services.mariadb.options).toContain('--health-cmd');
56+
expect(services.mariadb.options).toContain('healthcheck.sh');
57+
expect(services.mariadb.options).toContain('--innodb_initialized');
58+
});
59+
60+
it('should include correct mariadb env configuration', () => {
61+
const entry = createTestEntry({ mariadb: 'mariadb:11.4' });
62+
const services = buildServicesForEntry(entry);
63+
64+
expect(services.mariadb.env).toEqual({
65+
MYSQL_DATABASE: 'magento_integration_tests',
66+
MYSQL_USER: 'user',
67+
MYSQL_PASSWORD: 'password',
68+
MYSQL_ROOT_PASSWORD: 'rootpassword'
69+
});
70+
});
71+
72+
it('should include correct mariadb ports', () => {
73+
const entry = createTestEntry({ mariadb: 'mariadb:11.4' });
74+
const services = buildServicesForEntry(entry);
75+
76+
expect(services.mariadb.ports).toEqual(['3306:3306']);
77+
});
78+
});
79+
2380
describe('search engine selection', () => {
2481
it('should prefer opensearch when both are available', () => {
2582
const entry = createTestEntry();

supported-version/src/services/build-services.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { PackageMatrixVersion, Services } from '../matrix/matrix-type';
22
import {
33
mysqlConfig,
4+
mariadbConfig,
45
elasticsearchConfig,
56
opensearchConfig,
67
rabbitmqConfig,
78
redisConfig,
89
valkeyConfig
910
} from './service-config';
1011

12+
interface DatabaseChoice {
13+
type: 'mariadb' | 'mysql';
14+
image: string;
15+
}
16+
1117
interface SearchEngineChoice {
1218
type: 'opensearch' | 'elasticsearch';
1319
image: string;
@@ -18,6 +24,20 @@ interface CacheChoice {
1824
image: string;
1925
}
2026

27+
/**
28+
* Determines which database to use for a matrix entry.
29+
* Prefers mariadb over mysql.
30+
*/
31+
function getDatabaseChoice(entry: PackageMatrixVersion): DatabaseChoice | null {
32+
if (entry.mariadb && entry.mariadb.trim() !== '') {
33+
return { type: 'mariadb', image: entry.mariadb };
34+
}
35+
if (entry.mysql && entry.mysql.trim() !== '') {
36+
return { type: 'mysql', image: entry.mysql };
37+
}
38+
return null;
39+
}
40+
2141
/**
2242
* Determines which search engine to use for a matrix entry.
2343
* Prefers opensearch over elasticsearch.
@@ -52,9 +72,14 @@ function getCacheChoice(entry: PackageMatrixVersion): CacheChoice | null {
5272
export function buildServicesForEntry(entry: PackageMatrixVersion): Services {
5373
const services: Services = {};
5474

55-
// MySQL is always included if present
56-
if (entry.mysql && entry.mysql.trim() !== '') {
57-
services.mysql = mysqlConfig.getConfig(entry.mysql);
75+
// Database: prefer mariadb over mysql
76+
const database = getDatabaseChoice(entry);
77+
if (database) {
78+
if (database.type === 'mariadb') {
79+
services.mariadb = mariadbConfig.getConfig(database.image);
80+
} else {
81+
services.mysql = mysqlConfig.getConfig(database.image);
82+
}
5883
}
5984

6085
// Search engine: prefer opensearch over elasticsearch
@@ -83,4 +108,4 @@ export function buildServicesForEntry(entry: PackageMatrixVersion): Services {
83108
}
84109

85110
return services;
86-
}
111+
}

supported-version/src/services/service-config.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@ export const mysqlConfig: ServiceTemplate = {
2020
}
2121
};
2222

23+
export const mariadbConfig: ServiceTemplate = {
24+
getConfig(image: string): ServiceConfig {
25+
return {
26+
image,
27+
env: {
28+
MYSQL_DATABASE: 'magento_integration_tests',
29+
MYSQL_USER: 'user',
30+
MYSQL_PASSWORD: 'password',
31+
MYSQL_ROOT_PASSWORD: 'rootpassword'
32+
},
33+
ports: ['3306:3306'],
34+
options: '--health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3'
35+
};
36+
}
37+
};
38+
2339
export const elasticsearchConfig: ServiceTemplate = {
2440
getConfig(image: string): ServiceConfig {
2541
return {

supported-version/src/versions/mage-os/composite.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"magento": "mage-os/project-community-edition:>=1.0 <1.1",
44
"php": 8.3,
55
"composer": "2.9.7",
6-
"mysql": "mariadb:10.6",
6+
"mariadb": "mariadb:10.6",
77
"elasticsearch": "elasticsearch:8.11.4",
88
"rabbitmq": "rabbitmq:3.13-management",
99
"redis": "redis:7.2",

supported-version/src/versions/mage-os/individual.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"upstream": "2.4.7-p1",
3535
"php": 8.3,
3636
"composer": "2.7.4",
37-
"mysql": "mariadb:10.6",
37+
"mariadb": "mariadb:10.6",
3838
"elasticsearch": "elasticsearch:8.11.4",
3939
"rabbitmq": "rabbitmq:3.13-management",
4040
"redis": "redis:7.2",
@@ -49,7 +49,7 @@
4949
"upstream": "2.4.7-p1",
5050
"php": 8.3,
5151
"composer": "2.7.4",
52-
"mysql": "mariadb:10.6",
52+
"mariadb": "mariadb:10.6",
5353
"elasticsearch": "elasticsearch:8.11.4",
5454
"rabbitmq": "rabbitmq:3.13-management",
5555
"redis": "redis:7.2",
@@ -64,7 +64,7 @@
6464
"upstream": "2.4.7-p2",
6565
"php": 8.3,
6666
"composer": "2.7.4",
67-
"mysql": "mariadb:10.6",
67+
"mariadb": "mariadb:10.6",
6868
"elasticsearch": "elasticsearch:8.11.4",
6969
"rabbitmq": "rabbitmq:3.13-management",
7070
"redis": "redis:7.2",
@@ -79,7 +79,7 @@
7979
"upstream": "2.4.7-p3",
8080
"php": 8.3,
8181
"composer": "2.7.4",
82-
"mysql": "mariadb:10.6",
82+
"mariadb": "mariadb:10.6",
8383
"elasticsearch": "elasticsearch:8.11.4",
8484
"rabbitmq": "rabbitmq:3.13-management",
8585
"redis": "redis:7.2",
@@ -94,7 +94,7 @@
9494
"upstream": "2.4.7-p4",
9595
"php": 8.3,
9696
"composer": "2.7.4",
97-
"mysql": "mariadb:10.6",
97+
"mariadb": "mariadb:10.6",
9898
"elasticsearch": "elasticsearch:8.11.4",
9999
"rabbitmq": "rabbitmq:3.13-management",
100100
"redis": "redis:7.2",

0 commit comments

Comments
 (0)