Skip to content
Merged
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
1 change: 1 addition & 0 deletions supported-version/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ See the [action.yml](./action.yml)
- `currently-supported` - The currently supported Magento Open Source versions by Adobe.
- `latest` - The latest version of Magento only.
- `custom` - A custom subset of the versions, as specified by you. Requires `custom_versions` sibling key.
- `usable` - All versions of Magento, minus any that can no longer be installed or used under normal circumstances.
- `nightly` - The nightly version of Magento (only available via `https://upstream-nightly.mage-os.org`)
- `all` - All versions of Magento (including patched/unpatched versions).

Expand Down
2 changes: 1 addition & 1 deletion supported-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ description: "A Github Action that computes the Github Actions matrix for the ch
inputs:
kind:
required: false
description: "The kind of versions you want to return. Allowed values are `currently-supported`, `latest`, `custom`, `nightly` and `all`"
description: "The kind of versions you want to return. Allowed values are `currently-supported`, `latest`, `custom`, `usable`, `nightly`, and `all`"
default: "currently-supported"
project:
required: false
Expand Down
76 changes: 38 additions & 38 deletions supported-version/dist/index.js

Large diffs are not rendered by default.

42 changes: 42 additions & 0 deletions supported-version/src/kind/get-usable.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { getUsableVersions } from "./get-usable";
import { Project } from "../project/projects";
import { getIndividualVersionsForProject } from "../versions/get-versions-for-project";

// Mock the dependencies
jest.mock('../versions/get-versions-for-project');
const mockGetVersions = getIndividualVersionsForProject as jest.Mock;

describe('getUsableVersions for magento-open-source', () => {
const project: Project = "magento-open-source";

beforeEach(() => {
mockGetVersions.mockReset();
});

it('should return an array of versions', () => {
mockGetVersions.mockReturnValue({
'magento/project-community-edition:2.4.6': { composer: '2.2.0' }
});
expect(Array.isArray(getUsableVersions(project))).toBe(true);
});

it('should filter out versions with composer < 2.0.0', () => {
mockGetVersions.mockReturnValue({
'magento/project-community-edition:2.4.5': { composer: '1.9.0' },
'magento/project-community-edition:2.4.6': { composer: '2.2.0' }
});

const versions = getUsableVersions(project);
expect(versions).not.toContain('magento/project-community-edition:2.4.5');
expect(versions).toContain('magento/project-community-edition:2.4.6');
});

it('should handle composer version equal to 2.0.0', () => {
mockGetVersions.mockReturnValue({
'magento/project-community-edition:2.4.6': { composer: '2.0.0' }
});

const versions = getUsableVersions(project);
expect(versions).toContain('magento/project-community-edition:2.4.6');
});
});
22 changes: 22 additions & 0 deletions supported-version/src/kind/get-usable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { PackageMatrixVersion } from '../matrix/matrix-type';
import { getIndividualVersionsForProject } from "../versions/get-versions-for-project";
import semver from 'semver';

export const getUsableVersions = (project: string): string[] => {
const allVersions = getIndividualVersionsForProject(project)
return Object.entries(<Record<string,PackageMatrixVersion>>allVersions)
.filter(([key, value]) => {
/**
* Filter out any versions that are not 'usable', and cannot be successfully installed
* anymore for modern systems or other reasons outside our control.
*/

// Packagist retired support for Composer 1 on 2025-09-01.
if (value.composer && semver.lt(value.composer.toString(), '2.0.0')) {
return false;
}

return true;
})
.map(([key, value]) => key);
}
4 changes: 2 additions & 2 deletions supported-version/src/matrix/get-matrix-for-kind.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ describe('getMatrixForKind for magento-open-source', () => {
});

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

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

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

expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
Expand Down
3 changes: 3 additions & 0 deletions supported-version/src/matrix/get-matrix-for-kind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import latestJson from '../kind/special-versions/latest.json';
import nightlyJson from '../kind/special-versions/nightly.json';
import { getDayBefore } from '../nightly/get-day-before';
import { getCurrentlySupportedVersions } from "../kind/get-currently-supported";
import { getUsableVersions } from "../kind/get-usable";
import { amendMatrixForNext } from "../nightly/amend-matrix-for-next";

export const getMatrixForKind = (kind: string, project: string, versions = "") => {
Expand All @@ -13,6 +14,8 @@ export const getMatrixForKind = (kind: string, project: string, versions = "") =
return getMatrixForVersions(project, latestJson[project]);
case 'currently-supported':
return getMatrixForVersions(project, getCurrentlySupportedVersions(project, new Date()));
case 'usable':
return getMatrixForVersions(project, getUsableVersions(project));
case 'nightly':
return amendMatrixForNext(getMatrixForVersions(project, nightlyJson[project]), 'https://upstream-nightly.mage-os.org', getDayBefore());
case 'all':
Expand Down
Loading