better named tests and log local-docker params

pull/461/head
Frostebite 2022-09-21 03:18:42 +01:00
parent 22d6a89d26
commit c78d403723
6 changed files with 42 additions and 33 deletions

55
dist/index.js vendored
View File

@ -4172,6 +4172,9 @@ class CloudRunnerCustomHooks {
} }
return output.filter((x) => x.step !== undefined && x.hook !== undefined && x.hook.length > 0); return output.filter((x) => x.step !== undefined && x.hook !== undefined && x.hook.length > 0);
} }
static getSecrets(hooks) {
return hooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0);
}
} }
exports.CloudRunnerCustomHooks = CloudRunnerCustomHooks; exports.CloudRunnerCustomHooks = CloudRunnerCustomHooks;
class Hook { class Hook {
@ -4656,6 +4659,25 @@ exports.LfsHashing = LfsHashing;
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) { var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod }; return (mod && mod.__esModule) ? mod : { "default": mod };
}; };
@ -4667,6 +4689,7 @@ const cloud_runner_query_override_1 = __importDefault(__nccwpck_require__(31011)
const cloud_runner_options_reader_1 = __importDefault(__nccwpck_require__(3343)); const cloud_runner_options_reader_1 = __importDefault(__nccwpck_require__(3343));
const build_parameters_1 = __importDefault(__nccwpck_require__(80787)); const build_parameters_1 = __importDefault(__nccwpck_require__(80787));
const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552)); const cloud_runner_options_1 = __importDefault(__nccwpck_require__(96552));
const core = __importStar(__nccwpck_require__(42186));
// import CloudRunner from '../cloud-runner'; // import CloudRunner from '../cloud-runner';
// import ImageEnvironmentFactory from '../../image-environment-factory'; // import ImageEnvironmentFactory from '../../image-environment-factory';
class TaskParameterSerializer { class TaskParameterSerializer {
@ -4688,23 +4711,27 @@ class TaskParameterSerializer {
]; ];
} }
static serializeBuildParamsAndInput(buildParameters) { static serializeBuildParamsAndInput(buildParameters) {
core.info(`Serializing ${JSON.stringify(buildParameters, undefined, 4)}`);
let array = [ let array = [
...TaskParameterSerializer.serializeFromObject(buildParameters), ...TaskParameterSerializer.serializeFromObject(buildParameters),
...TaskParameterSerializer.readInput(), ...TaskParameterSerializer.readInput(),
]; ];
const configurableHooks = cloud_runner_custom_hooks_1.CloudRunnerCustomHooks.getHooks(buildParameters.customJobHooks); core.info(`Array with object serialized build params and input ${JSON.stringify(array, undefined, 4)}`);
const secrets = configurableHooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0); const secrets = cloud_runner_custom_hooks_1.CloudRunnerCustomHooks.getSecrets(cloud_runner_custom_hooks_1.CloudRunnerCustomHooks.getHooks(buildParameters.customJobHooks));
if (secrets.length > 0) { if (secrets.length > 0) {
// eslint-disable-next-line unicorn/no-array-reduce // eslint-disable-next-line unicorn/no-array-reduce
array.push(secrets.reduce((x, y) => [...x, ...y])); array.push(secrets.reduce((x, y) => [...x, ...y]));
} }
core.info(`Array with secrets added ${JSON.stringify(array, undefined, 4)}`);
const blocked = new Set(['0', 'length', 'prototype', '', 'unityVersion']); const blocked = new Set(['0', 'length', 'prototype', '', 'unityVersion']);
array = array.filter((x) => !blocked.has(x.name)); array = array.filter((x) => !blocked.has(x.name));
core.info(`Array after blocking removed added ${JSON.stringify(array, undefined, 4)}`);
array = array.map((x) => { array = array.map((x) => {
x.name = __1.Input.ToEnvVarFormat(x.name); x.name = __1.Input.ToEnvVarFormat(x.name);
x.value = `${x.value}`; x.value = `${x.value}`;
return x; return x;
}); });
core.info(`Array after env var formatting ${JSON.stringify(array, undefined, 4)}`);
return array; return array;
} }
static readBuildParameterFromEnvironment() { static readBuildParameterFromEnvironment() {
@ -5210,33 +5237,13 @@ exports["default"] = GitHub;
/***/ }), /***/ }),
/***/ 25145: /***/ 25145:
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) { /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
"use strict"; "use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
const task_parameter_serializer_1 = __nccwpck_require__(35346); const task_parameter_serializer_1 = __nccwpck_require__(35346);
const test_license_reader_1 = __nccwpck_require__(13963); const test_license_reader_1 = __nccwpck_require__(13963);
const core = __importStar(__nccwpck_require__(42186));
class Parameter { class Parameter {
} }
class ImageEnvironmentFactory { class ImageEnvironmentFactory {
@ -5298,9 +5305,7 @@ class ImageEnvironmentFactory {
{ name: 'RUNNER_WORKSPACE', value: process.env.RUNNER_WORKSPACE }, { name: 'RUNNER_WORKSPACE', value: process.env.RUNNER_WORKSPACE },
]; ];
if (parameters.cloudRunnerCluster === 'local-docker') { if (parameters.cloudRunnerCluster === 'local-docker') {
core.info(JSON.stringify(parameters, undefined, 4));
const content = task_parameter_serializer_1.TaskParameterSerializer.readBuildEnvironmentVariables(parameters); const content = task_parameter_serializer_1.TaskParameterSerializer.readBuildEnvironmentVariables(parameters);
core.info(JSON.stringify(content, undefined, 4));
for (const element of content) { for (const element of content) {
if (environmentVariables.find((x) => x.name === element.name) === undefined) { if (environmentVariables.find((x) => x.name === element.name) === undefined) {
environmentVariables.push(element); environmentVariables.push(element);

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -32,6 +32,10 @@ export class CloudRunnerCustomHooks {
return output.filter((x) => x.step !== undefined && x.hook !== undefined && x.hook.length > 0); return output.filter((x) => x.step !== undefined && x.hook !== undefined && x.hook.length > 0);
} }
public static getSecrets(hooks) {
return hooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0);
}
} }
export class Hook { export class Hook {
public commands; public commands;

View File

@ -6,6 +6,7 @@ import CloudRunnerQueryOverride from './cloud-runner-query-override';
import CloudRunnerOptionsReader from './cloud-runner-options-reader'; import CloudRunnerOptionsReader from './cloud-runner-options-reader';
import BuildParameters from '../../build-parameters'; import BuildParameters from '../../build-parameters';
import CloudRunnerOptions from '../cloud-runner-options'; import CloudRunnerOptions from '../cloud-runner-options';
import * as core from '@actions/core';
// import CloudRunner from '../cloud-runner'; // import CloudRunner from '../cloud-runner';
// import ImageEnvironmentFactory from '../../image-environment-factory'; // import ImageEnvironmentFactory from '../../image-environment-factory';
@ -29,26 +30,30 @@ export class TaskParameterSerializer {
]; ];
} }
private static serializeBuildParamsAndInput(buildParameters: BuildParameters) { private static serializeBuildParamsAndInput(buildParameters: BuildParameters) {
core.info(`Serializing ${JSON.stringify(buildParameters, undefined, 4)}`);
let array = [ let array = [
...TaskParameterSerializer.serializeFromObject(buildParameters), ...TaskParameterSerializer.serializeFromObject(buildParameters),
...TaskParameterSerializer.readInput(), ...TaskParameterSerializer.readInput(),
]; ];
const configurableHooks = CloudRunnerCustomHooks.getHooks(buildParameters.customJobHooks); core.info(`Array with object serialized build params and input ${JSON.stringify(array, undefined, 4)}`);
const secrets = configurableHooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0); const secrets = CloudRunnerCustomHooks.getSecrets(CloudRunnerCustomHooks.getHooks(buildParameters.customJobHooks));
if (secrets.length > 0) { if (secrets.length > 0) {
// eslint-disable-next-line unicorn/no-array-reduce // eslint-disable-next-line unicorn/no-array-reduce
array.push(secrets.reduce((x, y) => [...x, ...y])); array.push(secrets.reduce((x, y) => [...x, ...y]));
} }
core.info(`Array with secrets added ${JSON.stringify(array, undefined, 4)}`);
const blocked = new Set(['0', 'length', 'prototype', '', 'unityVersion']); const blocked = new Set(['0', 'length', 'prototype', '', 'unityVersion']);
array = array.filter((x) => !blocked.has(x.name)); array = array.filter((x) => !blocked.has(x.name));
core.info(`Array after blocking removed added ${JSON.stringify(array, undefined, 4)}`);
array = array.map((x) => { array = array.map((x) => {
x.name = Input.ToEnvVarFormat(x.name); x.name = Input.ToEnvVarFormat(x.name);
x.value = `${x.value}`; x.value = `${x.value}`;
return x; return x;
}); });
core.info(`Array after env var formatting ${JSON.stringify(array, undefined, 4)}`);
return array; return array;
} }

View File

@ -4,7 +4,6 @@ import UnityVersioning from '../../unity-versioning';
import { Cli } from '../../cli/cli'; import { Cli } from '../../cli/cli';
import GitHub from '../../github'; import GitHub from '../../github';
import setups from './cloud-runner-suite.test'; import setups from './cloud-runner-suite.test';
import * as core from '@actions/core';
async function CreateParameters(overrides) { async function CreateParameters(overrides) {
if (overrides) { if (overrides) {
@ -40,7 +39,6 @@ describe('Cloud Runner Environment Serializer', () => {
}); });
const result = TaskParameterSerializer.readBuildEnvironmentVariables(buildParameter); const result = TaskParameterSerializer.readBuildEnvironmentVariables(buildParameter);
core.info(JSON.stringify(result, undefined, 4));
expect(result.find((x) => Number.parseInt(x.name)) !== undefined).toBeFalsy(); expect(result.find((x) => Number.parseInt(x.name)) !== undefined).toBeFalsy();
}); });
}); });

