Solution proposal to Issue Add customImage parameter #150 (#151)

* add customImage attribute

* add one more test for input passing && check for customImage == ''
This commit is contained in:
Kai Biermeier 2020-09-18 18:41:31 +02:00 committed by GitHub
parent cccd5074ea
commit 6a53a9e853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 2 deletions

View File

@ -6,6 +6,10 @@ inputs:
required: false
default: ''
description: 'Version of unity to use for building the project.'
customImage:
required: false
default: ''
description: 'Specific docker image that should be used for building the project'
targetPlatform:
required: false
default: ''

File diff suppressed because one or more lines are too long

View File

@ -25,6 +25,7 @@ class BuildParameters {
return {
version: Input.unityVersion,
customImage: Input.customImage,
uid,
gid,
runnerTempPath: process.env.RUNNER_TEMP,

View File

@ -8,6 +8,7 @@ class ImageTag {
name = 'unity3d',
version = '2019.2.11f1',
platform,
customImage,
} = imageProperties;
if (!ImageTag.versionPattern.test(version)) {
@ -24,7 +25,7 @@ class ImageTag {
ImageTag.imageSuffixes.generic,
);
Object.assign(this, { repository, name, version, platform, builderPlatform });
Object.assign(this, { repository, name, version, platform, builderPlatform, customImage });
}
static get versionPattern() {
@ -82,6 +83,10 @@ class ImageTag {
toString() {
const { image, tag } = this;
if (this.customImage && this.customImage !== '') {
return this.customImage;
}
return `${image}:${tag}`;
}
}

View File

@ -51,6 +51,15 @@ describe('UnityImageVersion', () => {
expect(image.toString()).toStrictEqual(`${defaults.image}:2099.1.1111`);
});
it('returns customImage if given', () => {
const image = new ImageTag({
version: '2099.1.1111',
platform: some.platform,
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
});
expect(image.toString()).toStrictEqual(image.customImage);
});
it('returns the specific build platform', () => {
const image = new ImageTag({ version: '2019.2.11f1', platform: 'WebGL' });

View File

@ -12,6 +12,10 @@ class Input {
return core.getInput('unityVersion');
}
static get customImage() {
return core.getInput('customImage');
}
static get targetPlatform() {
return core.getInput('targetPlatform') || Platform.default;
}

View File

@ -20,6 +20,18 @@ describe('Input', () => {
expect(spy).toHaveBeenCalledTimes(1);
});
});
describe('customImage', () => {
it('returns the default value', () => {
expect(Input.customImage).toStrictEqual('');
});
it('takes input from the users workflow', () => {
const mockValue = '2020.4.99f9';
const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
expect(Input.customImage).toStrictEqual(mockValue);
expect(spy).toHaveBeenCalledTimes(1);
});
});
describe('targetPlatform', () => {
it('returns the default value', () => {