feat: support custom image
parent
7d26e264b9
commit
29899d84e8
|
@ -6,6 +6,10 @@ inputs:
|
|||
required: false
|
||||
default: '2019.2.11f1'
|
||||
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:
|
||||
required: false
|
||||
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 {
|
||||
unityVersion,
|
||||
customImage,
|
||||
projectPath,
|
||||
testMode,
|
||||
artifactsPath,
|
||||
useHostNetwork,
|
||||
customParameters,
|
||||
} = Input.getFromUser();
|
||||
const baseImage = ImageTag.createForBase(unityVersion);
|
||||
const baseImage = ImageTag.createForBase({ version: unityVersion, customImage });
|
||||
|
||||
// Build docker image
|
||||
const actionImage = await Docker.build({ path: actionFolder, dockerfile, baseImage });
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { trimStart } from 'lodash-es';
|
||||
|
||||
class ImageTag {
|
||||
static createForBase(version) {
|
||||
static createForBase({ version, customImage }) {
|
||||
const repository = 'gableroux';
|
||||
const name = 'unity3d';
|
||||
return new this({ repository, name, version });
|
||||
return new this({ repository, name, version, customImage });
|
||||
}
|
||||
|
||||
static createForAction(version) {
|
||||
|
@ -13,12 +13,12 @@ class ImageTag {
|
|||
return new this({ repository, name, version });
|
||||
}
|
||||
|
||||
constructor({ repository = '', name, version }) {
|
||||
constructor({ repository = '', name, version, customImage }) {
|
||||
if (!ImageTag.versionPattern.test(version)) {
|
||||
throw new Error(`Invalid version "${version}".`);
|
||||
}
|
||||
|
||||
Object.assign(this, { repository, name, version });
|
||||
Object.assign(this, { repository, name, version, customImage });
|
||||
}
|
||||
|
||||
static get versionPattern() {
|
||||
|
@ -34,6 +34,10 @@ class ImageTag {
|
|||
}
|
||||
|
||||
toString() {
|
||||
if (this.customImage && this.customImage !== '') {
|
||||
return this.customImage;
|
||||
}
|
||||
|
||||
return `${this.image}:${this.tag}`;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,9 +30,18 @@ describe('UnityImageVersion', () => {
|
|||
|
||||
describe('toString', () => {
|
||||
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`);
|
||||
});
|
||||
|
||||
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