Various fixes

pull/353/head
Frostebite 2022-04-04 22:44:44 +01:00
commit b969dbb14a
20 changed files with 292 additions and 249 deletions

223
dist/index.js vendored
View File

@ -245,8 +245,8 @@ class BuildParameters {
static create() {
return __awaiter(this, void 0, void 0, function* () {
const buildFile = this.parseBuildFile(input_1.default.buildName, input_1.default.targetPlatform, input_1.default.androidAppBundle);
const unityVersion = unity_versioning_1.default.determineUnityVersion(input_1.default.projectPath, input_1.default.unityVersion);
const buildVersion = yield versioning_1.default.determineVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion);
const editorVersion = unity_versioning_1.default.determineUnityVersion(input_1.default.projectPath, input_1.default.unityVersion);
const buildVersion = yield versioning_1.default.determineBuildVersion(input_1.default.versioningStrategy, input_1.default.specifiedVersion);
const androidVersionCode = android_versioning_1.default.determineVersionCode(buildVersion, input_1.default.androidVersionCode);
const androidSdkManagerParameters = android_versioning_1.default.determineSdkManagerParameters(input_1.default.androidTargetSdkVersion);
// Todo - Don't use process.env directly, that's what the input model class is for.
@ -269,11 +269,11 @@ class BuildParameters {
core.setSecret(unitySerial);
}
return {
version: unityVersion,
editorVersion,
customImage: input_1.default.customImage,
unitySerial,
runnerTempPath: process.env.RUNNER_TEMP,
platform: input_1.default.targetPlatform,
targetPlatform: input_1.default.targetPlatform,
projectPath: input_1.default.projectPath,
buildName: input_1.default.buildName,
buildPath: `${input_1.default.buildsPath}/${input_1.default.targetPlatform}`,
@ -501,6 +501,7 @@ const remote_client_logger_1 = __nccwpck_require__(28082);
const setup_cloud_runner_repository_1 = __nccwpck_require__(39656);
const SDK = __importStar(__nccwpck_require__(71786));
const caching_1 = __nccwpck_require__(38759);
const cloud_runner_query_override_1 = __importDefault(__nccwpck_require__(31011));
class CLI {
static InitCliMode() {
const program = new commander_ts_1.Command();
@ -514,6 +515,9 @@ class CLI {
.map((x) => `${x.key} (${x.description})`)
.join(` | `));
program.option('--populateOverride <populate>', 'should use override query to pull input false by default');
program.option('--cachePushFrom <cachePushFrom>', 'cache push from source folder');
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
program.option('--artifactName <artifactName>', 'caching artifact name');
program.parse(process.argv);
CLI.options = program.opts();
__1.Input.cliOptions = CLI.options;
@ -523,7 +527,7 @@ class CLI {
return __awaiter(this, void 0, void 0, function* () {
__1.Input.githubInputEnabled = false;
if (CLI.options['populate'] === `true`) {
yield __1.Input.PopulateQueryOverrideInput();
yield cloud_runner_query_override_1.default.PopulateQueryOverrideInput();
}
CLI.logInput();
const results = cli_decorator_1.GetCliFunctions(CLI.options.mode);
@ -2185,7 +2189,7 @@ class KubernetesJobSpecFactory {
},
{
name: 'BUILD_TARGET',
value: buildParameters.platform,
value: buildParameters.targetPlatform,
},
{
name: 'ANDROID_VERSION_CODE',
@ -2873,6 +2877,70 @@ class CloudRunnerNamespace {
exports["default"] = CloudRunnerNamespace;
/***/ }),
/***/ 31011:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const input_1 = __importDefault(__nccwpck_require__(91933));
const generic_input_reader_1 = __nccwpck_require__(2263);
const formatFunction = (value, arguments_) => {
for (const element of arguments_) {
value = value.replace(`{${element.key}}`, element.value);
}
return value;
};
class CloudRunnerQueryOverride {
static shouldUseOverride(query) {
if (input_1.default.readInputOverrideCommand() !== '') {
if (input_1.default.readInputFromOverrideList() !== '') {
const doesInclude = input_1.default.readInputFromOverrideList().split(',').includes(query) ||
input_1.default.readInputFromOverrideList().split(',').includes(input_1.default.ToEnvVarFormat(query));
return doesInclude ? true : false;
}
else {
return true;
}
}
}
static queryOverride(query) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.shouldUseOverride(query)) {
throw new Error(`Should not be trying to run override query on ${query}`);
}
return yield generic_input_reader_1.GenericInputReader.Run(formatFunction(input_1.default.readInputOverrideCommand(), [{ key: 0, value: query }]));
});
}
static PopulateQueryOverrideInput() {
return __awaiter(this, void 0, void 0, function* () {
const queries = input_1.default.readInputFromOverrideList().split(',');
input_1.default.queryOverrides = new Array();
for (const element of queries) {
if (CloudRunnerQueryOverride.shouldUseOverride(element)) {
input_1.default.queryOverrides[element] = yield CloudRunnerQueryOverride.queryOverride(element);
}
}
});
}
}
exports["default"] = CloudRunnerQueryOverride;
/***/ }),
/***/ 69862:
@ -2948,7 +3016,7 @@ class TaskParameterSerializer {
},
{
name: 'BUILD_TARGET',
value: __1.CloudRunner.buildParameters.platform,
value: __1.CloudRunner.buildParameters.targetPlatform,
},
...TaskParameterSerializer.serializeBuildParamsAndInput,
];
@ -3140,12 +3208,11 @@ class BuildAutomationWorkflow {
}
static get SetupCommands() {
return `export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
echo "cloning"
echo "cloning game ci"
mkdir -p ${cloud_runner_folders_1.CloudRunnerFolders.builderPathFull.replace(/\\/g, `/`)}
git clone -q -b ${cloud_runner_1.default.buildParameters.cloudRunnerBranch} ${cloud_runner_folders_1.CloudRunnerFolders.unityBuilderRepoUrl} "${cloud_runner_folders_1.CloudRunnerFolders.builderPathFull.replace(/\\/g, `/`)}"
${cloud_runner_1.default.buildParameters.cloudRunnerIntegrationTests ? '' : '#'} tree ${cloud_runner_folders_1.CloudRunnerFolders.builderPathFull.replace(/\\/g, `/`)}
chmod +x ${path_1.default.join(cloud_runner_folders_1.CloudRunnerFolders.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`)}
echo "caching"
echo "cloud runner remote cli"
node --version
node ${path_1.default.join(cloud_runner_folders_1.CloudRunnerFolders.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`)} -m remote-cli`;
}
@ -3451,10 +3518,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 },
@ -3507,23 +3574,27 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const platform_1 = __importDefault(__nccwpck_require__(9707));
class ImageTag {
constructor(imageProperties) {
const { repository = 'unityci', name = 'editor', version = '2019.2.11f1', platform, cloudRunnerBuilderPlatform, customImage, } = imageProperties;
if (!ImageTag.versionPattern.test(version)) {
throw new Error(`Invalid version "${version}".`);
const { editorVersion = '2019.2.11f1', targetPlatform, customImage, cloudRunnerBuilderPlatform } = imageProperties;
if (!ImageTag.versionPattern.test(editorVersion)) {
throw new Error(`Invalid version "${editorVersion}".`);
}
const builderPlatformSuffix = ImageTag.getTargetPlatformToImageSuffixMap(platform, version);
this.repository = repository;
this.name = name;
this.version = version;
this.platform = platform;
this.builderPlatformSuffix = builderPlatformSuffix;
this.cloudRunnerBuilderPlatform = cloudRunnerBuilderPlatform;
// 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.cloudRunnerBuilderPlatform = cloudRunnerBuilderPlatform;
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',
@ -3539,8 +3610,18 @@ class ImageTag {
facebook: 'facebook',
};
}
static getTargetPlatformToImageSuffixMap(platform, version) {
const { generic, webgl, mac, windows, windowsIl2cpp, wsaPlayer, linux, linuxIl2cpp, android, ios, tvos, facebook } = ImageTag.imageSuffixes;
static getImagePlatformPrefixes(platform) {
switch (platform) {
case 'win32':
return 'windows';
case 'linux':
return 'ubuntu';
default:
return '';
}
}
static getTargetPlatformToTargetPlatformSuffixMap(platform, version) {
const { generic, webgl, mac, windows, windowsIl2cpp, wsaPlayer, linux, linuxIl2cpp, android, ios, tvos, facebook } = ImageTag.targetPlatformSuffixes;
const [major, minor] = version.split('.').map((digit) => Number(digit));
// @see: https://docs.unity3d.com/ScriptReference/BuildTarget.html
switch (platform) {
@ -3610,26 +3691,17 @@ class ImageTag {
}
}
get tag() {
const tagPlatform = this.cloudRunnerBuilderPlatform ? this.cloudRunnerBuilderPlatform : process.platform;
//We check the host os so we know what type of the images we need to pull
switch (tagPlatform) {
case 'win32':
return `windows-${this.version}-${this.builderPlatformSuffix}`.replace(/-+$/, '');
case 'linux':
return `${this.version}-${this.builderPlatformSuffix}`.replace(/-+$/, '');
default:
break;
}
const versionAndPlatform = `${this.editorVersion}-${this.builderPlatform}`.replace(/-+$/, '');
return `${this.cloudRunnerBuilderPlatform ? this.cloudRunnerBuilderPlatform : this.imagePlatformPrefix}-${versionAndPlatform}-${this.imageRollingVersion}`;
}
get image() {
return `${this.repository}/${this.name}`.replace(/^\/+/, '');
}
toString() {
const { image, tag, customImage } = this;
if (customImage && 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
}
}
exports["default"] = ImageTag;
@ -3868,74 +3940,29 @@ exports.ReadLicense = ReadLicense;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const fs_1 = __importDefault(__nccwpck_require__(57147));
const path_1 = __importDefault(__nccwpck_require__(71017));
const generic_input_reader_1 = __nccwpck_require__(2263);
const platform_1 = __importDefault(__nccwpck_require__(9707));
const formatFunction = (value, arguments_) => {
for (const element of arguments_) {
value = value.replace(`{${element.key}}`, element.value);
}
return value;
};
const core = __nccwpck_require__(42186);
/**
* 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 {
// also enabled debug logging for cloud runner
static get cloudRunnerTests() {
return Input.getInput(`cloudRunnerTests`) || Input.getInput(`CloudRunnerTests`) || false;
}
static shouldUseOverride(query) {
if (Input.readInputOverrideCommand() !== '') {
if (Input.readInputFromOverrideList() !== '') {
const doesInclude = Input.readInputFromOverrideList().split(',').includes(query) ||
Input.readInputFromOverrideList().split(',').includes(Input.ToEnvVarFormat(query));
return doesInclude ? true : false;
}
else {
return true;
}
}
}
static get cliMode() {
return Input.cliOptions !== undefined && Input.cliOptions.mode !== undefined && Input.cliOptions.mode !== '';
}
static queryOverride(query) {
return __awaiter(this, void 0, void 0, function* () {
if (!this.shouldUseOverride(query)) {
throw new Error(`Should not be trying to run override query on ${query}`);
}
return yield generic_input_reader_1.GenericInputReader.Run(formatFunction(Input.readInputOverrideCommand(), [{ key: 0, value: query }]));
});
}
static PopulateQueryOverrideInput() {
return __awaiter(this, void 0, void 0, function* () {
const queries = Input.readInputFromOverrideList().split(',');
Input.queryOverrides = new Array();
for (const element of queries) {
if (Input.shouldUseOverride(element)) {
Input.queryOverrides[element] = yield Input.queryOverride(element);
}
}
});
}
static getInput(query) {
const coreInput = core.getInput(query);
if (Input.githubInputEnabled && coreInput && coreInput !== '') {
@ -4283,7 +4310,7 @@ const fs_1 = __importDefault(__nccwpck_require__(57147));
class SetupMac {
static setup(buildParameters, actionFolder) {
return __awaiter(this, void 0, void 0, function* () {
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_1.default.existsSync(unityEditorPath)) {
yield SetupMac.installUnityHub();
@ -4307,9 +4334,9 @@ class SetupMac {
}
static installUnity(buildParameters, silent = false) {
return __awaiter(this, void 0, void 0, function* () {
const unityChangeset = yield unity_changeset_1.getUnityChangeset(buildParameters.version);
const unityChangeset = yield unity_changeset_1.getUnityChangeset(buildParameters.editorVersion);
const command = `${this.unityHubPath} -- --headless install \
--version ${buildParameters.version} \
--version ${buildParameters.editorVersion} \
--changeset ${unityChangeset.changeset} \
--module mac-il2cpp \
--childModules`;
@ -4326,10 +4353,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;
@ -4377,28 +4404,28 @@ const fs_1 = __importDefault(__nccwpck_require__(57147));
class SetupWindows {
static setup(buildParameters) {
return __awaiter(this, void 0, void 0, function* () {
yield SetupWindows.setupWindowsRun(buildParameters.platform);
const { targetPlatform } = buildParameters;
yield SetupWindows.setupWindowsRun(targetPlatform);
});
}
//Setup prerequisite files/folders for a windows-based docker run
static setupWindowsRun(platform, silent = false) {
static setupWindowsRun(targetPlatform, silent = false) {
return __awaiter(this, void 0, void 0, function* () {
if (!fs_1.default.existsSync('c:/regkeys')) {
fs_1.default.mkdirSync('c:/regkeys');
}
switch (platform) {
switch (targetPlatform) {
//These all need the Windows 10 SDK
case 'StandaloneWindows':
case 'StandaloneWindows64':
case 'WSAPlayer':
this.generateWinSDKRegKeys(silent);
yield this.generateWinSDKRegKeys(silent);
break;
}
});
}
static generateWinSDKRegKeys(silent = false) {
return __awaiter(this, void 0, void 0, function* () {
// 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';
yield exec_1.exec(exportWinSDKRegKeysCommand, undefined, { silent });
});
@ -4421,7 +4448,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
const fs_1 = __importDefault(__nccwpck_require__(57147));
class ValidateWindows {
static validate(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
@ -4839,7 +4866,7 @@ class Versioning {
static get descriptionRegex3() {
return /^v?([\d.]+-\w+\.\d+)-(\d+)-g(\w+)-?(\w+)*/g;
}
static determineVersion(strategy, inputVersion) {
static determineBuildVersion(strategy, inputVersion) {
return __awaiter(this, void 0, void 0, function* () {
// Validate input
if (!Object.hasOwnProperty.call(this.strategies, strategy)) {

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -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,

View File

@ -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."`;

View File

@ -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 () => {

View File

@ -11,11 +11,11 @@ import { GitRepoReader } from './input-readers/git-repo';
import { GithubCliReader } from './input-readers/github-cli';
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;
@ -69,8 +69,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);
@ -94,12 +94,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}`,

View File

@ -8,6 +8,7 @@ import { RemoteClientLogger } from './remote-client/remote-client-services/remot
import { SetupCloudRunnerRepository } from './remote-client/setup-cloud-runner-repository';
import * as SDK from 'aws-sdk';
import { Caching } from './remote-client/remote-client-services/caching';
import CloudRunnerQueryOverride from '../cloud-runner/services/cloud-runner-query-override';
export class CLI {
private static options;
@ -27,6 +28,9 @@ export class CLI {
.join(` | `),
);
program.option('--populateOverride <populate>', 'should use override query to pull input false by default');
program.option('--cachePushFrom <cachePushFrom>', 'cache push from source folder');
program.option('--cachePushTo <cachePushTo>', 'cache push to caching folder');
program.option('--artifactName <artifactName>', 'caching artifact name');
program.parse(process.argv);
CLI.options = program.opts();
Input.cliOptions = CLI.options;
@ -36,7 +40,7 @@ export class CLI {
static async RunCli(): Promise<void> {
Input.githubInputEnabled = false;
if (CLI.options['populate'] === `true`) {
await Input.PopulateQueryOverrideInput();
await CloudRunnerQueryOverride.PopulateQueryOverrideInput();
}
CLI.logInput();
const results = GetCliFunctions(CLI.options.mode);

View File

@ -60,7 +60,7 @@ class KubernetesJobSpecFactory {
},
{
name: 'BUILD_TARGET',
value: buildParameters.platform,
value: buildParameters.targetPlatform,
},
{
name: 'ANDROID_VERSION_CODE',

View File

@ -0,0 +1,43 @@
import Input from '../../input';
import { GenericInputReader } from '../../input-readers/generic-input-reader';
const formatFunction = (value, arguments_) => {
for (const element of arguments_) {
value = value.replace(`{${element.key}}`, element.value);
}
return value;
};
class CloudRunnerQueryOverride {
private static shouldUseOverride(query) {
if (Input.readInputOverrideCommand() !== '') {
if (Input.readInputFromOverrideList() !== '') {
const doesInclude =
Input.readInputFromOverrideList().split(',').includes(query) ||
Input.readInputFromOverrideList().split(',').includes(Input.ToEnvVarFormat(query));
return doesInclude ? true : false;
} else {
return true;
}
}
}
private static async queryOverride(query) {
if (!this.shouldUseOverride(query)) {
throw new Error(`Should not be trying to run override query on ${query}`);
}
return await GenericInputReader.Run(formatFunction(Input.readInputOverrideCommand(), [{ key: 0, value: query }]));
}
public static async PopulateQueryOverrideInput() {
const queries = Input.readInputFromOverrideList().split(',');
Input.queryOverrides = new Array();
for (const element of queries) {
if (CloudRunnerQueryOverride.shouldUseOverride(element)) {
Input.queryOverrides[element] = await CloudRunnerQueryOverride.queryOverride(element);
}
}
}
}
export default CloudRunnerQueryOverride;

View File

@ -17,7 +17,7 @@ export class TaskParameterSerializer {
},
{
name: 'BUILD_TARGET',
value: CloudRunner.buildParameters.platform,
value: CloudRunner.buildParameters.targetPlatform,
},
...TaskParameterSerializer.serializeBuildParamsAndInput,
];

View File

@ -83,16 +83,13 @@ export class BuildAutomationWorkflow implements WorkflowInterface {
private static get SetupCommands() {
return `export GIT_DISCOVERY_ACROSS_FILESYSTEM=1
echo "cloning"
echo "cloning game ci"
mkdir -p ${CloudRunnerFolders.builderPathFull.replace(/\\/g, `/`)}
git clone -q -b ${CloudRunner.buildParameters.cloudRunnerBranch} ${
CloudRunnerFolders.unityBuilderRepoUrl
} "${CloudRunnerFolders.builderPathFull.replace(/\\/g, `/`)}"
${
CloudRunner.buildParameters.cloudRunnerIntegrationTests ? '' : '#'
} tree ${CloudRunnerFolders.builderPathFull.replace(/\\/g, `/`)}
chmod +x ${path.join(CloudRunnerFolders.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`)}
echo "caching"
echo "cloud runner remote cli"
node --version
node ${path.join(CloudRunnerFolders.builderPathFull, 'dist', `index.js`).replace(/\\/g, `/`)} -m remote-cli`;
}

View File

@ -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 },

View File

@ -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.builderPlatformSuffix).toStrictEqual(some.builderPlatform);
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;
}
});

View File

@ -1,44 +1,45 @@
import Platform from './platform';
import BuildParameters from './build-parameters';
class ImageTag {
public repository: string;
public name: string;
public version: string;
public platform: any;
public builderPlatformSuffix: string;
public cloudRunnerBuilderPlatform: string;
public cloudRunnerBuilderPlatform!: string | undefined;
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,
cloudRunnerBuilderPlatform,
customImage,
} = imageProperties;
constructor(imageProperties: Partial<BuildParameters>) {
const { editorVersion = '2019.2.11f1', targetPlatform, customImage, cloudRunnerBuilderPlatform } = imageProperties;
if (!ImageTag.versionPattern.test(version)) {
throw new Error(`Invalid version "${version}".`);
if (!ImageTag.versionPattern.test(editorVersion)) {
throw new Error(`Invalid version "${editorVersion}".`);
}
const builderPlatformSuffix = ImageTag.getTargetPlatformToImageSuffixMap(platform, version);
this.repository = repository;
this.name = name;
this.version = version;
this.platform = platform;
this.builderPlatformSuffix = builderPlatformSuffix;
this.cloudRunnerBuilderPlatform = cloudRunnerBuilderPlatform;
// 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.cloudRunnerBuilderPlatform = cloudRunnerBuilderPlatform;
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',
@ -55,9 +56,20 @@ class ImageTag {
};
}
static getTargetPlatformToImageSuffixMap(platform, version) {
static getImagePlatformPrefixes(platform) {
switch (platform) {
case 'win32':
return 'windows';
case 'linux':
return 'ubuntu';
default:
return '';
}
}
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
@ -129,16 +141,11 @@ class ImageTag {
}
get tag() {
const tagPlatform = this.cloudRunnerBuilderPlatform ? this.cloudRunnerBuilderPlatform : process.platform;
//We check the host os so we know what type of the images we need to pull
switch (tagPlatform) {
case 'win32':
return `windows-${this.version}-${this.builderPlatformSuffix}`.replace(/-+$/, '');
case 'linux':
return `${this.version}-${this.builderPlatformSuffix}`.replace(/-+$/, '');
default:
break;
}
const versionAndPlatform = `${this.editorVersion}-${this.builderPlatform}`.replace(/-+$/, '');
return `${
this.cloudRunnerBuilderPlatform ? this.cloudRunnerBuilderPlatform : this.imagePlatformPrefix
}-${versionAndPlatform}-${this.imageRollingVersion}`;
}
get image() {
@ -148,12 +155,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
}
}
export default ImageTag;

View File

@ -1,21 +1,15 @@
import fs from 'fs';
import path from 'path';
import { GenericInputReader } from './input-readers/generic-input-reader';
import Platform from './platform';
const formatFunction = (value, arguments_) => {
for (const element of arguments_) {
value = value.replace(`{${element.key}}`, element.value);
}
return value;
};
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;
@ -26,40 +20,11 @@ class Input {
static get cloudRunnerTests(): boolean {
return Input.getInput(`cloudRunnerTests`) || Input.getInput(`CloudRunnerTests`) || false;
}
private static shouldUseOverride(query) {
if (Input.readInputOverrideCommand() !== '') {
if (Input.readInputFromOverrideList() !== '') {
const doesInclude =
Input.readInputFromOverrideList().split(',').includes(query) ||
Input.readInputFromOverrideList().split(',').includes(Input.ToEnvVarFormat(query));
return doesInclude ? true : false;
} else {
return true;
}
}
}
static get cliMode() {
return Input.cliOptions !== undefined && Input.cliOptions.mode !== undefined && Input.cliOptions.mode !== '';
}
private static async queryOverride(query) {
if (!this.shouldUseOverride(query)) {
throw new Error(`Should not be trying to run override query on ${query}`);
}
return await GenericInputReader.Run(formatFunction(Input.readInputOverrideCommand(), [{ key: 0, value: query }]));
}
public static async PopulateQueryOverrideInput() {
const queries = Input.readInputFromOverrideList().split(',');
Input.queryOverrides = new Array();
for (const element of queries) {
if (Input.shouldUseOverride(element)) {
Input.queryOverrides[element] = await Input.queryOverride(element);
}
}
}
public static getInput(query) {
const coreInput = core.getInput(query);
if (Input.githubInputEnabled && coreInput && coreInput !== '') {
@ -84,6 +49,7 @@ class Input {
return '';
}
static get region(): string {
return Input.getInput('region') || 'eu-west-2';
}
@ -111,6 +77,7 @@ class Input {
return Input.getInput(`GitSHA`);
}
}
static get runNumber() {
return Input.getInput('GITHUB_RUN_NUMBER') || '0';
}
@ -135,6 +102,7 @@ class Input {
!fs.existsSync(path.join('ProjectSettings', 'ProjectVersion.txt'))
? 'test-project'
: '.';
return rawProjectPath.replace(/\/$/, '');
}

View File

@ -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;

View File

@ -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 });

View File

@ -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

View File

@ -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);
});
});
});

View File

@ -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(', ')}.`);