Skip to content

Commit 6a53a9e

Browse files
authored
Solution proposal to Issue Add customImage parameter #150 (#151)
* add customImage attribute * add one more test for input passing && check for customImage == ''
1 parent cccd507 commit 6a53a9e

File tree

7 files changed

+37
-2
lines changed

7 files changed

+37
-2
lines changed

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ inputs:
66
required: false
77
default: ''
88
description: 'Version of unity to use for building the project.'
9+
customImage:
10+
required: false
11+
default: ''
12+
description: 'Specific docker image that should be used for building the project'
913
targetPlatform:
1014
required: false
1115
default: ''

action/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/model/build-parameters.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class BuildParameters {
2525

2626
return {
2727
version: Input.unityVersion,
28+
customImage: Input.customImage,
2829
uid,
2930
gid,
3031
runnerTempPath: process.env.RUNNER_TEMP,

src/model/image-tag.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class ImageTag {
88
name = 'unity3d',
99
version = '2019.2.11f1',
1010
platform,
11+
customImage,
1112
} = imageProperties;
1213

1314
if (!ImageTag.versionPattern.test(version)) {
@@ -24,7 +25,7 @@ class ImageTag {
2425
ImageTag.imageSuffixes.generic,
2526
);
2627

27-
Object.assign(this, { repository, name, version, platform, builderPlatform });
28+
Object.assign(this, { repository, name, version, platform, builderPlatform, customImage });
2829
}
2930

3031
static get versionPattern() {
@@ -82,6 +83,10 @@ class ImageTag {
8283
toString() {
8384
const { image, tag } = this;
8485

86+
if (this.customImage && this.customImage !== '') {
87+
return this.customImage;
88+
}
89+
8590
return `${image}:${tag}`;
8691
}
8792
}

src/model/image-tag.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ describe('UnityImageVersion', () => {
5151

5252
expect(image.toString()).toStrictEqual(`${defaults.image}:2099.1.1111`);
5353
});
54+
it('returns customImage if given', () => {
55+
const image = new ImageTag({
56+
version: '2099.1.1111',
57+
platform: some.platform,
58+
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
59+
});
60+
61+
expect(image.toString()).toStrictEqual(image.customImage);
62+
});
5463

5564
it('returns the specific build platform', () => {
5665
const image = new ImageTag({ version: '2019.2.11f1', platform: 'WebGL' });

src/model/input.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ class Input {
1212
return core.getInput('unityVersion');
1313
}
1414

15+
static get customImage() {
16+
return core.getInput('customImage');
17+
}
18+
1519
static get targetPlatform() {
1620
return core.getInput('targetPlatform') || Platform.default;
1721
}

src/model/input.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ describe('Input', () => {
2020
expect(spy).toHaveBeenCalledTimes(1);
2121
});
2222
});
23+
describe('customImage', () => {
24+
it('returns the default value', () => {
25+
expect(Input.customImage).toStrictEqual('');
26+
});
27+
28+
it('takes input from the users workflow', () => {
29+
const mockValue = '2020.4.99f9';
30+
const spy = jest.spyOn(core, 'getInput').mockReturnValue(mockValue);
31+
expect(Input.customImage).toStrictEqual(mockValue);
32+
expect(spy).toHaveBeenCalledTimes(1);
33+
});
34+
});
2335

2436
describe('targetPlatform', () => {
2537
it('returns the default value', () => {

0 commit comments

Comments
 (0)