mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
fix(supported-versions): nightly build matrix tag (#152)
This commit is contained in:
Vendored
+5
-5
File diff suppressed because one or more lines are too long
@@ -32,6 +32,12 @@ describe('getMatrixForKind for mage-os', () => {
|
||||
expect(result.include).toBeDefined();
|
||||
});
|
||||
|
||||
it('returns a matrix nightly`', () => {
|
||||
const result = getMatrixForKind("nightly", project);
|
||||
expect(result.magento).toBeDefined();
|
||||
expect(result.include).toBeDefined();
|
||||
});
|
||||
|
||||
it('returns a matrix for the next release when using `nightly`', () => {
|
||||
const result = getMatrixForKind("nightly", project, "mage-os/project-community-edition:next");
|
||||
|
||||
@@ -48,6 +54,12 @@ describe('getMatrixForKind for mage-os', () => {
|
||||
describe('getMatrixForKind for magento-open-source', () => {
|
||||
const project = "magento-open-source";
|
||||
|
||||
it('returns a matrix nightly`', () => {
|
||||
const result = getMatrixForKind("nightly", project);
|
||||
expect(result.magento).toBeDefined();
|
||||
expect(result.include).toBeDefined();
|
||||
});
|
||||
|
||||
it('returns a matrix for `latest`', () => {
|
||||
const result = getMatrixForKind("latest", project);
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@ import { getMatrixForVersions } from "./get-matrix-for-versions";
|
||||
import { getIndividualVersionsForProject } from "../versions/get-versions-for-project";
|
||||
import latestJson from '../kind/special-versions/latest.json';
|
||||
import nightlyJson from '../kind/special-versions/nightly.json';
|
||||
import { amendMatrixForNext } from "../nightly/get-next-version";
|
||||
import { getDayBefore } from '../nightly/get-day-before';
|
||||
import { getCurrentlySupportedVersions } from "../kind/get-currently-supported";
|
||||
import { amendMatrixForNext } from "../nightly/amend-matrix-for-next";
|
||||
|
||||
export const getMatrixForKind = (kind: string, project: string, versions = "") => {
|
||||
|
||||
|
||||
@@ -0,0 +1,223 @@
|
||||
import { amendMatrixForNext } from "./amend-matrix-for-next";
|
||||
|
||||
describe('amendMatrixForNext', () => {
|
||||
it('should amend the "next" versions listed in the matrix output for the given repo', () => {
|
||||
expect(
|
||||
amendMatrixForNext(
|
||||
{
|
||||
include: [
|
||||
{
|
||||
"magento": "magento/project-community-edition:next",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
}
|
||||
],
|
||||
magento: ["magento/project-community-edition:next"]
|
||||
},
|
||||
"https://upstream-nightly.mage-os.org",
|
||||
new Date()
|
||||
)
|
||||
).toEqual(
|
||||
{
|
||||
include: [
|
||||
{
|
||||
"magento": "magento/project-community-edition:@alpha",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
}
|
||||
],
|
||||
magento: ["magento/project-community-edition:@alpha"]
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
it('should should do nothing to matrixes that contain no next versions', () => {
|
||||
expect(
|
||||
amendMatrixForNext(
|
||||
{
|
||||
include: [
|
||||
{
|
||||
"magento": "magento/project-community-edition:v2.4.6-p2",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
}
|
||||
],
|
||||
magento: ["magento/project-community-edition:v2.4.6-p2"]
|
||||
},
|
||||
"https://upstream-nightly.mage-os.org",
|
||||
new Date()
|
||||
)
|
||||
).toEqual(
|
||||
{
|
||||
include: [
|
||||
{
|
||||
"magento": "magento/project-community-edition:v2.4.6-p2",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
}
|
||||
],
|
||||
magento: ["magento/project-community-edition:v2.4.6-p2"]
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
it('should only modify next versions', () => {
|
||||
expect(
|
||||
amendMatrixForNext(
|
||||
{
|
||||
include: [
|
||||
{
|
||||
"magento": "magento/project-community-edition:v2.4.6-p2",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
},
|
||||
{
|
||||
"magento": "magento/project-community-edition:next",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
}
|
||||
],
|
||||
magento: ["magento/project-community-edition:v2.4.6-p2", "magento/project-community-edition:next"]
|
||||
},
|
||||
"https://upstream-nightly.mage-os.org",
|
||||
new Date()
|
||||
)
|
||||
).toEqual(
|
||||
{
|
||||
include: [
|
||||
{
|
||||
"magento": "magento/project-community-edition:v2.4.6-p2",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
},
|
||||
{
|
||||
"magento": "magento/project-community-edition:@alpha",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
}
|
||||
],
|
||||
magento: ["magento/project-community-edition:v2.4.6-p2", "magento/project-community-edition:@alpha"]
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
it('should amend the "next" versions listed in the matrix output for the given repo, for a different project', () => {
|
||||
expect(
|
||||
amendMatrixForNext(
|
||||
{
|
||||
include: [
|
||||
{
|
||||
"magento": "mage-os/project-community-edition:next",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
}
|
||||
],
|
||||
magento: ["mage-os/project-community-edition:next"]
|
||||
},
|
||||
"https://upstream-nightly.mage-os.org",
|
||||
new Date()
|
||||
)
|
||||
).toEqual(
|
||||
{
|
||||
include: [
|
||||
{
|
||||
"magento": "mage-os/project-community-edition:@alpha",
|
||||
"php": 8.2,
|
||||
"composer": "2",
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:8.5.3",
|
||||
"rabbitmq": "rabbitmq:3.11-management",
|
||||
"redis": "redis:7.0",
|
||||
"varnish": "varnish:7.3",
|
||||
"nginx": "nginx:1.22",
|
||||
"os": "ubuntu-latest",
|
||||
"release": "2023-09-15T00:00:00+0000",
|
||||
"eol": "2026-09-15T00:00:00+0000"
|
||||
}
|
||||
],
|
||||
magento: ["mage-os/project-community-edition:@alpha"]
|
||||
}
|
||||
)
|
||||
});
|
||||
})
|
||||
@@ -0,0 +1,23 @@
|
||||
import { GithubActionsMatrix } from "../matrix/matrix-type";
|
||||
import { Repository } from "./repository";
|
||||
import { unifyNextPackageName } from "./unify-next-package-name";
|
||||
|
||||
/**
|
||||
* A placeholder value use to refer to the next version of Magento.
|
||||
* This value is just a placeholder, there is no "next" version (as of authoring).
|
||||
*/
|
||||
export const nextVersionPlaceHolder = "next";
|
||||
|
||||
export const amendMatrixForNext = (matrix: GithubActionsMatrix, repository: Repository, date: Date = new Date()): GithubActionsMatrix => {
|
||||
const nextVersionRegExp = new RegExp(nextVersionPlaceHolder + '$');
|
||||
matrix.magento = matrix.magento.map((item) => item.match(nextVersionRegExp) ? unifyNextPackageName(item, repository, date) : item);
|
||||
matrix.include = matrix.include.map((item) => {
|
||||
return item.magento.match(nextVersionRegExp)
|
||||
? {
|
||||
...item,
|
||||
magento: unifyNextPackageName(item.magento, repository, date),
|
||||
}
|
||||
: item;
|
||||
});
|
||||
return matrix;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { getNextVersion } from "./get-next-version"
|
||||
|
||||
describe('getNextVersion', () => {
|
||||
|
||||
it('should get the next nightly version for Magento Open Source', () => {
|
||||
expect(getNextVersion('https://upstream-nightly.mage-os.org', new Date('2022-09-29T17:47:00')), ).toEqual('@alpha');
|
||||
});
|
||||
|
||||
@@ -1,20 +1,4 @@
|
||||
import { GithubActionsMatrix } from "../matrix/matrix-type";
|
||||
|
||||
const KNOWN_REPOSITORIES = {
|
||||
"https://repo.mage-os.org": true,
|
||||
"https://nightly.mage-os.org": true,
|
||||
"https://upstream-mirror.mage-os.org": true,
|
||||
"https://upstream-nightly.mage-os.org": true,
|
||||
"https://repo.magento.com": true,
|
||||
}
|
||||
|
||||
export type Repository = keyof typeof KNOWN_REPOSITORIES;
|
||||
|
||||
/**
|
||||
* A placeholder value use to refer to the next version of Magento.
|
||||
* This value is just a placeholder, there is no "next" version (as of authoring).
|
||||
*/
|
||||
export const nextVersionPlaceHolder = "project-community-edition:next";
|
||||
import { Repository } from "./repository";
|
||||
|
||||
/**
|
||||
* Get the next version of Magento, as determined by the repository.
|
||||
@@ -26,29 +10,6 @@ export const getNextVersion = (repository: Repository, date: Date) => {
|
||||
// See: https://github.com/mage-os/generate-mirror-repo-js/blob/bbbdf1708ea0bf8fc845aad8240d00f37632b4a7/src/release-branch-build-tools.js#L71
|
||||
return "@alpha";
|
||||
default:
|
||||
return "";
|
||||
return "next";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export const replaceNextPlaceHolderWithVersion = (packageName: string, nextVersion: string) => {
|
||||
return packageName.replace(/(?!:)next$/, nextVersion);
|
||||
}
|
||||
|
||||
export const computeNextPackage = (packageName: string, repository: Repository, date: Date): string => {
|
||||
return replaceNextPlaceHolderWithVersion(packageName, getNextVersion(repository, date));
|
||||
}
|
||||
|
||||
export const amendMatrixForNext = (matrix: GithubActionsMatrix, repository: Repository, date: Date = new Date()): GithubActionsMatrix => {
|
||||
const nextVersionRegExp = new RegExp(nextVersionPlaceHolder + '$');
|
||||
matrix.magento = matrix.magento.map((item) => item.match(nextVersionRegExp) ? computeNextPackage(item, repository, date) : item);
|
||||
matrix.include = matrix.include.map((item) => {
|
||||
return item.magento.match(nextVersionRegExp)
|
||||
? {
|
||||
...item,
|
||||
magento: computeNextPackage(item.magento, repository, date),
|
||||
}
|
||||
: item;
|
||||
});
|
||||
return matrix;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
const KNOWN_REPOSITORIES = {
|
||||
"https://repo.mage-os.org": true,
|
||||
"https://nightly.mage-os.org": true,
|
||||
"https://upstream-mirror.mage-os.org": true,
|
||||
"https://upstream-nightly.mage-os.org": true,
|
||||
"https://repo.magento.com": true,
|
||||
}
|
||||
|
||||
export type Repository = keyof typeof KNOWN_REPOSITORIES;
|
||||
@@ -0,0 +1,32 @@
|
||||
import { unifyNextPackageName } from "./unify-next-package-name";
|
||||
|
||||
describe('unifyNextPackageName', () => {
|
||||
it('should do nothing to an unknown package', () => {
|
||||
expect(unifyNextPackageName('test', 'https://repo.mage-os.org', new Date())).toEqual('test');
|
||||
});
|
||||
|
||||
it('should do nothing to a next-available package at a non-next version', () => {
|
||||
expect(
|
||||
unifyNextPackageName('magento/product-community-edition:v2.4.5-p1', 'https://repo.mage-os.org', new Date())
|
||||
)
|
||||
.toEqual('magento/product-community-edition:v2.4.5-p1');
|
||||
});
|
||||
|
||||
it('should do nothing to a next package at a next version on a repo that doesnt support that version', () => {
|
||||
expect(
|
||||
unifyNextPackageName('magento/product-community-edition:next', 'https://repo.mage-os.org', new Date())
|
||||
).toEqual('magento/product-community-edition:next');
|
||||
});
|
||||
|
||||
it('should convert the next version to the specific format of the repo that supports the next version', () => {
|
||||
expect(
|
||||
unifyNextPackageName('magento/product-community-edition:next', 'https://upstream-nightly.mage-os.org', new Date())
|
||||
).toEqual('magento/product-community-edition:@alpha');
|
||||
});
|
||||
|
||||
it('should convert the next version to the specific format of the repo that supports the next version', () => {
|
||||
expect(
|
||||
unifyNextPackageName('mage-os/product-community-edition:next', 'https://nightly.mage-os.org', new Date())
|
||||
).toEqual('mage-os/product-community-edition:@alpha');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { getNextVersion } from "./get-next-version";
|
||||
import { Repository } from "./repository";
|
||||
|
||||
/**
|
||||
* Unify the next package name for the "nightly" version of a given repository and package name.
|
||||
*
|
||||
* Internally, we call this "next".
|
||||
* - MageOS calls this "alpha".
|
||||
* - Adobe calls this "beta".
|
||||
*
|
||||
* Someone else may call it something else. This may even differ per package repository
|
||||
* (Packagist vs. MageOS Mirror vs. Some other mirror).
|
||||
*
|
||||
* If the version isn't a "next" version, unifyNextPackageName will ignore it
|
||||
* and return the original package name.
|
||||
*/
|
||||
export const unifyNextPackageName = (packageName: string, repository: Repository, date: Date): string => {
|
||||
return packageName.replace(/(?!:)next$/, getNextVersion(repository, date));
|
||||
}
|
||||
Reference in New Issue
Block a user