mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00
Switch to version 1 images (#374)
* feat: upgrade to images of version 1 (rolling tag) * chore: indicate what needs to move out of the input class
This commit is contained in:
parent
1bc7130fea
commit
441be81543
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.
@ -2,7 +2,7 @@
|
||||
import Platform from '../platform';
|
||||
|
||||
export const mockGetFromUser = jest.fn().mockResolvedValue({
|
||||
version: '',
|
||||
editorVersion: '',
|
||||
targetPlatform: Platform.types.Test,
|
||||
projectPath: '.',
|
||||
buildName: Platform.types.Test,
|
||||
|
@ -1,3 +1,3 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`Versioning determineVersion throws for invalid strategy somethingRandom 1`] = `"Versioning strategy should be one of None, Semantic, Tag, Custom."`;
|
||||
exports[`Versioning determineBuildVersion throws for invalid strategy somethingRandom 1`] = `"Versioning strategy should be one of None, Semantic, Tag, Custom."`;
|
||||
|
@ -10,7 +10,7 @@ const testLicense =
|
||||
'<?xml version="1.0" encoding="UTF-8"?><root>\n <License id="Terms">\n <MachineBindings>\n <Binding Key="1" Value="576562626572264761624c65526f7578"/>\n <Binding Key="2" Value="576562626572264761624c65526f7578"/>\n </MachineBindings>\n <MachineID Value="D7nTUnjNAmtsUMcnoyrqkgIbYdM="/>\n <SerialHash Value="2033b8ac3e6faa3742ca9f0bfae44d18f2a96b80"/>\n <Features>\n <Feature Value="33"/>\n <Feature Value="1"/>\n <Feature Value="12"/>\n <Feature Value="2"/>\n <Feature Value="24"/>\n <Feature Value="3"/>\n <Feature Value="36"/>\n <Feature Value="17"/>\n <Feature Value="19"/>\n <Feature Value="62"/>\n </Features>\n <DeveloperData Value="AQAAAEY0LUJHUlgtWEQ0RS1aQ1dWLUM1SlctR0RIQg=="/>\n <SerialMasked Value="F4-BGRX-XD4E-ZCWV-C5JW-XXXX"/>\n <StartDate Value="2021-02-08T00:00:00"/>\n <UpdateDate Value="2021-02-09T00:34:57"/>\n <InitialActivationDate Value="2021-02-08T00:34:56"/>\n <LicenseVersion Value="6.x"/>\n <ClientProvidedVersion Value="2018.4.30f1"/>\n <AlwaysOnline Value="false"/>\n <Entitlements>\n <Entitlement Ns="unity_editor" Tag="UnityPersonal" Type="EDITOR" ValidTo="9999-12-31T00:00:00"/>\n <Entitlement Ns="unity_editor" Tag="DarkSkin" Type="EDITOR_FEATURE" ValidTo="9999-12-31T00:00:00"/>\n </Entitlements>\n </License>\n<Signature xmlns="http://www.w3.org/2000/09/xmldsig#"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><Reference URI="#Terms"><Transforms><Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/><DigestValue>m0Db8UK+ktnOLJBtHybkfetpcKo=</DigestValue></Reference></SignedInfo><SignatureValue>o/pUbSQAukz7+ZYAWhnA0AJbIlyyCPL7bKVEM2lVqbrXt7cyey+umkCXamuOgsWPVUKBMkXtMH8L\n5etLmD0getWIhTGhzOnDCk+gtIPfL4jMo9tkEuOCROQAXCci23VFscKcrkB+3X6h4wEOtA2APhOY\nB+wvC794o8/82ffjP79aVAi57rp3Wmzx+9pe9yMwoJuljAy2sc2tIMgdQGWVmOGBpQm3JqsidyzI\nJWG2kjnc7pDXK9pwYzXoKiqUqqrut90d+kQqRyv7MSZXR50HFqD/LI69h68b7P8Bjo3bPXOhNXGR\n9YCoemH6EkfCJxp2gIjzjWW+l2Hj2EsFQi8YXw==</SignatureValue></Signature></root>';
|
||||
process.env.UNITY_LICENSE = testLicense;
|
||||
|
||||
const determineVersion = jest.spyOn(Versioning, 'determineVersion').mockImplementation(async () => '1.3.37');
|
||||
const determineVersion = jest.spyOn(Versioning, 'determineBuildVersion').mockImplementation(async () => '1.3.37');
|
||||
const determineUnityVersion = jest
|
||||
.spyOn(UnityVersioning, 'determineUnityVersion')
|
||||
.mockImplementation(() => '2019.2.11f1');
|
||||
@ -55,10 +55,10 @@ describe('BuildParameters', () => {
|
||||
expect(determineSdkManagerParameters).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('returns the platform', async () => {
|
||||
it('returns the targetPlatform', async () => {
|
||||
const mockValue = 'somePlatform';
|
||||
jest.spyOn(Input, 'targetPlatform', 'get').mockReturnValue(mockValue);
|
||||
expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ platform: mockValue }));
|
||||
expect(BuildParameters.create()).resolves.toEqual(expect.objectContaining({ targetPlatform: mockValue }));
|
||||
});
|
||||
|
||||
it('returns the project path', async () => {
|
||||
|
@ -9,11 +9,11 @@ import UnityVersioning from './unity-versioning';
|
||||
import Versioning from './versioning';
|
||||
|
||||
class BuildParameters {
|
||||
public version!: string;
|
||||
public editorVersion!: string;
|
||||
public customImage!: string;
|
||||
public unitySerial!: string;
|
||||
public runnerTempPath: string | undefined;
|
||||
public platform!: string;
|
||||
public targetPlatform!: string;
|
||||
public projectPath!: string;
|
||||
public buildName!: string;
|
||||
public buildPath!: string;
|
||||
@ -55,8 +55,8 @@ class BuildParameters {
|
||||
|
||||
static async create(): Promise<BuildParameters> {
|
||||
const buildFile = this.parseBuildFile(Input.buildName, Input.targetPlatform, Input.androidAppBundle);
|
||||
const unityVersion = UnityVersioning.determineUnityVersion(Input.projectPath, Input.unityVersion);
|
||||
const buildVersion = await Versioning.determineVersion(Input.versioningStrategy, Input.specifiedVersion);
|
||||
const editorVersion = UnityVersioning.determineUnityVersion(Input.projectPath, Input.unityVersion);
|
||||
const buildVersion = await Versioning.determineBuildVersion(Input.versioningStrategy, Input.specifiedVersion);
|
||||
const androidVersionCode = AndroidVersioning.determineVersionCode(buildVersion, Input.androidVersionCode);
|
||||
const androidSdkManagerParameters = AndroidVersioning.determineSdkManagerParameters(Input.androidTargetSdkVersion);
|
||||
|
||||
@ -79,12 +79,12 @@ class BuildParameters {
|
||||
// ---
|
||||
|
||||
return {
|
||||
version: unityVersion,
|
||||
editorVersion,
|
||||
customImage: Input.customImage,
|
||||
unitySerial,
|
||||
|
||||
runnerTempPath: process.env.RUNNER_TEMP,
|
||||
platform: Input.targetPlatform,
|
||||
targetPlatform: Input.targetPlatform,
|
||||
projectPath: Input.projectPath,
|
||||
buildName: Input.buildName,
|
||||
buildPath: `${Input.buildsPath}/${Input.targetPlatform}`,
|
||||
@ -116,6 +116,7 @@ class BuildParameters {
|
||||
customJob: Input.customJob,
|
||||
runNumber: Input.runNumber,
|
||||
branch: await Input.branch(),
|
||||
// Todo - move this out of UserInput and into some class that determines additional information (as needed)
|
||||
githubRepo: await Input.githubRepo(),
|
||||
remoteBuildCluster: Input.cloudRunnerCluster,
|
||||
awsStackName: Input.awsBaseStackName,
|
||||
|
@ -60,7 +60,7 @@ class KubernetesJobSpecFactory {
|
||||
},
|
||||
{
|
||||
name: 'BUILD_TARGET',
|
||||
value: buildParameters.platform,
|
||||
value: buildParameters.targetPlatform,
|
||||
},
|
||||
{
|
||||
name: 'ANDROID_VERSION_CODE',
|
||||
|
@ -18,7 +18,7 @@ export class TaskParameterSerializer {
|
||||
},
|
||||
{
|
||||
name: 'BUILD_TARGET',
|
||||
value: CloudRunnerState.buildParams.platform,
|
||||
value: CloudRunnerState.buildParams.targetPlatform,
|
||||
},
|
||||
...TaskParameterSerializer.serializeBuildParamsAndInput,
|
||||
];
|
||||
|
@ -30,10 +30,10 @@ class ImageEnvironmentFactory {
|
||||
{ name: 'UNITY_EMAIL', value: process.env.UNITY_EMAIL },
|
||||
{ name: 'UNITY_PASSWORD', value: process.env.UNITY_PASSWORD },
|
||||
{ name: 'UNITY_SERIAL', value: parameters.unitySerial },
|
||||
{ name: 'UNITY_VERSION', value: parameters.version },
|
||||
{ name: 'UNITY_VERSION', value: parameters.editorVersion },
|
||||
{ name: 'USYM_UPLOAD_AUTH_TOKEN', value: process.env.USYM_UPLOAD_AUTH_TOKEN },
|
||||
{ name: 'PROJECT_PATH', value: parameters.projectPath },
|
||||
{ name: 'BUILD_TARGET', value: parameters.platform },
|
||||
{ name: 'BUILD_TARGET', value: parameters.targetPlatform },
|
||||
{ name: 'BUILD_NAME', value: parameters.buildName },
|
||||
{ name: 'BUILD_PATH', value: parameters.buildPath },
|
||||
{ name: 'BUILD_FILE', value: parameters.buildFile },
|
||||
|
@ -2,10 +2,8 @@ import ImageTag from './image-tag';
|
||||
|
||||
describe('ImageTag', () => {
|
||||
const some = {
|
||||
repository: 'test1',
|
||||
name: 'test2',
|
||||
version: '2099.9.f9f9',
|
||||
platform: 'Test',
|
||||
editorVersion: '2099.9.f9f9',
|
||||
targetPlatform: 'Test',
|
||||
builderPlatform: '',
|
||||
};
|
||||
|
||||
@ -17,50 +15,51 @@ describe('ImageTag', () => {
|
||||
|
||||
describe('constructor', () => {
|
||||
it('can be called', () => {
|
||||
const { platform } = some;
|
||||
expect(() => new ImageTag({ platform })).not.toThrow();
|
||||
const { targetPlatform } = some;
|
||||
|
||||
expect(() => new ImageTag({ targetPlatform })).not.toThrow();
|
||||
});
|
||||
|
||||
it('accepts parameters and sets the right properties', () => {
|
||||
const image = new ImageTag(some);
|
||||
|
||||
expect(image.repository).toStrictEqual(some.repository);
|
||||
expect(image.name).toStrictEqual(some.name);
|
||||
expect(image.version).toStrictEqual(some.version);
|
||||
expect(image.platform).toStrictEqual(some.platform);
|
||||
expect(image.repository).toStrictEqual('unityci');
|
||||
expect(image.name).toStrictEqual('editor');
|
||||
expect(image.editorVersion).toStrictEqual(some.editorVersion);
|
||||
expect(image.targetPlatform).toStrictEqual(some.targetPlatform);
|
||||
expect(image.builderPlatform).toStrictEqual(some.builderPlatform);
|
||||
});
|
||||
|
||||
test.each(['2000.0.0f0', '2011.1.11f1'])('accepts %p version format', (version) => {
|
||||
expect(() => new ImageTag({ version, platform: some.platform })).not.toThrow();
|
||||
expect(() => new ImageTag({ editorVersion: version, targetPlatform: some.targetPlatform })).not.toThrow();
|
||||
});
|
||||
|
||||
test.each(['some version', '', 1])('throws for incorrect versions %p', (version) => {
|
||||
const { platform } = some;
|
||||
expect(() => new ImageTag({ version, platform })).toThrow();
|
||||
test.each(['some version', ''])('throws for incorrect version %p', (editorVersion) => {
|
||||
const { targetPlatform } = some;
|
||||
expect(() => new ImageTag({ editorVersion, targetPlatform })).toThrow();
|
||||
});
|
||||
|
||||
test.each([undefined, 'nonExisting'])('throws for unsupported target %p', (platform) => {
|
||||
expect(() => new ImageTag({ platform })).toThrow();
|
||||
test.each([undefined, 'nonExisting'])('throws for unsupported target %p', (targetPlatform) => {
|
||||
expect(() => new ImageTag({ targetPlatform })).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
describe('toString', () => {
|
||||
it('returns the correct version', () => {
|
||||
const image = new ImageTag({ version: '2099.1.1111', platform: some.platform });
|
||||
const image = new ImageTag({ editorVersion: '2099.1.1111', targetPlatform: some.targetPlatform });
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111-0`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2099.1.1111-1`);
|
||||
break;
|
||||
case 'linux':
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2099.1.1111-0`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2099.1.1111-1`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
it('returns customImage if given', () => {
|
||||
const image = new ImageTag({
|
||||
version: '2099.1.1111',
|
||||
platform: some.platform,
|
||||
editorVersion: '2099.1.1111',
|
||||
targetPlatform: some.targetPlatform,
|
||||
customImage: `${defaults.image}:2099.1.1111@347598437689743986`,
|
||||
});
|
||||
|
||||
@ -68,27 +67,27 @@ describe('ImageTag', () => {
|
||||
});
|
||||
|
||||
it('returns the specific build platform', () => {
|
||||
const image = new ImageTag({ version: '2019.2.11f1', platform: 'WebGL' });
|
||||
const image = new ImageTag({ editorVersion: '2019.2.11f1', targetPlatform: 'WebGL' });
|
||||
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-webgl-0`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-webgl-1`);
|
||||
break;
|
||||
case 'linux':
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-webgl-0`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2019.2.11f1-webgl-1`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
it('returns no specific build platform for generic targetPlatforms', () => {
|
||||
const image = new ImageTag({ platform: 'NoTarget' });
|
||||
const image = new ImageTag({ targetPlatform: 'NoTarget' });
|
||||
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-0`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:windows-2019.2.11f1-1`);
|
||||
break;
|
||||
case 'linux':
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:2019.2.11f1-0`);
|
||||
expect(image.toString()).toStrictEqual(`${defaults.image}:ubuntu-2019.2.11f1-1`);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
@ -1,35 +1,42 @@
|
||||
import Platform from './platform';
|
||||
import BuildParameters from './build-parameters';
|
||||
|
||||
class ImageTag {
|
||||
public repository: string;
|
||||
public name: string;
|
||||
public version: string;
|
||||
public platform: any;
|
||||
public editorVersion: string;
|
||||
public targetPlatform: any;
|
||||
public builderPlatform: string;
|
||||
public customImage: any;
|
||||
public imageRollingVersion: number;
|
||||
public imagePlatformPrefix: string;
|
||||
|
||||
constructor(imageProperties) {
|
||||
const { repository = 'unityci', name = 'editor', version = '2019.2.11f1', platform, customImage } = imageProperties;
|
||||
constructor(imageProperties: Partial<BuildParameters>) {
|
||||
const { editorVersion = '2019.2.11f1', targetPlatform, customImage } = imageProperties;
|
||||
|
||||
if (!ImageTag.versionPattern.test(version)) {
|
||||
throw new Error(`Invalid version "${version}".`);
|
||||
if (!ImageTag.versionPattern.test(editorVersion)) {
|
||||
throw new Error(`Invalid version "${editorVersion}".`);
|
||||
}
|
||||
|
||||
const builderPlatform = ImageTag.getTargetPlatformToImageSuffixMap(platform, version);
|
||||
|
||||
this.repository = repository;
|
||||
this.name = name;
|
||||
this.version = version;
|
||||
this.platform = platform;
|
||||
this.builderPlatform = builderPlatform;
|
||||
// Todo we might as well skip this class for customImage.
|
||||
// Either
|
||||
this.customImage = customImage;
|
||||
|
||||
// Or
|
||||
this.repository = 'unityci';
|
||||
this.name = 'editor';
|
||||
this.editorVersion = editorVersion;
|
||||
this.targetPlatform = targetPlatform;
|
||||
this.builderPlatform = ImageTag.getTargetPlatformToTargetPlatformSuffixMap(targetPlatform, editorVersion);
|
||||
this.imagePlatformPrefix = ImageTag.getImagePlatformPrefixes(process.platform);
|
||||
this.imageRollingVersion = 1; // will automatically roll to the latest non-breaking version.
|
||||
}
|
||||
|
||||
static get versionPattern() {
|
||||
return /^20\d{2}\.\d\.\w{3,4}|3$/;
|
||||
}
|
||||
|
||||
static get imageSuffixes() {
|
||||
static get targetPlatformSuffixes() {
|
||||
return {
|
||||
generic: '',
|
||||
webgl: 'webgl',
|
||||
@ -46,9 +53,20 @@ class ImageTag {
|
||||
};
|
||||
}
|
||||
|
||||
static getTargetPlatformToImageSuffixMap(platform, version) {
|
||||
static getImagePlatformPrefixes(platform) {
|
||||
switch (platform) {
|
||||
case 'win32':
|
||||
return 'windows';
|
||||
case 'linux':
|
||||
return 'ubuntu';
|
||||
default:
|
||||
throw new Error('The Operating System of this runner is not yet supported.');
|
||||
}
|
||||
}
|
||||
|
||||
static getTargetPlatformToTargetPlatformSuffixMap(platform, version) {
|
||||
const { generic, webgl, mac, windows, windowsIl2cpp, wsaPlayer, linux, linuxIl2cpp, android, ios, tvos, facebook } =
|
||||
ImageTag.imageSuffixes;
|
||||
ImageTag.targetPlatformSuffixes;
|
||||
|
||||
const [major, minor] = version.split('.').map((digit) => Number(digit));
|
||||
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
|
||||
@ -120,15 +138,9 @@ class ImageTag {
|
||||
}
|
||||
|
||||
get tag() {
|
||||
//We check the host os so we know what type of the images we need to pull
|
||||
switch (process.platform) {
|
||||
case 'win32':
|
||||
return `windows-${this.version}-${this.builderPlatform}`.replace(/-+$/, '');
|
||||
case 'linux':
|
||||
return `${this.version}-${this.builderPlatform}`.replace(/-+$/, '');
|
||||
default:
|
||||
break;
|
||||
}
|
||||
const versionAndPlatform = `${this.editorVersion}-${this.builderPlatform}`.replace(/-+$/, '');
|
||||
|
||||
return `${this.imagePlatformPrefix}-${versionAndPlatform}-${this.imageRollingVersion}`;
|
||||
}
|
||||
|
||||
get image() {
|
||||
@ -138,11 +150,9 @@ class ImageTag {
|
||||
toString() {
|
||||
const { image, tag, customImage } = this;
|
||||
|
||||
if (customImage && customImage !== '') {
|
||||
return customImage;
|
||||
}
|
||||
if (customImage) return customImage;
|
||||
|
||||
return `${image}:${tag}-0`; // '0' here represents the docker repo version
|
||||
return `${image}:${tag}`; // '0' here represents the docker repo version
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@ const core = require('@actions/core');
|
||||
* Input variables specified in workflows using "with" prop.
|
||||
*
|
||||
* Note that input is always passed as a string, even booleans.
|
||||
*
|
||||
* Todo: rename to UserInput and remove anything that is not direct input from the user / ci workflow
|
||||
*/
|
||||
class Input {
|
||||
public static cliOptions;
|
||||
@ -19,6 +21,7 @@ class Input {
|
||||
static get cloudRunnerTests(): boolean {
|
||||
return Input.getInput(`cloudRunnerTests`) || Input.getInput(`CloudRunnerTests`) || false;
|
||||
}
|
||||
|
||||
private static getInput(query) {
|
||||
const coreInput = core.getInput(query);
|
||||
if (Input.githubInputEnabled && coreInput && coreInput !== '') {
|
||||
@ -33,19 +36,24 @@ class Input {
|
||||
? process.env[Input.ToEnvVarFormat(query)]
|
||||
: '';
|
||||
}
|
||||
|
||||
static get region(): string {
|
||||
return Input.getInput('region') || 'eu-west-2';
|
||||
}
|
||||
|
||||
static async githubRepo() {
|
||||
return (
|
||||
Input.getInput('GITHUB_REPOSITORY') ||
|
||||
Input.getInput('GITHUB_REPO') ||
|
||||
// todo - move this to some class specific for determining additional information
|
||||
(await GitRepoReader.GetRemote()) ||
|
||||
'game-ci/unity-builder'
|
||||
);
|
||||
}
|
||||
|
||||
static async branch() {
|
||||
if (await GitRepoReader.GetBranch()) {
|
||||
// todo - move this to some class specific for determining additional information
|
||||
return await GitRepoReader.GetBranch();
|
||||
} else if (Input.getInput(`GITHUB_REF`)) {
|
||||
return Input.getInput(`GITHUB_REF`).replace('refs/', '').replace(`head/`, '');
|
||||
@ -62,9 +70,11 @@ class Input {
|
||||
} else if (Input.getInput(`GitSHA`)) {
|
||||
return Input.getInput(`GitSHA`);
|
||||
} else if (GitRepoReader.GetSha()) {
|
||||
// todo - move this to some class specific for determining additional information
|
||||
return GitRepoReader.GetSha();
|
||||
}
|
||||
}
|
||||
|
||||
static get runNumber() {
|
||||
return Input.getInput('GITHUB_RUN_NUMBER') || '0';
|
||||
}
|
||||
@ -89,6 +99,7 @@ class Input {
|
||||
!fs.existsSync(path.join('ProjectSettings', 'ProjectVersion.txt'))
|
||||
? 'test-project'
|
||||
: '.';
|
||||
|
||||
return rawProjectPath.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
@ -197,6 +208,7 @@ class Input {
|
||||
}
|
||||
|
||||
static async githubToken() {
|
||||
// Todo - move GitHubCLI out of the simple input class. It is in fact not input from the user.
|
||||
return Input.getInput('githubToken') || (await GithubCliReader.GetGitHubAuthToken()) || '';
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ class SetupMac {
|
||||
static unityHubPath = `"/Applications/Unity Hub.app/Contents/MacOS/Unity Hub"`;
|
||||
|
||||
public static async setup(buildParameters: BuildParameters, actionFolder: string) {
|
||||
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.version}/Unity.app/Contents/MacOS/Unity`;
|
||||
const unityEditorPath = `/Applications/Unity/Hub/Editor/${buildParameters.editorVersion}/Unity.app/Contents/MacOS/Unity`;
|
||||
|
||||
// Only install unity if the editor doesn't already exist
|
||||
if (!fs.existsSync(unityEditorPath)) {
|
||||
@ -31,9 +31,9 @@ class SetupMac {
|
||||
}
|
||||
|
||||
private static async installUnity(buildParameters: BuildParameters, silent = false) {
|
||||
const unityChangeset = await getUnityChangeset(buildParameters.version);
|
||||
const unityChangeset = await getUnityChangeset(buildParameters.editorVersion);
|
||||
const command = `${this.unityHubPath} -- --headless install \
|
||||
--version ${buildParameters.version} \
|
||||
--version ${buildParameters.editorVersion} \
|
||||
--changeset ${unityChangeset.changeset} \
|
||||
--module mac-il2cpp \
|
||||
--childModules`;
|
||||
@ -50,10 +50,10 @@ class SetupMac {
|
||||
// Need to set environment variables from here because we execute
|
||||
// the scripts on the host for mac
|
||||
process.env.ACTION_FOLDER = actionFolder;
|
||||
process.env.UNITY_VERSION = buildParameters.version;
|
||||
process.env.UNITY_VERSION = buildParameters.editorVersion;
|
||||
process.env.UNITY_SERIAL = buildParameters.unitySerial;
|
||||
process.env.PROJECT_PATH = buildParameters.projectPath;
|
||||
process.env.BUILD_TARGET = buildParameters.platform;
|
||||
process.env.BUILD_TARGET = buildParameters.targetPlatform;
|
||||
process.env.BUILD_NAME = buildParameters.buildName;
|
||||
process.env.BUILD_PATH = buildParameters.buildPath;
|
||||
process.env.BUILD_FILE = buildParameters.buildFile;
|
||||
|
@ -4,26 +4,27 @@ import { BuildParameters } from '..';
|
||||
|
||||
class SetupWindows {
|
||||
public static async setup(buildParameters: BuildParameters) {
|
||||
await SetupWindows.setupWindowsRun(buildParameters.platform);
|
||||
const { targetPlatform } = buildParameters;
|
||||
|
||||
await SetupWindows.setupWindowsRun(targetPlatform);
|
||||
}
|
||||
|
||||
//Setup prerequisite files/folders for a windows-based docker run
|
||||
private static async setupWindowsRun(platform, silent = false) {
|
||||
private static async setupWindowsRun(targetPlatform, silent = false) {
|
||||
if (!fs.existsSync('c:/regkeys')) {
|
||||
fs.mkdirSync('c:/regkeys');
|
||||
}
|
||||
switch (platform) {
|
||||
switch (targetPlatform) {
|
||||
//These all need the Windows 10 SDK
|
||||
case 'StandaloneWindows':
|
||||
case 'StandaloneWindows64':
|
||||
case 'WSAPlayer':
|
||||
this.generateWinSDKRegKeys(silent);
|
||||
await this.generateWinSDKRegKeys(silent);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static async generateWinSDKRegKeys(silent = false) {
|
||||
// Export registry keys that point to the location of the windows 10 sdk
|
||||
// Export registry keys that point to the Windows 10 SDK
|
||||
const exportWinSDKRegKeysCommand =
|
||||
'reg export "HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0" c:/regkeys/winsdk.reg /y';
|
||||
await exec(exportWinSDKRegKeysCommand, undefined, { silent });
|
||||
|
@ -3,7 +3,7 @@ import { BuildParameters } from '..';
|
||||
|
||||
class ValidateWindows {
|
||||
public static validate(buildParameters: BuildParameters) {
|
||||
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.platform);
|
||||
ValidateWindows.validateWindowsPlatformRequirements(buildParameters.targetPlatform);
|
||||
if (!(process.env.UNITY_EMAIL && process.env.UNITY_PASSWORD)) {
|
||||
throw new Error(`Unity email and password must be set for Windows based builds to
|
||||
authenticate the license. Make sure to set them inside UNITY_EMAIL
|
||||
|
@ -116,7 +116,7 @@ describe('Versioning', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('descriptionRegex', () => {
|
||||
describe('descriptionRegex1', () => {
|
||||
it('is a valid regex', () => {
|
||||
expect(Versioning.descriptionRegex1).toBeInstanceOf(RegExp);
|
||||
});
|
||||
@ -137,19 +137,19 @@ describe('Versioning', () => {
|
||||
|
||||
test.each(['v0', 'v0.1', 'v0.1.2', 'v0.1-2', 'v0.1-2-g'])('does not like %s', (description) => {
|
||||
expect(Versioning.descriptionRegex1.test(description)).toBeFalsy();
|
||||
// Also never expect without the v to work for any of these cases.
|
||||
// Also, never expect without the v to work for any of these cases.
|
||||
expect(Versioning.descriptionRegex1.test(description?.slice(1))).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('determineVersion', () => {
|
||||
describe('determineBuildVersion', () => {
|
||||
test.each(['somethingRandom'])('throws for invalid strategy %s', async (strategy) => {
|
||||
await expect(Versioning.determineVersion(strategy, '')).rejects.toThrowErrorMatchingSnapshot();
|
||||
await expect(Versioning.determineBuildVersion(strategy, '')).rejects.toThrowErrorMatchingSnapshot();
|
||||
});
|
||||
|
||||
describe('opt out strategy', () => {
|
||||
it("returns 'none'", async () => {
|
||||
await expect(Versioning.determineVersion('None', 'v1.0')).resolves.toMatchInlineSnapshot(`"none"`);
|
||||
await expect(Versioning.determineBuildVersion('None', 'v1.0')).resolves.toMatchInlineSnapshot(`"none"`);
|
||||
});
|
||||
});
|
||||
|
||||
@ -157,7 +157,7 @@ describe('Versioning', () => {
|
||||
test.each(['v0.1', '1', 'CamelCase', 'dashed-version'])(
|
||||
'returns the inputVersion for %s',
|
||||
async (inputVersion) => {
|
||||
await expect(Versioning.determineVersion('Custom', inputVersion)).resolves.toStrictEqual(inputVersion);
|
||||
await expect(Versioning.determineBuildVersion('Custom', inputVersion)).resolves.toStrictEqual(inputVersion);
|
||||
},
|
||||
);
|
||||
});
|
||||
@ -166,7 +166,7 @@ describe('Versioning', () => {
|
||||
it('refers to generateSemanticVersion', async () => {
|
||||
const generateSemanticVersion = jest.spyOn(Versioning, 'generateSemanticVersion').mockResolvedValue('1.3.37');
|
||||
|
||||
await expect(Versioning.determineVersion('Semantic', '')).resolves.toStrictEqual('1.3.37');
|
||||
await expect(Versioning.determineBuildVersion('Semantic', '')).resolves.toStrictEqual('1.3.37');
|
||||
expect(generateSemanticVersion).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@ -175,7 +175,7 @@ describe('Versioning', () => {
|
||||
it('refers to generateTagVersion', async () => {
|
||||
const generateTagVersion = jest.spyOn(Versioning, 'generateTagVersion').mockResolvedValue('0.1');
|
||||
|
||||
await expect(Versioning.determineVersion('Tag', '')).resolves.toStrictEqual('0.1');
|
||||
await expect(Versioning.determineBuildVersion('Tag', '')).resolves.toStrictEqual('0.1');
|
||||
expect(generateTagVersion).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
@ -185,7 +185,7 @@ describe('Versioning', () => {
|
||||
const strategy = 'Test';
|
||||
// @ts-ignore
|
||||
jest.spyOn(Versioning, 'strategies', 'get').mockReturnValue({ [strategy]: strategy });
|
||||
await expect(Versioning.determineVersion(strategy, '')).rejects.toThrowError(NotImplementedException);
|
||||
await expect(Versioning.determineBuildVersion(strategy, '')).rejects.toThrowError(NotImplementedException);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -79,7 +79,7 @@ export default class Versioning {
|
||||
return /^v?([\d.]+-\w+\.\d+)-(\d+)-g(\w+)-?(\w+)*/g;
|
||||
}
|
||||
|
||||
static async determineVersion(strategy: string, inputVersion: string) {
|
||||
static async determineBuildVersion(strategy: string, inputVersion: string) {
|
||||
// Validate input
|
||||
if (!Object.hasOwnProperty.call(this.strategies, strategy)) {
|
||||
throw new ValidationError(`Versioning strategy should be one of ${Object.values(this.strategies).join(', ')}.`);
|
||||
|
Loading…
Reference in New Issue
Block a user