mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-07 20:35:33 -04:00
Allow customization of container registry and image version
This commit is contained in:
parent
aae14202b7
commit
ab9d6f5eea
@ -124,6 +124,14 @@ inputs:
|
|||||||
'Isolation mode to use for the docker container. Can be one of process, hyperv, or default. Default will pick the
|
'Isolation mode to use for the docker container. Can be one of process, hyperv, or default. Default will pick the
|
||||||
default mode as described by Microsoft where server versions use process and desktop versions use hyperv. Only
|
default mode as described by Microsoft where server versions use process and desktop versions use hyperv. Only
|
||||||
applicable on Windows'
|
applicable on Windows'
|
||||||
|
containerRegistryRepository:
|
||||||
|
required: false
|
||||||
|
default: 'unityci/editor'
|
||||||
|
description: 'Container registry url to pull image from. Only applicable if customImage is not set.'
|
||||||
|
containerRegistryImageVersion:
|
||||||
|
required: false
|
||||||
|
default: '3'
|
||||||
|
description: 'Container registry image version. Only applicable if customImage is not set.'
|
||||||
allowDirtyBuild:
|
allowDirtyBuild:
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
@ -44,6 +44,8 @@ class BuildParameters {
|
|||||||
public dockerCpuLimit!: string;
|
public dockerCpuLimit!: string;
|
||||||
public dockerMemoryLimit!: string;
|
public dockerMemoryLimit!: string;
|
||||||
public dockerIsolationMode!: string;
|
public dockerIsolationMode!: string;
|
||||||
|
public containerRegistryRepository!: string;
|
||||||
|
public containerRegistryImageVersion!: string;
|
||||||
|
|
||||||
public customParameters!: string;
|
public customParameters!: string;
|
||||||
public sshAgent!: string;
|
public sshAgent!: string;
|
||||||
@ -170,6 +172,8 @@ class BuildParameters {
|
|||||||
dockerCpuLimit: Input.dockerCpuLimit,
|
dockerCpuLimit: Input.dockerCpuLimit,
|
||||||
dockerMemoryLimit: Input.dockerMemoryLimit,
|
dockerMemoryLimit: Input.dockerMemoryLimit,
|
||||||
dockerIsolationMode: Input.dockerIsolationMode,
|
dockerIsolationMode: Input.dockerIsolationMode,
|
||||||
|
containerRegistryRepository: Input.containerRegistryRepository,
|
||||||
|
containerRegistryImageVersion: Input.containerRegistryImageVersion,
|
||||||
providerStrategy: CloudRunnerOptions.providerStrategy,
|
providerStrategy: CloudRunnerOptions.providerStrategy,
|
||||||
buildPlatform: CloudRunnerOptions.buildPlatform,
|
buildPlatform: CloudRunnerOptions.buildPlatform,
|
||||||
kubeConfig: CloudRunnerOptions.kubeConfig,
|
kubeConfig: CloudRunnerOptions.kubeConfig,
|
||||||
|
@ -5,11 +5,11 @@ describe('ImageTag', () => {
|
|||||||
editorVersion: '2099.9.f9f9',
|
editorVersion: '2099.9.f9f9',
|
||||||
targetPlatform: 'Test',
|
targetPlatform: 'Test',
|
||||||
builderPlatform: '',
|
builderPlatform: '',
|
||||||
|
containerRegistryRepository: 'unityci/editor',
|
||||||
|
containerRegistryImageVersion: '3',
|
||||||
};
|
};
|
||||||
|
|
||||||
const defaults = {
|
const defaults = {
|
||||||
repository: 'unityci',
|
|
||||||
name: 'editor',
|
|
||||||
image: 'unityci/editor',
|
image: 'unityci/editor',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -21,8 +21,7 @@ describe('ImageTag', () => {
|
|||||||
it('accepts parameters and sets the right properties', () => {
|
it('accepts parameters and sets the right properties', () => {
|
||||||
const image = new ImageTag(testImageParameters);
|
const image = new ImageTag(testImageParameters);
|
||||||
|
|
||||||
expect(image.repository).toStrictEqual('unityci');
|
expect(image.repository).toStrictEqual('unityci/editor');
|
||||||
expect(image.name).toStrictEqual('editor');
|
|
||||||
expect(image.editorVersion).toStrictEqual(testImageParameters.editorVersion);
|
expect(image.editorVersion).toStrictEqual(testImageParameters.editorVersion);
|
||||||
expect(image.targetPlatform).toStrictEqual(testImageParameters.targetPlatform);
|
expect(image.targetPlatform).toStrictEqual(testImageParameters.targetPlatform);
|
||||||
expect(image.builderPlatform).toStrictEqual(testImageParameters.builderPlatform);
|
expect(image.builderPlatform).toStrictEqual(testImageParameters.builderPlatform);
|
||||||
@ -53,6 +52,8 @@ describe('ImageTag', () => {
|
|||||||
const image = new ImageTag({
|
const image = new ImageTag({
|
||||||
editorVersion: '2099.1.1111',
|
editorVersion: '2099.1.1111',
|
||||||
targetPlatform: testImageParameters.targetPlatform,
|
targetPlatform: testImageParameters.targetPlatform,
|
||||||
|
containerRegistryRepository: 'unityci/editor',
|
||||||
|
containerRegistryImageVersion: '3',
|
||||||
});
|
});
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
case 'win32':
|
case 'win32':
|
||||||
@ -68,6 +69,8 @@ describe('ImageTag', () => {
|
|||||||
editorVersion: '2099.1.1111',
|
editorVersion: '2099.1.1111',
|
||||||
targetPlatform: testImageParameters.targetPlatform,
|
targetPlatform: testImageParameters.targetPlatform,
|
||||||
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
|
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
|
||||||
|
containerRegistryRepository: 'unityci/editor',
|
||||||
|
containerRegistryImageVersion: '3',
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(image.toString()).toStrictEqual(image.customImage);
|
expect(image.toString()).toStrictEqual(image.customImage);
|
||||||
@ -77,6 +80,8 @@ describe('ImageTag', () => {
|
|||||||
const image = new ImageTag({
|
const image = new ImageTag({
|
||||||
editorVersion: '2019.2.11f1',
|
editorVersion: '2019.2.11f1',
|
||||||
targetPlatform: 'WebGL',
|
targetPlatform: 'WebGL',
|
||||||
|
containerRegistryRepository: 'unityci/editor',
|
||||||
|
containerRegistryImageVersion: '3',
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
@ -93,6 +98,8 @@ describe('ImageTag', () => {
|
|||||||
const image = new ImageTag({
|
const image = new ImageTag({
|
||||||
editorVersion: '2019.2.11f1',
|
editorVersion: '2019.2.11f1',
|
||||||
targetPlatform: 'NoTarget',
|
targetPlatform: 'NoTarget',
|
||||||
|
containerRegistryRepository: 'unityci/editor',
|
||||||
|
containerRegistryImageVersion: '3',
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (process.platform) {
|
switch (process.platform) {
|
||||||
|
@ -2,7 +2,6 @@ import Platform from './platform';
|
|||||||
|
|
||||||
class ImageTag {
|
class ImageTag {
|
||||||
public repository: string;
|
public repository: string;
|
||||||
public name: string;
|
|
||||||
public cloudRunnerBuilderPlatform!: string;
|
public cloudRunnerBuilderPlatform!: string;
|
||||||
public editorVersion: string;
|
public editorVersion: string;
|
||||||
public targetPlatform: string;
|
public targetPlatform: string;
|
||||||
@ -12,7 +11,14 @@ class ImageTag {
|
|||||||
public imagePlatformPrefix: string;
|
public imagePlatformPrefix: string;
|
||||||
|
|
||||||
constructor(imageProperties: { [key: string]: string }) {
|
constructor(imageProperties: { [key: string]: string }) {
|
||||||
const { editorVersion, targetPlatform, customImage, cloudRunnerBuilderPlatform } = imageProperties;
|
const {
|
||||||
|
editorVersion,
|
||||||
|
targetPlatform,
|
||||||
|
customImage,
|
||||||
|
cloudRunnerBuilderPlatform,
|
||||||
|
containerRegistryRepository,
|
||||||
|
containerRegistryImageVersion,
|
||||||
|
} = imageProperties;
|
||||||
|
|
||||||
if (!ImageTag.versionPattern.test(editorVersion)) {
|
if (!ImageTag.versionPattern.test(editorVersion)) {
|
||||||
throw new Error(`Invalid version "${editorVersion}".`);
|
throw new Error(`Invalid version "${editorVersion}".`);
|
||||||
@ -23,8 +29,7 @@ class ImageTag {
|
|||||||
this.customImage = customImage;
|
this.customImage = customImage;
|
||||||
|
|
||||||
// Or
|
// Or
|
||||||
this.repository = 'unityci';
|
this.repository = containerRegistryRepository;
|
||||||
this.name = 'editor';
|
|
||||||
this.editorVersion = editorVersion;
|
this.editorVersion = editorVersion;
|
||||||
this.targetPlatform = targetPlatform;
|
this.targetPlatform = targetPlatform;
|
||||||
this.cloudRunnerBuilderPlatform = cloudRunnerBuilderPlatform;
|
this.cloudRunnerBuilderPlatform = cloudRunnerBuilderPlatform;
|
||||||
@ -33,7 +38,7 @@ class ImageTag {
|
|||||||
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefixes(
|
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefixes(
|
||||||
isCloudRunnerLocal ? process.platform : cloudRunnerBuilderPlatform,
|
isCloudRunnerLocal ? process.platform : cloudRunnerBuilderPlatform,
|
||||||
);
|
);
|
||||||
this.imageRollingVersion = 3; // Will automatically roll to the latest non-breaking version.
|
this.imageRollingVersion = Number(containerRegistryImageVersion); // Will automatically roll to the latest non-breaking version.
|
||||||
}
|
}
|
||||||
|
|
||||||
static get versionPattern(): RegExp {
|
static get versionPattern(): RegExp {
|
||||||
@ -156,7 +161,7 @@ class ImageTag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get image(): string {
|
get image(): string {
|
||||||
return `${this.repository}/${this.name}`.replace(/^\/+/, '');
|
return `${this.repository}`.replace(/^\/+/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string {
|
toString(): string {
|
||||||
|
@ -256,6 +256,14 @@ class Input {
|
|||||||
return Input.getInput('dockerIsolationMode') || 'default';
|
return Input.getInput('dockerIsolationMode') || 'default';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static get containerRegistryRepository(): string {
|
||||||
|
return Input.getInput('containerRegistryUrl')!;
|
||||||
|
}
|
||||||
|
|
||||||
|
static get containerRegistryImageVersion(): string {
|
||||||
|
return Input.getInput('containerRegistryImageVersion')!;
|
||||||
|
}
|
||||||
|
|
||||||
public static ToEnvVarFormat(input: string) {
|
public static ToEnvVarFormat(input: string) {
|
||||||
if (input.toUpperCase() === input) {
|
if (input.toUpperCase() === input) {
|
||||||
return input;
|
return input;
|
||||||
|
Loading…
Reference in New Issue
Block a user