View File

@ -1,7 +1,6 @@
import BuildParameters from './build-parameters'; import BuildParameters from './build-parameters';
import { TaskParameterSerializer } from './cloud-runner/services/task-parameter-serializer'; import { TaskParameterSerializer } from './cloud-runner/services/task-parameter-serializer';
import { ReadLicense } from './input-readers/test-license-reader'; import { ReadLicense } from './input-readers/test-license-reader';
import * as core from '@actions/core';
class Parameter { class Parameter {
public name; public name;
@ -69,9 +68,7 @@ class ImageEnvironmentFactory {
{ name: 'RUNNER_WORKSPACE', value: process.env.RUNNER_WORKSPACE }, { name: 'RUNNER_WORKSPACE', value: process.env.RUNNER_WORKSPACE },
]; ];
if (parameters.cloudRunnerCluster === 'local-docker') { if (parameters.cloudRunnerCluster === 'local-docker') {
core.info(JSON.stringify(parameters, undefined, 4));
const content = TaskParameterSerializer.readBuildEnvironmentVariables(parameters); const content = TaskParameterSerializer.readBuildEnvironmentVariables(parameters);
core.info(JSON.stringify(content, undefined, 4));
for (const element of content) { for (const element of content) {
if (environmentVariables.find((x) => x.name === element.name) === undefined) { if (environmentVariables.find((x) => x.name === element.name) === undefined) {
environmentVariables.push(element); environmentVariables.push(element);