feat(supported-version): dynamically append "version" to matrix

This commit is contained in:
Damien Retzinger
2026-05-07 09:27:00 -04:00
parent c786530c3e
commit a7e327d44f
6 changed files with 36 additions and 25 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
@@ -16,7 +16,7 @@ export const getMatrixForVersions = (project: string, versions: string[]): Githu
return { return {
magento: [...acc.magento, current], magento: [...acc.magento, current],
include: [...acc.include, knownVersions[current]] include: [...acc.include, { ...knownVersions[current], version: current.split(':')[1] ?? '' }]
} }
}, {magento: [], include: []}); }, {magento: [], include: []});
} }
@@ -11,6 +11,7 @@ export interface Services {
export interface PackageMatrixVersion { export interface PackageMatrixVersion {
magento: string, magento: string,
version: string,
php: string | number, php: string | number,
composer: string | number, composer: string | number,
mysql: string, mysql: string,
@@ -4,10 +4,11 @@ describe('amendMatrixForNext', () => {
it('should amend the "next" versions listed in the matrix output for the given repo', () => { it('should amend the "next" versions listed in the matrix output for the given repo', () => {
expect( expect(
amendMatrixForNext( amendMatrixForNext(
{ {
include: [ include: [
{ {
"magento": "magento/project-community-edition:next", "magento": "magento/project-community-edition:next",
"version": "next",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -24,15 +25,16 @@ describe('amendMatrixForNext', () => {
} }
], ],
magento: ["magento/project-community-edition:next"] magento: ["magento/project-community-edition:next"]
}, },
"https://upstream-nightly.mage-os.org", "https://upstream-nightly.mage-os.org",
new Date() new Date()
) )
).toEqual( ).toEqual(
{ {
include: [ include: [
{ {
"magento": "magento/project-community-edition:@alpha", "magento": "magento/project-community-edition:@alpha",
"version": "@alpha",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -56,10 +58,11 @@ describe('amendMatrixForNext', () => {
it('should should do nothing to matrixes that contain no next versions', () => { it('should should do nothing to matrixes that contain no next versions', () => {
expect( expect(
amendMatrixForNext( amendMatrixForNext(
{ {
include: [ include: [
{ {
"magento": "magento/project-community-edition:v2.4.6-p2", "magento": "magento/project-community-edition:v2.4.6-p2",
"version": "v2.4.6-p2",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -76,15 +79,16 @@ describe('amendMatrixForNext', () => {
} }
], ],
magento: ["magento/project-community-edition:v2.4.6-p2"] magento: ["magento/project-community-edition:v2.4.6-p2"]
}, },
"https://upstream-nightly.mage-os.org", "https://upstream-nightly.mage-os.org",
new Date() new Date()
) )
).toEqual( ).toEqual(
{ {
include: [ include: [
{ {
"magento": "magento/project-community-edition:v2.4.6-p2", "magento": "magento/project-community-edition:v2.4.6-p2",
"version": "v2.4.6-p2",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -108,10 +112,11 @@ describe('amendMatrixForNext', () => {
it('should only modify next versions', () => { it('should only modify next versions', () => {
expect( expect(
amendMatrixForNext( amendMatrixForNext(
{ {
include: [ include: [
{ {
"magento": "magento/project-community-edition:v2.4.6-p2", "magento": "magento/project-community-edition:v2.4.6-p2",
"version": "v2.4.6-p2",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -128,6 +133,7 @@ describe('amendMatrixForNext', () => {
}, },
{ {
"magento": "magento/project-community-edition:next", "magento": "magento/project-community-edition:next",
"version": "next",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -144,15 +150,16 @@ describe('amendMatrixForNext', () => {
} }
], ],
magento: ["magento/project-community-edition:v2.4.6-p2", "magento/project-community-edition:next"] magento: ["magento/project-community-edition:v2.4.6-p2", "magento/project-community-edition:next"]
}, },
"https://upstream-nightly.mage-os.org", "https://upstream-nightly.mage-os.org",
new Date() new Date()
) )
).toEqual( ).toEqual(
{ {
include: [ include: [
{ {
"magento": "magento/project-community-edition:v2.4.6-p2", "magento": "magento/project-community-edition:v2.4.6-p2",
"version": "v2.4.6-p2",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -169,6 +176,7 @@ describe('amendMatrixForNext', () => {
}, },
{ {
"magento": "magento/project-community-edition:@alpha", "magento": "magento/project-community-edition:@alpha",
"version": "@alpha",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -192,10 +200,11 @@ describe('amendMatrixForNext', () => {
it('should amend the "next" versions listed in the matrix output for the given repo, for a different project', () => { it('should amend the "next" versions listed in the matrix output for the given repo, for a different project', () => {
expect( expect(
amendMatrixForNext( amendMatrixForNext(
{ {
include: [ include: [
{ {
"magento": "mage-os/project-community-edition:next", "magento": "mage-os/project-community-edition:next",
"version": "next",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -212,15 +221,16 @@ describe('amendMatrixForNext', () => {
} }
], ],
magento: ["mage-os/project-community-edition:next"] magento: ["mage-os/project-community-edition:next"]
}, },
"https://upstream-nightly.mage-os.org", "https://upstream-nightly.mage-os.org",
new Date() new Date()
) )
).toEqual( ).toEqual(
{ {
include: [ include: [
{ {
"magento": "mage-os/project-community-edition:@alpha", "magento": "mage-os/project-community-edition:@alpha",
"version": "@alpha",
"php": 8.2, "php": 8.2,
"composer": "2", "composer": "2",
"mysql": "mysql:8.0", "mysql": "mysql:8.0",
@@ -240,4 +250,4 @@ describe('amendMatrixForNext', () => {
} }
) )
}); });
}) })
@@ -12,12 +12,11 @@ export const amendMatrixForNext = (matrix: GithubActionsMatrix, repository: Repo
const nextVersionRegExp = new RegExp(nextVersionPlaceHolder + '$'); const nextVersionRegExp = new RegExp(nextVersionPlaceHolder + '$');
matrix.magento = matrix.magento.map((item) => item.match(nextVersionRegExp) ? unifyNextPackageName(item, repository, date) : item); matrix.magento = matrix.magento.map((item) => item.match(nextVersionRegExp) ? unifyNextPackageName(item, repository, date) : item);
matrix.include = matrix.include.map((item) => { matrix.include = matrix.include.map((item) => {
return item.magento.match(nextVersionRegExp) if (!item.magento.match(nextVersionRegExp)) {
? { return item;
...item, }
magento: unifyNextPackageName(item.magento, repository, date), const magento = unifyNextPackageName(item.magento, repository, date);
} return { ...item, magento, version: magento.split(':')[1] };
: item;
}); });
return matrix; return matrix;
} }
@@ -3,6 +3,7 @@ import { PackageMatrixVersion } from '../matrix/matrix-type';
const createTestEntry = (overrides: Partial<PackageMatrixVersion> = {}): PackageMatrixVersion => ({ const createTestEntry = (overrides: Partial<PackageMatrixVersion> = {}): PackageMatrixVersion => ({
magento: 'magento/project-community-edition:2.4.7', magento: 'magento/project-community-edition:2.4.7',
version: '2.4.7',
php: '8.3', php: '8.3',
composer: '2.7.4', composer: '2.7.4',
mysql: 'mysql:8.4', mysql: 'mysql:8.4',