mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
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
This commit is contained in:
committed by
Damien Retzinger
parent
5fd96b988e
commit
5608271fe3
@@ -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).
|
||||
|
||||
|
||||
@@ -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`, `recent` and `all`"
|
||||
description: "The kind of versions you want to return. Allowed values are `currently-supported`, `latest`, `custom`, `usable`, `nightly`, `recent` and `all`"
|
||||
default: "currently-supported"
|
||||
project:
|
||||
required: false
|
||||
|
||||
Vendored
+34
-34
File diff suppressed because one or more lines are too long
@@ -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');
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
@@ -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();
|
||||
|
||||
@@ -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";
|
||||
import { getRecentVersions } from "../kind/recent";
|
||||
|
||||
@@ -14,6 +15,8 @@ export const getMatrixForKind = (kind: string, project: string, versions = "", r
|
||||
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':
|
||||
|
||||
Reference in New Issue
Block a user