Parity with unity builder image version regex (#267)

pull/270/head v4.2.0
Andrew Kahr 2024-05-07 11:08:32 +01:00 committed by GitHub
parent fea469be8c
commit 5817131b76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 13 deletions

2
dist/index.js generated vendored
View File

@ -415,7 +415,7 @@ class ImageTag {
this.imageRollingVersion = Number(containerRegistryImageVersion); this.imageRollingVersion = Number(containerRegistryImageVersion);
} }
static get versionPattern() { static get versionPattern() {
return /^20\d{2}\.\d\.\w{3,4}|3$/; return /^\d+\.\d+\.\d+[a-z]\d+$/;
} }
static get targetPlatformSuffixes() { static get targetPlatformSuffixes() {
return { return {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -2,7 +2,7 @@ import ImageTag from './image-tag';
describe('ImageTag', () => { describe('ImageTag', () => {
const some = { const some = {
editorVersion: '2099.9.f9f9', editorVersion: '2099.9.9f9',
targetPlatform: 'Test', targetPlatform: 'Test',
builderPlatform: '', builderPlatform: '',
containerRegistryRepository: 'unityci/editor', containerRegistryRepository: 'unityci/editor',
@ -28,11 +28,14 @@ describe('ImageTag', () => {
expect(image.targetPlatformSuffix).toStrictEqual(some.builderPlatform); expect(image.targetPlatformSuffix).toStrictEqual(some.builderPlatform);
}); });
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', editorVersion => { test.each(['2000.0.0f0', '2011.1.11f1', '6000.0.0f1'])(
expect( 'accepts %p version format',
() => new ImageTag({ editorVersion, targetPlatform: some.targetPlatform }), editorVersion => {
).not.toThrow(); expect(
}); () => new ImageTag({ editorVersion, targetPlatform: some.targetPlatform }),
).not.toThrow();
},
);
test.each(['some version', '', 1])('throws for incorrect versions %p', editorVersion => { test.each(['some version', '', 1])('throws for incorrect versions %p', editorVersion => {
const { targetPlatform } = some; const { targetPlatform } = some;
@ -43,7 +46,7 @@ describe('ImageTag', () => {
describe('toString', () => { describe('toString', () => {
it('returns the correct version', () => { it('returns the correct version', () => {
const image = new ImageTag({ const image = new ImageTag({
editorVersion: '2099.1.1111', editorVersion: '2099.1.1111f1',
targetPlatform: some.targetPlatform, targetPlatform: some.targetPlatform,
containerRegistryRepository: 'unityci/editor', containerRegistryRepository: 'unityci/editor',
containerRegistryImageVersion: '3', containerRegistryImageVersion: '3',
@ -51,16 +54,16 @@ describe('ImageTag', () => {
switch (process.platform) { switch (process.platform) {
case 'win32': case 'win32':
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111-3`); expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111f1-3`);
break; break;
case 'linux': case 'linux':
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-3`); expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111f1-3`);
break; break;
} }
}); });
it('returns customImage if given', () => { it('returns customImage if given', () => {
const image = new ImageTag({ const image = new ImageTag({
editorVersion: '2099.1.1111', editorVersion: '2099.1.1111f1',
targetPlatform: some.targetPlatform, targetPlatform: some.targetPlatform,
customImage: `${defaults.image}:2099.1.1111@347598437689743986`, customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
containerRegistryRepository: 'unityci/editor', containerRegistryRepository: 'unityci/editor',

View File

@ -35,7 +35,7 @@ class ImageTag {
} }
static get versionPattern() { static get versionPattern() {
return /^20\d{2}\.\d\.\w{3,4}|3$/; return /^\d+\.\d+\.\d+[a-z]\d+$/;
} }
static get targetPlatformSuffixes() { static get targetPlatformSuffixes() {