mirror of
https://github.com/graycoreio/github-actions-magento2.git
synced 2026-06-08 19:46:41 +00:00
feat: allow using "next" version on supported version (#58)
This also allows using the action in https://github.com/mage-os/generate-mirror-repo-js where the test module is an external package installed with composer. In this case, no local path repo configuration is needed. Co-authored-by: Vinai Kopp <Vinai@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
use_local_source:
|
||||
type: boolean
|
||||
required: false
|
||||
default: true
|
||||
description: "Whether or not you want to test your local package or not."
|
||||
|
||||
source_folder:
|
||||
type: string
|
||||
@@ -130,6 +135,7 @@ jobs:
|
||||
name: Add Github Repo for Testing
|
||||
working-directory: ${{ inputs.magento_directory }}
|
||||
shell: bash
|
||||
if: ${{ inputs.use_local_source == true }}
|
||||
|
||||
- run: composer require monolog/monolog:"<2.7.0" --no-update
|
||||
name: Fixup Monolog (https://github.com/magento/magento2/pull/35596)
|
||||
|
||||
@@ -18,6 +18,11 @@ inputs:
|
||||
default: "2"
|
||||
description: "The version of composer to use"
|
||||
|
||||
use_local_source:
|
||||
required: false
|
||||
default: "true"
|
||||
description: "Whether or not you want to test your local package or not."
|
||||
|
||||
source_folder:
|
||||
required: true
|
||||
default: $GITHUB_WORKSPACE
|
||||
@@ -86,6 +91,7 @@ runs:
|
||||
name: Add Github Repo for Testing
|
||||
working-directory: ${{ inputs.magento_directory }}
|
||||
shell: bash
|
||||
if: ${{ inputs.use_local_source == 'true' }}
|
||||
|
||||
- run: |
|
||||
composer config --no-interaction allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
|
||||
|
||||
Generated
+1
-2
@@ -8062,8 +8062,7 @@
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz",
|
||||
"integrity": "sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w==",
|
||||
"dev": true,
|
||||
"requires": {}
|
||||
"dev": true
|
||||
},
|
||||
"jest-regex-util": {
|
||||
"version": "28.0.2",
|
||||
|
||||
@@ -13,9 +13,15 @@ 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`, and `all` | false | 'currently-supported' |
|
||||
| kind | The "kind" of support you're targeting for your package. Allowed values are `currently-supported`, `latest`, `custom`, `nightly` and `all` | false | 'currently-supported' |
|
||||
| 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 | '' |
|
||||
|
||||
## 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.
|
||||
- `nightly` - The nightly version of Magento (only available via `https://upstream-nightly.mage-os.org`)
|
||||
- `all` - All versions of Magento (including patched/unpatched versions).
|
||||
## Usage
|
||||
|
||||
```yml
|
||||
|
||||
@@ -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, all`"
|
||||
description: "The kind of versions you want to return. Allowed values are `currently-supported`, `latest`, `custom`, `nightly` and `all`"
|
||||
default: "currently-supported"
|
||||
custom_versions:
|
||||
required: false
|
||||
|
||||
Vendored
+5
-5
File diff suppressed because one or more lines are too long
@@ -5,6 +5,7 @@ export const KNOWN_KINDS = {
|
||||
'currently-supported': true,
|
||||
'latest': true,
|
||||
'custom': true,
|
||||
'nightly': true,
|
||||
'all': true,
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
[
|
||||
"magento/project-community-edition:next"
|
||||
]
|
||||
@@ -29,6 +29,13 @@ describe('getMatrixForKind', () => {
|
||||
expect(result.include).toBeDefined();
|
||||
});
|
||||
|
||||
it('returns a matrix for the next release when using `nightly`', () => {
|
||||
const result = getMatrixForKind("nightly", "magento/project-community-edition:next");
|
||||
|
||||
expect(result.magento).toBeDefined();
|
||||
expect(result.include).toBeDefined();
|
||||
});
|
||||
|
||||
it('returns a matrix for valid multiple `custom`', () => {
|
||||
const result = getMatrixForKind("custom", "magento/project-community-edition:2.3.7-p3,magento/project-community-edition:2.4.0");
|
||||
|
||||
|
||||
@@ -3,6 +3,9 @@ import { getMatrixForVersions } from "./get-matrix-for-versions";
|
||||
import latestJson from '../kind/latest.json';
|
||||
import currentlySupportedJson from '../kind/currently-supported.json';
|
||||
import allVersions from '../versions/individual.json';
|
||||
import nightly from '../kind/nightly.json';
|
||||
import { amendMatrixForNext } from "../nightly/get-next-version";
|
||||
import { getDayBefore } from '../nightly/get-day-before';
|
||||
|
||||
export const getMatrixForKind = (kind: string, versions: string = "") => {
|
||||
switch(kind){
|
||||
@@ -10,6 +13,8 @@ export const getMatrixForKind = (kind: string, versions: string = "") => {
|
||||
return getMatrixForVersions(latestJson);
|
||||
case 'currently-supported':
|
||||
return getMatrixForVersions(currentlySupportedJson);
|
||||
case 'nightly':
|
||||
return amendMatrixForNext(getMatrixForVersions(nightly), 'https://upstream-mirror.mage-os.org', getDayBefore());
|
||||
case 'all':
|
||||
return getMatrixForVersions(Object.keys(allVersions));
|
||||
case 'custom':
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Gets the date one day before the date.
|
||||
*/
|
||||
export const getDayBefore = (date: Date = new Date()) => {
|
||||
const yesterday = new Date(date);
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
return yesterday;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { getNextVersion } from "./get-next-version"
|
||||
|
||||
describe('getNextVersion', () => {
|
||||
|
||||
it('should get the next nightly version for MageOS', () => {
|
||||
expect(getNextVersion('https://upstream-mirror.mage-os.org', new Date('2022-09-29T17:47:00')), ).toEqual('@alpha');
|
||||
});
|
||||
|
||||
it('should handle the first of the month correctly', () => {
|
||||
expect(getNextVersion('https://upstream-mirror.mage-os.org', new Date('2022-01-01T17:47:00')), ).toEqual('@alpha');
|
||||
});
|
||||
})
|
||||
@@ -0,0 +1,44 @@
|
||||
import { GithubActionsMatrix } from "../matrix/matrix-type";
|
||||
|
||||
export type Repository = "https://upstream-mirror.mage-os.org" | "https://repo.magento.com";
|
||||
|
||||
/**
|
||||
* 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 = "magento/project-community-edition:next";
|
||||
|
||||
/**
|
||||
* Get the next version of Magento, as determined by the repository.
|
||||
*/
|
||||
export const getNextVersion = (repository: Repository, date: Date) => {
|
||||
switch(repository){
|
||||
case "https://upstream-mirror.mage-os.org":
|
||||
// See: https://github.com/mage-os/generate-mirror-repo-js/blob/bbbdf1708ea0bf8fc845aad8240d00f37632b4a7/src/release-branch-build-tools.js#L71
|
||||
return "@alpha";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
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 = "https://upstream-mirror.mage-os.org", date: Date = new Date()): GithubActionsMatrix => {
|
||||
matrix.magento = matrix.magento.map((item) => item === nextVersionPlaceHolder ? computeNextPackage(nextVersionPlaceHolder, repository, date) : item);
|
||||
matrix.include = matrix.include.map((item) => {
|
||||
return item.magento === nextVersionPlaceHolder
|
||||
? {
|
||||
...item,
|
||||
magento: computeNextPackage(nextVersionPlaceHolder, repository, date),
|
||||
}
|
||||
: item;
|
||||
});
|
||||
return matrix;
|
||||
}
|
||||
@@ -94,5 +94,17 @@
|
||||
"varnish": "varnish:7.0",
|
||||
"nginx": "nginx:1.18",
|
||||
"os": "ubuntu-latest"
|
||||
},
|
||||
"magento/project-community-edition:next": {
|
||||
"magento": "magento/project-community-edition:next",
|
||||
"php": 8.1,
|
||||
"composer": 2,
|
||||
"mysql": "mysql:8.0",
|
||||
"elasticsearch": "elasticsearch:7.17.5",
|
||||
"rabbitmq": "rabbitmq:3.9",
|
||||
"redis": "redis:6.2",
|
||||
"varnish": "varnish:7.0",
|
||||
"nginx": "nginx:1.18",
|
||||
"os": "ubuntu-latest"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user