Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:

- name: Allow SQL triggers
run: |
mysql --host 127.0.0.1 --port ${{ job.services.mysql.ports['3306'] }} -u root -prootpassword -e "set global log_bin_trust_function_creators=1;"
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;"

- run: composer create-project --repository-url="${{ inputs.magento_repository }}" "${{ matrix.magento }}" ${{ inputs.magento_directory }} --no-install
shell: bash
Expand Down
44 changes: 22 additions & 22 deletions resolve-check-config/dist/index.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions resolve-check-config/src/tier-map.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ describe('servicesForTiers', () => {
expect([...servicesForTiers(['search'])].sort()).toEqual(['elasticsearch', 'opensearch']);
});

it('expands the db tier to both implementations', () => {
expect([...servicesForTiers(['db'])].sort()).toEqual(['mariadb', 'mysql']);
});

it('expands the web tier to nginx + php-fpm', () => {
expect([...servicesForTiers(['web'])].sort()).toEqual(['nginx', 'php-fpm']);
});
Expand Down
2 changes: 1 addition & 1 deletion resolve-check-config/src/tier-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type Tier = 'db' | 'search' | 'queue' | 'cache' | 'web';
* the keys that union to the values of the selected tiers here.
*/
export const TIER_TO_SERVICES: Record<Tier, readonly string[]> = {
db: ['mysql'],
db: ['mariadb', 'mysql'],
search: ['opensearch', 'elasticsearch'],
queue: ['rabbitmq'],
cache: ['valkey', 'redis'],
Expand Down
46 changes: 23 additions & 23 deletions setup-install/dist/index.js

Large diffs are not rendered by default.

60 changes: 55 additions & 5 deletions setup-install/src/build-command.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,19 @@ const MYSQL_SERVICE = {
options: '--health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3',
};

const MYSQL_ARGS = [
const MARIADB_SERVICE = {
image: 'mariadb:11.4',
env: {
MYSQL_DATABASE: 'magento_integration_tests',
MYSQL_USER: 'user',
MYSQL_PASSWORD: 'password',
MYSQL_ROOT_PASSWORD: 'rootpassword',
},
ports: ['3306:3306'],
options: '--health-cmd="healthcheck.sh --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3',
};

const DB_ARGS = [
'--db-host=127.0.0.1:3306',
'--db-name=magento_integration_tests',
'--db-user=user',
Expand Down Expand Up @@ -67,10 +79,25 @@ describe('buildInstallArgs', () => {
});
});

describe('mysql', () => {
describe('database', () => {
it('adds db flags when mysql service is present', () => {
const services: Services = { mysql: MYSQL_SERVICE };
expect(buildInstallArgs(services)).toEqual([...BASE_ARGS, ...MYSQL_ARGS]);
expect(buildInstallArgs(services)).toEqual([...BASE_ARGS, ...DB_ARGS]);
});

it('adds db flags when mariadb service is present', () => {
const services: Services = { mariadb: MARIADB_SERVICE };
expect(buildInstallArgs(services)).toEqual([...BASE_ARGS, ...DB_ARGS]);
});

it('prefers mariadb over mysql when both are present', () => {
const services: Services = {
mariadb: MARIADB_SERVICE,
mysql: { ...MYSQL_SERVICE, ports: ['3307:3306'] },
};
const args = buildInstallArgs(services);
expect(args).toContain('--db-host=127.0.0.1:3306');
expect(args).not.toContain('--db-host=127.0.0.1:3307');
});
});

Expand Down Expand Up @@ -140,7 +167,7 @@ describe('buildInstallArgs', () => {
});

describe('buildMysqlPrepArgs', () => {
it('uses root password and port from service config', () => {
it('uses root password and port from mysql service config', () => {
expect(buildMysqlPrepArgs(MYSQL_SERVICE)).toEqual([
'-h127.0.0.1',
'--port=3306',
Expand All @@ -150,6 +177,16 @@ describe('buildInstallArgs', () => {
]);
});

it('uses root password and port from mariadb service config', () => {
expect(buildMysqlPrepArgs(MARIADB_SERVICE)).toEqual([
'-h127.0.0.1',
'--port=3306',
'-uroot',
'-prootpassword',
'-e', 'SET GLOBAL log_bin_trust_function_creators = 1;',
]);
});

it('falls back to default port when ports is absent', () => {
const args = buildMysqlPrepArgs({ image: 'mysql:8.4' });
expect(args).toContain('--port=3306');
Expand All @@ -171,7 +208,7 @@ describe('buildInstallArgs', () => {
};
expect(buildInstallArgs(services)).toEqual([
...BASE_ARGS,
...MYSQL_ARGS,
...DB_ARGS,
...OPENSEARCH_ARGS,
...RABBITMQ_ARGS,
...CACHE_ARGS,
Expand All @@ -193,6 +230,19 @@ describe('buildInstallArgs', () => {
]);
});

it('uses the mariadb network alias when the mariadb service is present', () => {
const services: Services = {
mariadb: { ...MARIADB_SERVICE, ports: ['33060:3306'] },
};
expect(buildInstallArgs(services, true)).toEqual([
...BASE_ARGS,
'--db-host=mariadb:3306',
'--db-name=magento_integration_tests',
'--db-user=user',
'--db-password=password',
]);
});

it('uses the opensearch alias and parses the internal port', () => {
const services: Services = {
opensearch: { image: 'opensearchproject/opensearch:2.19.1', ports: ['19200:9200'] },
Expand Down
24 changes: 15 additions & 9 deletions setup-install/src/build-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export interface ServiceConfig {
}

export interface Services {
mariadb?: ServiceConfig;
mysql?: ServiceConfig;
opensearch?: ServiceConfig;
elasticsearch?: ServiceConfig;
Expand All @@ -16,6 +17,9 @@ export interface Services {
'php-fpm'?: ServiceConfig;
}

export const getDatabaseService = (services: Services): ServiceConfig | undefined =>
services.mariadb ?? services.mysql;

const BASE_ARGS = [
'--base-url=http://localhost/',
'--admin-user=admin',
Expand All @@ -31,9 +35,9 @@ const parsePort = (svc: ServiceConfig | undefined, index: 0 | 1, fallback: strin
return svc?.ports?.[0]?.split(':')[index] ?? fallback;
};

export const buildMysqlPrepArgs = (mysql: ServiceConfig): string[] => {
const rootPassword = mysql.env?.MYSQL_ROOT_PASSWORD ?? 'rootpassword';
const port = parsePort(mysql, 0, '3306');
export const buildMysqlPrepArgs = (database: ServiceConfig): string[] => {
const rootPassword = database.env?.MYSQL_ROOT_PASSWORD ?? 'rootpassword';
const port = parsePort(database, 0, '3306');
return ['-h127.0.0.1', `--port=${port}`, '-uroot', `-p${rootPassword}`, '-e', 'SET GLOBAL log_bin_trust_function_creators = 1;'];
};

Expand All @@ -45,14 +49,16 @@ export const buildInstallArgs = (services: Services | null, containerMode = fals
const portIdx: 0 | 1 = containerMode ? 1 : 0;
const hostFor = (alias: string): string => containerMode ? alias : 'localhost';

if (services.mysql) {
const dbPort = parsePort(services.mysql, portIdx, '3306');
const dbHost = containerMode ? `mysql:${dbPort}` : `127.0.0.1:${dbPort}`;
const database = getDatabaseService(services);
if (database) {
const dbAlias = services.mariadb ? 'mariadb' : 'mysql';
const dbPort = parsePort(database, portIdx, '3306');
const dbHost = containerMode ? `${dbAlias}:${dbPort}` : `127.0.0.1:${dbPort}`;
args.push(
`--db-host=${dbHost}`,
`--db-name=${services.mysql.env?.MYSQL_DATABASE ?? 'magento'}`,
`--db-user=${services.mysql.env?.MYSQL_USER ?? 'magento'}`,
`--db-password=${services.mysql.env?.MYSQL_PASSWORD ?? 'magento'}`,
`--db-name=${database.env?.MYSQL_DATABASE ?? 'magento'}`,
`--db-user=${database.env?.MYSQL_USER ?? 'magento'}`,
`--db-password=${database.env?.MYSQL_PASSWORD ?? 'magento'}`,
);
}

Expand Down
8 changes: 5 additions & 3 deletions setup-install/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as nodePath from 'path';
import { buildInstallArgs, buildMysqlPrepArgs, Services } from './build-command';
import { buildInstallArgs, buildMysqlPrepArgs, getDatabaseService, Services } from './build-command';

const resolveContainerPath = (runnerPath: string): string => {
const workspace = process.env.GITHUB_WORKSPACE || '';
Expand All @@ -28,8 +28,10 @@ export async function run(): Promise<void> {

// setup:install creates MySQL triggers, which requires log_bin_trust_function_creators=1
// when binary logging is enabled. The prep always runs runner-side against the published port.
if (services?.mysql) {
await exec.exec('mysql', buildMysqlPrepArgs(services.mysql));
// The same SQL works against MariaDB.
const database = services ? getDatabaseService(services) : undefined;
if (database) {
await exec.exec('mysql', buildMysqlPrepArgs(database));
}

const args = buildInstallArgs(services, containerMode);
Expand Down
6 changes: 4 additions & 2 deletions supported-version/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ See the [action.yml](./action.yml)
| project | The project to return the supported versions for. Allowed values are `mage-os`, `mage-os-minimal`, and `magento-open-source` | false | 'magento-open-source' |
| 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 | '' |
| 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' |
| 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' |
| 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' |
| service_preferences | Comma-separated list of service implementations to prefer (e.g. `elasticsearch,valkey`). See [Service preferences](#service-preferences). | false | '' |

## Kinds
Expand All @@ -38,10 +38,11 @@ See the [action.yml](./action.yml)

When `include_services: true` (the default), each matrix entry is enriched with a `services` map. Some tiers of services (for example, search) have more than one valid implementation across the supported Magento versions:

- **db**: `mariadb` or `mysql`
- **search**: `opensearch` or `elasticsearch`
- **cache**: `valkey` or `redis`

By default the action picks `opensearch` over `elasticsearch` and `valkey` over `redis` wherever both are available for the matrix entry's Magento version. `service_preferences` lets the caller override that default pick by naming the implementation they want.
By default the action picks `mariadb` over `mysql`, `opensearch` over `elasticsearch`, and `valkey` over `redis` wherever both are available for the matrix entry's Magento version. `service_preferences` lets the caller override that default pick by naming the implementation they want.

Tiers without a preference fall back to the per-version default pick. Your preferences are **selective**, not **exclusive**.

Expand All @@ -58,6 +59,7 @@ with:

| Name | Tier |
|------------------|--------|
| `mariadb` | db |
| `mysql` | db |
| `elasticsearch` | search |
| `opensearch` | search |
Expand Down
36 changes: 18 additions & 18 deletions supported-version/dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions supported-version/src/matrix/matrix-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface PackageMatrixVersion {
php: string | number,
composer: string | number,
mysql: string,
mariadb: string,
elasticsearch: string,
opensearch: string,
rabbitmq: string,
Expand Down
10 changes: 10 additions & 0 deletions supported-version/src/nightly/amend-matrix-for-next.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand All @@ -38,6 +39,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand Down Expand Up @@ -66,6 +68,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand All @@ -92,6 +95,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand Down Expand Up @@ -120,6 +124,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand All @@ -137,6 +142,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand All @@ -163,6 +169,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand All @@ -180,6 +187,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand Down Expand Up @@ -208,6 +216,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand All @@ -234,6 +243,7 @@ describe('amendMatrixForNext', () => {
"php": 8.2,
"composer": "2",
"mysql": "mysql:8.0",
"mariadb": "",
"elasticsearch": "elasticsearch:8.5.3",
"opensearch": "",
"rabbitmq": "rabbitmq:3.11-management",
Expand Down
Loading
Loading