better named tests and log local-docker params
parent
0c1fd5133b
commit
22d6a89d26
|
|
@ -3555,25 +3555,6 @@ exports["default"] = KubernetesTaskRunner;
|
||||||
|
|
||||||
"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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
|
@ -3590,7 +3571,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
const cloud_runner_logger_1 = __importDefault(__nccwpck_require__(22855));
|
||||||
const docker_1 = __importDefault(__nccwpck_require__(16934));
|
const docker_1 = __importDefault(__nccwpck_require__(16934));
|
||||||
const model_1 = __nccwpck_require__(41359);
|
const model_1 = __nccwpck_require__(41359);
|
||||||
const core = __importStar(__nccwpck_require__(42186));
|
|
||||||
class LocalDockerCloudRunner {
|
class LocalDockerCloudRunner {
|
||||||
inspect() {
|
inspect() {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
|
|
@ -3640,7 +3620,7 @@ class LocalDockerCloudRunner {
|
||||||
return;
|
return;
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
core.info(JSON.stringify(Object.assign(Object.assign({ workspace, actionFolder }, this.buildParameters), content), undefined, 4));
|
// core.info(JSON.stringify({ workspace, actionFolder, ...this.buildParameters, ...content }, undefined, 4));
|
||||||
yield docker_1.default.run(image, Object.assign(Object.assign({ workspace, actionFolder }, this.buildParameters), content), false, commands, {
|
yield docker_1.default.run(image, Object.assign(Object.assign({ workspace, actionFolder }, this.buildParameters), content), false, commands, {
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
|
|
@ -4708,9 +4688,10 @@ class TaskParameterSerializer {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
static serializeBuildParamsAndInput(buildParameters) {
|
static serializeBuildParamsAndInput(buildParameters) {
|
||||||
let array = new Array();
|
let array = [
|
||||||
array = TaskParameterSerializer.readBuildParameters(array, buildParameters);
|
...TaskParameterSerializer.serializeFromObject(buildParameters),
|
||||||
array = TaskParameterSerializer.readInput(array);
|
...TaskParameterSerializer.readInput(),
|
||||||
|
];
|
||||||
const configurableHooks = cloud_runner_custom_hooks_1.CloudRunnerCustomHooks.getHooks(buildParameters.customJobHooks);
|
const configurableHooks = cloud_runner_custom_hooks_1.CloudRunnerCustomHooks.getHooks(buildParameters.customJobHooks);
|
||||||
const secrets = configurableHooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0);
|
const secrets = configurableHooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0);
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
|
|
@ -4735,13 +4716,17 @@ class TaskParameterSerializer {
|
||||||
}
|
}
|
||||||
return buildParameters;
|
return buildParameters;
|
||||||
}
|
}
|
||||||
|
static readInput() {
|
||||||
|
return TaskParameterSerializer.serializeFromType(__1.Input);
|
||||||
|
}
|
||||||
static ToEnvVarFormat(input) {
|
static ToEnvVarFormat(input) {
|
||||||
return cloud_runner_options_1.default.ToEnvVarFormat(input);
|
return cloud_runner_options_1.default.ToEnvVarFormat(input);
|
||||||
}
|
}
|
||||||
static UndoEnvVarFormat(element, buildParameters) {
|
static UndoEnvVarFormat(element, buildParameters) {
|
||||||
return (Object.keys(buildParameters).find((x) => `GAMECI-${TaskParameterSerializer.ToEnvVarFormat(x)}` === element) || '');
|
return (Object.keys(buildParameters).find((x) => `GAMECI-${TaskParameterSerializer.ToEnvVarFormat(x)}` === element) || '');
|
||||||
}
|
}
|
||||||
static readBuildParameters(array, buildParameters) {
|
static serializeFromObject(buildParameters) {
|
||||||
|
const array = [];
|
||||||
const keys = Object.keys(buildParameters);
|
const keys = Object.keys(buildParameters);
|
||||||
for (const element of keys) {
|
for (const element of keys) {
|
||||||
array.push({
|
array.push({
|
||||||
|
|
@ -4754,13 +4739,14 @@ class TaskParameterSerializer {
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
static readInput(array) {
|
static serializeFromType(type) {
|
||||||
|
const array = [];
|
||||||
const input = cloud_runner_options_reader_1.default.GetProperties();
|
const input = cloud_runner_options_reader_1.default.GetProperties();
|
||||||
for (const element of input) {
|
for (const element of input) {
|
||||||
if (typeof __1.Input[element] !== 'function' && array.filter((x) => x.name === element).length === 0) {
|
if (typeof type[element] !== 'function' && array.filter((x) => x.name === element).length === 0) {
|
||||||
array.push({
|
array.push({
|
||||||
name: element,
|
name: element,
|
||||||
value: `${__1.Input[element]}`,
|
value: `${type[element]}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,6 @@ import { ProviderInterface } from '../provider-interface';
|
||||||
import CloudRunnerSecret from '../../services/cloud-runner-secret';
|
import CloudRunnerSecret from '../../services/cloud-runner-secret';
|
||||||
import Docker from '../../../docker';
|
import Docker from '../../../docker';
|
||||||
import { Action } from '../../../../model';
|
import { Action } from '../../../../model';
|
||||||
import * as core from '@actions/core';
|
|
||||||
|
|
||||||
class LocalDockerCloudRunner implements ProviderInterface {
|
class LocalDockerCloudRunner implements ProviderInterface {
|
||||||
public buildParameters: BuildParameters | undefined;
|
public buildParameters: BuildParameters | undefined;
|
||||||
|
|
@ -74,7 +73,8 @@ class LocalDockerCloudRunner implements ProviderInterface {
|
||||||
return;
|
return;
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
core.info(JSON.stringify({ workspace, actionFolder, ...this.buildParameters, ...content }, undefined, 4));
|
|
||||||
|
// core.info(JSON.stringify({ workspace, actionFolder, ...this.buildParameters, ...content }, undefined, 4));
|
||||||
await Docker.run(image, { workspace, actionFolder, ...this.buildParameters, ...content }, false, commands, {
|
await Docker.run(image, { workspace, actionFolder, ...this.buildParameters, ...content }, false, commands, {
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data: Buffer) => {
|
stdout: (data: Buffer) => {
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,10 @@ export class TaskParameterSerializer {
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
private static serializeBuildParamsAndInput(buildParameters: BuildParameters) {
|
private static serializeBuildParamsAndInput(buildParameters: BuildParameters) {
|
||||||
let array = new Array();
|
let array = [
|
||||||
array = TaskParameterSerializer.readBuildParameters(array, buildParameters);
|
...TaskParameterSerializer.serializeFromObject(buildParameters),
|
||||||
array = TaskParameterSerializer.readInput(array);
|
...TaskParameterSerializer.readInput(),
|
||||||
|
];
|
||||||
const configurableHooks = CloudRunnerCustomHooks.getHooks(buildParameters.customJobHooks);
|
const configurableHooks = CloudRunnerCustomHooks.getHooks(buildParameters.customJobHooks);
|
||||||
const secrets = configurableHooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0);
|
const secrets = configurableHooks.map((x) => x.secrets).filter((x) => x !== undefined && x.length > 0);
|
||||||
if (secrets.length > 0) {
|
if (secrets.length > 0) {
|
||||||
|
|
@ -65,6 +66,10 @@ export class TaskParameterSerializer {
|
||||||
return buildParameters;
|
return buildParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readInput() {
|
||||||
|
return TaskParameterSerializer.serializeFromType(Input);
|
||||||
|
}
|
||||||
|
|
||||||
public static ToEnvVarFormat(input): string {
|
public static ToEnvVarFormat(input): string {
|
||||||
return CloudRunnerOptions.ToEnvVarFormat(input);
|
return CloudRunnerOptions.ToEnvVarFormat(input);
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +80,8 @@ export class TaskParameterSerializer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readBuildParameters(array: any[], buildParameters: BuildParameters) {
|
private static serializeFromObject(buildParameters) {
|
||||||
|
const array: any[] = [];
|
||||||
const keys = Object.keys(buildParameters);
|
const keys = Object.keys(buildParameters);
|
||||||
for (const element of keys) {
|
for (const element of keys) {
|
||||||
array.push(
|
array.push(
|
||||||
|
|
@ -93,13 +99,14 @@ export class TaskParameterSerializer {
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readInput(array: any[]) {
|
private static serializeFromType(type) {
|
||||||
|
const array: any[] = [];
|
||||||
const input = CloudRunnerOptionsReader.GetProperties();
|
const input = CloudRunnerOptionsReader.GetProperties();
|
||||||
for (const element of input) {
|
for (const element of input) {
|
||||||
if (typeof Input[element] !== 'function' && array.filter((x) => x.name === element).length === 0) {
|
if (typeof type[element] !== 'function' && array.filter((x) => x.name === element).length === 0) {
|
||||||
array.push({
|
array.push({
|
||||||
name: element,
|
name: element,
|
||||||
value: `${Input[element]}`,
|
value: `${type[element]}`,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ describe('Cloud Runner Environment Serializer', () => {
|
||||||
setups();
|
setups();
|
||||||
const testSecretName = 'testSecretName';
|
const testSecretName = 'testSecretName';
|
||||||
const testSecretValue = 'testSecretValue';
|
const testSecretValue = 'testSecretValue';
|
||||||
it('Task parameters serialize correctly', async () => {
|
it('Cloud Runner Parameter Serialization', async () => {
|
||||||
// Setup parameters
|
// Setup parameters
|
||||||
const buildParameter = await CreateParameters({
|
const buildParameter = await CreateParameters({
|
||||||
versioning: 'None',
|
versioning: 'None',
|
||||||
|
|
@ -39,8 +39,8 @@ describe('Cloud Runner Environment Serializer', () => {
|
||||||
`,
|
`,
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = TaskParameterSerializer.readBuildParameters([], buildParameter);
|
const result = TaskParameterSerializer.readBuildEnvironmentVariables(buildParameter);
|
||||||
core.info(JSON.stringify(result, undefined, 4));
|
core.info(JSON.stringify(result, undefined, 4));
|
||||||
expect(result.find((x) => Number.parseInt(x)) !== undefined).toBeFalsy();
|
expect(result.find((x) => Number.parseInt(x.name)) !== undefined).toBeFalsy();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue