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
8 changes: 5 additions & 3 deletions supported-version/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,18 @@ See the [action.yml](./action.yml)

| Input | Description | Required | Default |
|-----------------| ------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------- |-----------------------|
| kind | The "kind" of support you're targeting for your package. Allowed values are `currently-supported`, `latest`, `custom`, `nightly` and `all` | false | 'currently-supported' |
| project | The project to return the supported versions for. Allowed values are `mage-os` 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 | '' |
| kind | The "kind" of support you're targeting for your package. See [Kinds](#kinds). | false | 'currently-supported' |
| project | The project to return the supported versions for. Allowed values are `mage-os` 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' |

## Kinds
- `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`)
- `recent` - Versions released within a configurable time window from today (see `recent_time_frame`).
- `all` - All versions of Magento (including patched/unpatched versions).

## Projects
Expand Down
7 changes: 6 additions & 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`, `usable`, `nightly`, 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
Expand All @@ -17,6 +17,11 @@ inputs:
description: "The specific custom versions of Magento that you want to use. Only applies when `kind` is `custom`"
default: ""

recent_time_frame:
required: false
default: "2y"
description: "The time frame (from today). Only used in `recent` kind. String that defines a time duration using a combination of years (y), months (m), and days (d). Each unit is optional and can appear in any order, separated by spaces. For example `2y 2m 2d`. "

outputs:
matrix:
description: "The Github Actions matrix of software technologies required to run Magento."
Expand Down
75 changes: 38 additions & 37 deletions supported-version/dist/index.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions supported-version/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import { validateProject } from "./project/validate-projects";


export async function run(): Promise<void> {
try {
try {
const kind = core.getInput("kind");
const customVersions = core.getInput("custom_versions");
const project = core.getInput("project");

const recent_time_frame = core.getInput("recent_time_frame");

validateProject(<any>project)

validateKind(<any>kind, customVersions ? customVersions.split(',') : undefined);

core.setOutput('matrix', getMatrixForKind(kind, project, customVersions));
}
core.setOutput('matrix', getMatrixForKind(kind, project, customVersions, recent_time_frame));
}
catch (error) {
core.setFailed(error.message);
}
Expand Down
1 change: 1 addition & 0 deletions supported-version/src/kind/kinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const KNOWN_KINDS = {
'custom': true,
'usable': true,
'nightly': true,
'recent': true,
'all': true,
}

Expand Down
78 changes: 78 additions & 0 deletions supported-version/src/kind/recent.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { Project } from "../project/projects";
import { getRecentVersions } from "./recent";

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

test.each([
['2024-12-31T00:00:00Z', 'End of 2024', [
"magento/project-community-edition:2.4.4-p7",
"magento/project-community-edition:2.4.4-p8",
"magento/project-community-edition:2.4.4-p9",
"magento/project-community-edition:2.4.4-p10",
"magento/project-community-edition:2.4.4-p11",
"magento/project-community-edition:2.4.5-p6",
"magento/project-community-edition:2.4.5-p7",
"magento/project-community-edition:2.4.5-p8",
"magento/project-community-edition:2.4.5-p9",
"magento/project-community-edition:2.4.5-p10",
"magento/project-community-edition:2.4.6-p4",
"magento/project-community-edition:2.4.6-p5",
"magento/project-community-edition:2.4.6-p6",
"magento/project-community-edition:2.4.6-p7",
"magento/project-community-edition:2.4.6-p8",
"magento/project-community-edition:2.4.7",
"magento/project-community-edition:2.4.7-p1",
"magento/project-community-edition:2.4.7-p2",
"magento/project-community-edition:2.4.7-p3",
]],
['2025-04-08T00:00:00Z', 'The day Damien wrote a test.', [
"magento/project-community-edition:2.4.4-p9",
"magento/project-community-edition:2.4.4-p10",
"magento/project-community-edition:2.4.4-p11",
"magento/project-community-edition:2.4.4-p12",
"magento/project-community-edition:2.4.5-p8",
"magento/project-community-edition:2.4.5-p9",
"magento/project-community-edition:2.4.5-p10",
"magento/project-community-edition:2.4.5-p11",
"magento/project-community-edition:2.4.6-p6",
"magento/project-community-edition:2.4.6-p7",
"magento/project-community-edition:2.4.6-p8",
"magento/project-community-edition:2.4.6-p9",
"magento/project-community-edition:2.4.7-p1",
"magento/project-community-edition:2.4.7-p2",
"magento/project-community-edition:2.4.7-p3",
"magento/project-community-edition:2.4.7-p4",
]],
['2025-08-08T00:00:00Z', 'Day Before v2.4.5 EoL', [
"magento/project-community-edition:2.4.4-p10",
"magento/project-community-edition:2.4.4-p11",
"magento/project-community-edition:2.4.4-p12",
"magento/project-community-edition:2.4.4-p13",
"magento/project-community-edition:2.4.5-p9",
"magento/project-community-edition:2.4.5-p10",
"magento/project-community-edition:2.4.5-p11",
"magento/project-community-edition:2.4.5-p12",
"magento/project-community-edition:2.4.5-p13",
"magento/project-community-edition:2.4.6-p7",
"magento/project-community-edition:2.4.6-p8",
"magento/project-community-edition:2.4.6-p9",
"magento/project-community-edition:2.4.6-p10",
"magento/project-community-edition:2.4.6-p11",
"magento/project-community-edition:2.4.7-p2",
"magento/project-community-edition:2.4.7-p3",
"magento/project-community-edition:2.4.7-p4",
"magento/project-community-edition:2.4.7-p5",
"magento/project-community-edition:2.4.7-p6",
"magento/project-community-edition:2.4.8",
"magento/project-community-edition:2.4.8-p1"
]],
])(
'recent for %s',
(date, description ,result) => {
expect(
getRecentVersions(project, new Date(date), '360d')
).toEqual(result);
}
);
})
31 changes: 31 additions & 0 deletions supported-version/src/kind/recent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { PackageMatrixVersion } from '../matrix/matrix-type';
import { getIndividualVersionsForProject } from "../versions/get-versions-for-project";

export const getRecentVersions = (project: string, date: Date, durationStr: string): string[] => {
const regex = /(?:(\d+)\s*y)?\s*(?:(\d+)\s*m)?\s*(?:(\d+)\s*d)?/i;
const match = durationStr.match(regex);

if (!match) {
throw new Error(`Invalid duration string: ${durationStr}`);
}

const years = parseInt(match[1] || "0", 10);
const months = parseInt(match[2] || "0", 10);
const days = parseInt(match[3] || "0", 10);

const allVersions = getIndividualVersionsForProject(project)
return Object.entries(<Record<string,PackageMatrixVersion>>allVersions)
.filter(([key, value]) => {
const dayOfRelease = new Date(value.release);
dayOfRelease.setSeconds(dayOfRelease.getSeconds() + 1);
const dateAfterRelease = new Date(value.release);

dateAfterRelease.setFullYear(dateAfterRelease.getFullYear() + years);
dateAfterRelease.setMonth(dateAfterRelease.getMonth() + months);
dateAfterRelease.setDate(dateAfterRelease.getDate() + days);


return date >= dayOfRelease && date <= dateAfterRelease;
})
.map(([key, value]) => key);
}
14 changes: 14 additions & 0 deletions supported-version/src/matrix/get-matrix-for-kind.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ describe('getMatrixForKind for mage-os', () => {
expect(result.include).toBeDefined();
});

it('returns a matrix for `recent`', () => {
const result = getMatrixForKind("recent", project);

expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});

it('errors for invalid `custom``', () => {
expect(() => getMatrixForKind("custom", project)).toThrowError();
});
Expand Down Expand Up @@ -104,6 +111,13 @@ describe('getMatrixForKind for magento-open-source', () => {
expect(result.include).toBeDefined();
});

it('returns a matrix for `recent`', () => {
const result = getMatrixForKind("recent", project);

expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});

it('errors for invalid `custom``', () => {
expect(() => getMatrixForKind("custom", project)).toThrowError();
});
Expand Down
5 changes: 4 additions & 1 deletion supported-version/src/matrix/get-matrix-for-kind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ 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";

export const getMatrixForKind = (kind: string, project: string, versions = "") => {
export const getMatrixForKind = (kind: string, project: string, versions = "", recent_time_frame = '2y') => {

switch(kind){
case 'latest':
Expand All @@ -22,6 +23,8 @@ export const getMatrixForKind = (kind: string, project: string, versions = "") =
return getMatrixForVersions(project, Object.keys(getIndividualVersionsForProject(project)));
case 'custom':
return getMatrixForVersions(project, versions.split(","))
case 'recent':
return getMatrixForVersions(project, getRecentVersions(project, new Date(), recent_time_frame));
default:
throw new Error(`Unreachable kind: ${kind} discovered, please report to the maintainers.`);
}
Expand Down
Loading