feat: add project versions (#110)

* refactor: allow version matrixes by projects

* feat: add initial version-matrix for mage-os

* feat: add project as optional input to action

* docs: document new input

* refactor: tighten types a bit

* chore: apply change requests from code review
This commit is contained in:
Vinai Kopp
2023-09-06 22:08:57 +02:00
committed by GitHub
parent 28643a7156
commit f7f0504691
27 changed files with 331 additions and 67 deletions
@@ -1,49 +1,96 @@
import { getMatrixForKind } from "./get-matrix-for-kind";
describe('getMatrixForKind', () => {
describe('getMatrixForKind for mage-os', () => {
const project = "mage-os";
it('returns a matrix for `latest`', () => {
const result = getMatrixForKind("latest");
const result = getMatrixForKind("latest", project);
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('returns a matrix for `currently-supported`', () => {
const result = getMatrixForKind("currently-supported");
const result = getMatrixForKind("currently-supported", project);
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('returns a matrix for `all`', () => {
const result = getMatrixForKind("all");
const result = getMatrixForKind("all", project);
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('returns a matrix for valid `custom`', () => {
const result = getMatrixForKind("custom", "magento/project-community-edition:2.3.7-p3");
const result = getMatrixForKind("custom", project, "mage-os/project-community-edition:1.0.0");
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('returns a matrix for the next release when using `nightly`', () => {
const result = getMatrixForKind("nightly", "magento/project-community-edition:next");
const result = getMatrixForKind("nightly", project, "mage-os/project-community-edition:next");
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('errors for invalid `custom``', () => {
expect(() => getMatrixForKind("custom", project)).toThrowError();
});
})
describe('getMatrixForKind for magento-open-source', () => {
const project = "magento-open-source";
it('returns a matrix for `latest`', () => {
const result = getMatrixForKind("latest", project);
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('returns a matrix for `currently-supported`', () => {
const result = getMatrixForKind("currently-supported", project);
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('returns a matrix for `all`', () => {
const result = getMatrixForKind("all", project);
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('returns a matrix for valid `custom`', () => {
const result = getMatrixForKind("custom", project, "magento/project-community-edition:2.3.7-p3");
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('returns a matrix for the next release when using `nightly`', () => {
const result = getMatrixForKind("nightly", project, "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");
const result = getMatrixForKind("custom", project, "magento/project-community-edition:2.3.7-p3,magento/project-community-edition:2.4.0");
expect(result.magento).toBeDefined();
expect(result.include).toBeDefined();
});
it('errors for invalid `custom``', () => {
expect(() => getMatrixForKind("custom")).toThrowError();
expect(() => getMatrixForKind("custom", project)).toThrowError();
});
})