Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution proposal to Issue Add customImage parameter #150 #151

Merged
merged 2 commits into from
Sep 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down
2 changes: 1 addition & 1 deletion action/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/model/build-parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class BuildParameters {

return {
version: Input.unityVersion,
customImage: Input.customImage,
uid,
gid,
runnerTempPath: process.env.RUNNER_TEMP,
Expand Down
7 changes: 6 additions & 1 deletion src/model/image-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ImageTag {
name = 'unity3d',
version = '2019.2.11f1',
platform,
customImage,
} = imageProperties;

if (!ImageTag.versionPattern.test(version)) {
Expand All @@ -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() {
Expand Down Expand Up @@ -82,6 +83,10 @@ class ImageTag {
toString() {
const { image, tag } = this;

if (this.customImage && this.customImage !== '') {
return this.customImage;
}

return `${image}:${tag}`;
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/model/image-tag.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand Down
4 changes: 4 additions & 0 deletions src/model/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
12 changes: 12 additions & 0 deletions src/model/input.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down