feat: support custom image
parent
7d26e264b9
commit
29899d84e8
|
@ -6,6 +6,10 @@ inputs:
|
||||||
required: false
|
required: false
|
||||||
default: '2019.2.11f1'
|
default: '2019.2.11f1'
|
||||||
description: 'Version of unity to use for testing the project.'
|
description: 'Version of unity to use for testing the project.'
|
||||||
|
customImage:
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
description: 'Specific docker image that should be used for building the project'
|
||||||
projectPath:
|
projectPath:
|
||||||
required: false
|
required: false
|
||||||
description: 'Path to the Unity project to be tested.'
|
description: 'Path to the Unity project to be tested.'
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -7,13 +7,14 @@ async function action() {
|
||||||
const { dockerfile, workspace, actionFolder } = Action;
|
const { dockerfile, workspace, actionFolder } = Action;
|
||||||
const {
|
const {
|
||||||
unityVersion,
|
unityVersion,
|
||||||
|
customImage,
|
||||||
projectPath,
|
projectPath,
|
||||||
testMode,
|
testMode,
|
||||||
artifactsPath,
|
artifactsPath,
|
||||||
useHostNetwork,
|
useHostNetwork,
|
||||||
customParameters,
|
customParameters,
|
||||||
} = Input.getFromUser();
|
} = Input.getFromUser();
|
||||||
const baseImage = ImageTag.createForBase(unityVersion);
|
const baseImage = ImageTag.createForBase({ version: unityVersion, customImage });
|
||||||
|
|
||||||
// Build docker image
|
// Build docker image
|
||||||
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
import { trimStart } from 'lodash-es';
|
import { trimStart } from 'lodash-es';
|
||||||
|
|
||||||
class ImageTag {
|
class ImageTag {
|
||||||
static createForBase(version) {
|
static createForBase({ version, customImage }) {
|
||||||
const repository = 'gableroux';
|
const repository = 'gableroux';
|
||||||
const name = 'unity3d';
|
const name = 'unity3d';
|
||||||
return new this({ repository, name, version });
|
return new this({ repository, name, version, customImage });
|
||||||
}
|
}
|
||||||
|
|
||||||
static createForAction(version) {
|
static createForAction(version) {
|
||||||
|
@ -13,12 +13,12 @@ class ImageTag {
|
||||||
return new this({ repository, name, version });
|
return new this({ repository, name, version });
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor({ repository = '', name, version }) {
|
constructor({ repository = '', name, version, customImage }) {
|
||||||
if (!ImageTag.versionPattern.test(version)) {
|
if (!ImageTag.versionPattern.test(version)) {
|
||||||
throw new Error(`Invalid version "${version}".`);
|
throw new Error(`Invalid version "${version}".`);
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.assign(this, { repository, name, version });
|
Object.assign(this, { repository, name, version, customImage });
|
||||||
}
|
}
|
||||||
|
|
||||||
static get versionPattern() {
|
static get versionPattern() {
|
||||||
|
@ -34,6 +34,10 @@ class ImageTag {
|
||||||
}
|
}
|
||||||
|
|
||||||
toString() {
|
toString() {
|
||||||
|
if (this.customImage && this.customImage !== '') {
|
||||||
|
return this.customImage;
|
||||||
|
}
|
||||||
|
|
||||||
return `${this.image}:${this.tag}`;
|
return `${this.image}:${this.tag}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,9 +30,18 @@ describe('UnityImageVersion', () => {
|
||||||
|
|
||||||
describe('toString', () => {
|
describe('toString', () => {
|
||||||
it('returns the correct version', () => {
|
it('returns the correct version', () => {
|
||||||
const image = ImageTag.createForBase('2099.1.1111');
|
const image = ImageTag.createForBase({ version: '2099.1.1111' });
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(`gableroux/unity3d:2099.1.1111`);
|
expect(image.toString()).toStrictEqual(`gableroux/unity3d:2099.1.1111`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns customImage if given', () => {
|
||||||
|
const image = ImageTag.createForBase({
|
||||||
|
version: '2099.1.1111',
|
||||||
|
customImage: 'unityci/editor:2099.1.1111-base-0',
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(image.toString()).toStrictEqual(image.customImage);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue