Skip to content

Commit ce264fc

Browse files
authored
fix: allow matrix testing without EOL versions (#299)
* fix: remove versions dependent on EOL composer 1 * Restore composer 1 versions * Add `usable` version type, filtered by code constraints * Added code comment * Rebuilt index.js with latest changes merged * Updated documentation
1 parent 90551c9 commit ce264fc

7 files changed

Lines changed: 109 additions & 41 deletions

File tree

supported-version/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ See the [action.yml](./action.yml)
2121
- `currently-supported` - The currently supported Magento Open Source versions by Adobe.
2222
- `latest` - The latest version of Magento only.
2323
- `custom` - A custom subset of the versions, as specified by you. Requires `custom_versions` sibling key.
24+
- `usable` - All versions of Magento, minus any that can no longer be installed or used under normal circumstances.
2425
- `nightly` - The nightly version of Magento (only available via `https://upstream-nightly.mage-os.org`)
2526
- `all` - All versions of Magento (including patched/unpatched versions).
2627

supported-version/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: "A Github Action that computes the Github Actions matrix for the ch
55
inputs:
66
kind:
77
required: false
8-
description: "The kind of versions you want to return. Allowed values are `currently-supported`, `latest`, `custom`, `nightly` and `all`"
8+
description: "The kind of versions you want to return. Allowed values are `currently-supported`, `latest`, `custom`, `usable`, `nightly`, and `all`"
99
default: "currently-supported"
1010
project:
1111
required: false

supported-version/dist/index.js

Lines changed: 38 additions & 38 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { getUsableVersions } from "./get-usable";
2+
import { Project } from "../project/projects";
3+
import { getIndividualVersionsForProject } from "../versions/get-versions-for-project";
4+
5+
// Mock the dependencies
6+
jest.mock('../versions/get-versions-for-project');
7+
const mockGetVersions = getIndividualVersionsForProject as jest.Mock;
8+
9+
describe('getUsableVersions for magento-open-source', () => {
10+
const project: Project = "magento-open-source";
11+
12+
beforeEach(() => {
13+
mockGetVersions.mockReset();
14+
});
15+
16+
it('should return an array of versions', () => {
17+
mockGetVersions.mockReturnValue({
18+
'magento/project-community-edition:2.4.6': { composer: '2.2.0' }
19+
});
20+
expect(Array.isArray(getUsableVersions(project))).toBe(true);
21+
});
22+
23+
it('should filter out versions with composer < 2.0.0', () => {
24+
mockGetVersions.mockReturnValue({
25+
'magento/project-community-edition:2.4.5': { composer: '1.9.0' },
26+
'magento/project-community-edition:2.4.6': { composer: '2.2.0' }
27+
});
28+
29+
const versions = getUsableVersions(project);
30+
expect(versions).not.toContain('magento/project-community-edition:2.4.5');
31+
expect(versions).toContain('magento/project-community-edition:2.4.6');
32+
});
33+
34+
it('should handle composer version equal to 2.0.0', () => {
35+
mockGetVersions.mockReturnValue({
36+
'magento/project-community-edition:2.4.6': { composer: '2.0.0' }
37+
});
38+
39+
const versions = getUsableVersions(project);
40+
expect(versions).toContain('magento/project-community-edition:2.4.6');
41+
});
42+
});
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { PackageMatrixVersion } from '../matrix/matrix-type';
2+
import { getIndividualVersionsForProject } from "../versions/get-versions-for-project";
3+
import semver from 'semver';
4+
5+
export const getUsableVersions = (project: string): string[] => {
6+
const allVersions = getIndividualVersionsForProject(project)
7+
return Object.entries(<Record<string,PackageMatrixVersion>>allVersions)
8+
.filter(([key, value]) => {
9+
/**
10+
* Filter out any versions that are not 'usable', and cannot be successfully installed
11+
* anymore for modern systems or other reasons outside our control.
12+
*/
13+
14+
// Packagist retired support for Composer 1 on 2025-09-01.
15+
if (value.composer && semver.lt(value.composer.toString(), '2.0.0')) {
16+
return false;
17+
}
18+
19+
return true;
20+
})
21+
.map(([key, value]) => key);
22+
}

supported-version/src/matrix/get-matrix-for-kind.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ describe('getMatrixForKind for magento-open-source', () => {
8484
});
8585

8686
it('returns a matrix for valid `custom`', () => {
87-
const result = getMatrixForKind("custom", project, "magento/project-community-edition:2.3.7-p3");
87+
const result = getMatrixForKind("custom", project, "magento/project-community-edition:2.4.2");
8888

8989
expect(result.magento).toBeDefined();
9090
expect(result.include).toBeDefined();
@@ -98,7 +98,7 @@ describe('getMatrixForKind for magento-open-source', () => {
9898
});
9999

100100
it('returns a matrix for valid multiple `custom`', () => {
101-
const result = getMatrixForKind("custom", project, "magento/project-community-edition:2.3.7-p3,magento/project-community-edition:2.4.0");
101+
const result = getMatrixForKind("custom", project, "magento/project-community-edition:2.4.2,magento/project-community-edition:2.4.3");
102102

103103
expect(result.magento).toBeDefined();
104104
expect(result.include).toBeDefined();

supported-version/src/matrix/get-matrix-for-kind.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import latestJson from '../kind/special-versions/latest.json';
44
import nightlyJson from '../kind/special-versions/nightly.json';
55
import { getDayBefore } from '../nightly/get-day-before';
66
import { getCurrentlySupportedVersions } from "../kind/get-currently-supported";
7+
import { getUsableVersions } from "../kind/get-usable";
78
import { amendMatrixForNext } from "../nightly/amend-matrix-for-next";
89

910
export const getMatrixForKind = (kind: string, project: string, versions = "") => {
@@ -13,6 +14,8 @@ export const getMatrixForKind = (kind: string, project: string, versions = "") =
1314
return getMatrixForVersions(project, latestJson[project]);
1415
case 'currently-supported':
1516
return getMatrixForVersions(project, getCurrentlySupportedVersions(project, new Date()));
17+
case 'usable':
18+
return getMatrixForVersions(project, getUsableVersions(project));
1619
case 'nightly':
1720
return amendMatrixForNext(getMatrixForVersions(project, nightlyJson[project]), 'https://upstream-nightly.mage-os.org', getDayBefore());
1821
case 'all':

0 commit comments

Comments
 (0)