better named tests and log local-docker params

pull/461/head
Frostebite 2022-09-21 13:21:13 +01:00
parent 0636a44d61
commit 3377ebfda5
6 changed files with 32 additions and 27 deletions

25
dist/index.js vendored
View File

@ -3621,7 +3621,7 @@ class LocalDockerCloudRunner {
}),
];
// 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({ workspace, actionFolder }, this.buildParameters), false, commands, content, {
listeners: {
stdout: (data) => {
myOutput += data.toString();
@ -4715,7 +4715,7 @@ class TaskParameterSerializer {
]
.filter((x) => !TaskParameterSerializer.blocked.has(x.name))
.map((x) => {
x.name = __1.Input.ToEnvVarFormat(x.name);
x.name = TaskParameterSerializer.ToEnvVarFormat(x.name);
x.value = `${x.value}`;
if (buildParameters.cloudRunnerIntegrationTests) {
if (Number(x.name) === Number.NaN) {
@ -5110,12 +5110,12 @@ const image_environment_factory_1 = __importDefault(__nccwpck_require__(25145));
const fs_1 = __nccwpck_require__(57147);
const path_1 = __importDefault(__nccwpck_require__(71017));
class Docker {
static run(image, parameters, silent = false, overrideCommands = '', options = false) {
static run(image, parameters, silent = false, overrideCommands = '', additionalVariables = [], options = false) {
return __awaiter(this, void 0, void 0, function* () {
let runCommand = '';
switch (process.platform) {
case 'linux':
runCommand = this.getLinuxCommand(image, parameters, overrideCommands);
runCommand = this.getLinuxCommand(image, parameters, overrideCommands, additionalVariables);
break;
case 'win32':
runCommand = this.getWindowsCommand(image, parameters);
@ -5129,7 +5129,7 @@ class Docker {
}
});
}
static getLinuxCommand(image, parameters, overrideCommands = '') {
static getLinuxCommand(image, parameters, overrideCommands = '', additionalVariables = []) {
const { workspace, actionFolder, runnerTempPath, sshAgent, gitPrivateToken } = parameters;
const githubHome = path_1.default.join(runnerTempPath, '_github_home');
if (!fs_1.existsSync(githubHome))
@ -5140,7 +5140,7 @@ class Docker {
return `docker run \
--workdir /github/workspace \
--rm \
${image_environment_factory_1.default.getEnvVarString(parameters)} \
${image_environment_factory_1.default.getEnvVarString(parameters, additionalVariables)} \
--env UNITY_SERIAL \
--env GITHUB_WORKSPACE=/github/workspace \
${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \
@ -5241,8 +5241,8 @@ const test_license_reader_1 = __nccwpck_require__(13963);
class Parameter {
}
class ImageEnvironmentFactory {
static getEnvVarString(parameters) {
const environmentVariables = ImageEnvironmentFactory.getEnvironmentVariables(parameters);
static getEnvVarString(parameters, additionalVariables = []) {
const environmentVariables = ImageEnvironmentFactory.getEnvironmentVariables(parameters, additionalVariables);
let string = '';
for (const p of environmentVariables) {
if (p.value === '' || p.value === undefined) {
@ -5256,7 +5256,7 @@ class ImageEnvironmentFactory {
}
return string;
}
static getEnvironmentVariables(parameters) {
static getEnvironmentVariables(parameters, additionalVariables = []) {
const environmentVariables = [
{ name: 'UNITY_LICENSE', value: process.env.UNITY_LICENSE || test_license_reader_1.ReadLicense() },
{ name: 'UNITY_LICENSE_FILE', value: process.env.UNITY_LICENSE_FILE },
@ -5299,10 +5299,9 @@ class ImageEnvironmentFactory {
{ name: 'RUNNER_WORKSPACE', value: process.env.RUNNER_WORKSPACE },
];
if (parameters.cloudRunnerCluster === 'local-docker') {
for (const key of Object.keys(parameters)) {
const value = parameters[key];
if (environmentVariables.find((x) => value !== undefined && x !== undefined && x.name === key) === undefined) {
environmentVariables.push({ name: key, value });
for (const element of additionalVariables) {
if (environmentVariables.find((x) => x.name === element.name) === undefined) {
environmentVariables.push({ name: element.name, value: element.value });
}
}
}

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -75,7 +75,7 @@ class LocalDockerCloudRunner implements ProviderInterface {
];
// 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 }, false, commands, content, {
listeners: {
stdout: (data: Buffer) => {
myOutput += data.toString();

View File

@ -33,7 +33,7 @@ export class TaskParameterSerializer {
]
.filter((x) => !TaskParameterSerializer.blocked.has(x.name))
.map((x) => {
x.name = Input.ToEnvVarFormat(x.name);
x.name = TaskParameterSerializer.ToEnvVarFormat(x.name);
x.value = `${x.value}`;
if (buildParameters.cloudRunnerIntegrationTests) {
if (Number(x.name) === Number.NaN) {

View File

@ -4,11 +4,18 @@ import { existsSync, mkdirSync } from 'fs';
import path from 'path';
class Docker {
static async run(image, parameters, silent = false, overrideCommands = '', options: any = false) {
static async run(
image,
parameters,
silent = false,
overrideCommands = '',
additionalVariables: any[] = [],
options: any = false,
) {
let runCommand = '';
switch (process.platform) {
case 'linux':
runCommand = this.getLinuxCommand(image, parameters, overrideCommands);
runCommand = this.getLinuxCommand(image, parameters, overrideCommands, additionalVariables);
break;
case 'win32':
runCommand = this.getWindowsCommand(image, parameters);
@ -21,7 +28,7 @@ class Docker {
}
}
static getLinuxCommand(image, parameters, overrideCommands = ''): string {
static getLinuxCommand(image, parameters, overrideCommands = '', additionalVariables: any[] = []): string {
const { workspace, actionFolder, runnerTempPath, sshAgent, gitPrivateToken } = parameters;
const githubHome = path.join(runnerTempPath, '_github_home');
@ -32,7 +39,7 @@ class Docker {
return `docker run \
--workdir /github/workspace \
--rm \
${ImageEnvironmentFactory.getEnvVarString(parameters)} \
${ImageEnvironmentFactory.getEnvVarString(parameters, additionalVariables)} \
--env UNITY_SERIAL \
--env GITHUB_WORKSPACE=/github/workspace \
${gitPrivateToken ? `--env GIT_PRIVATE_TOKEN="${gitPrivateToken}"` : ''} \

View File

@ -7,8 +7,8 @@ class Parameter {
}
class ImageEnvironmentFactory {
public static getEnvVarString(parameters) {
const environmentVariables = ImageEnvironmentFactory.getEnvironmentVariables(parameters);
public static getEnvVarString(parameters, additionalVariables: any[] = []) {
const environmentVariables = ImageEnvironmentFactory.getEnvironmentVariables(parameters, additionalVariables);
let string = '';
for (const p of environmentVariables) {
if (p.value === '' || p.value === undefined) {
@ -24,7 +24,7 @@ class ImageEnvironmentFactory {
return string;
}
public static getEnvironmentVariables(parameters: BuildParameters) {
public static getEnvironmentVariables(parameters: BuildParameters, additionalVariables: any[] = []) {
const environmentVariables: Parameter[] = [
{ name: 'UNITY_LICENSE', value: process.env.UNITY_LICENSE || ReadLicense() },
{ name: 'UNITY_LICENSE_FILE', value: process.env.UNITY_LICENSE_FILE },
@ -67,10 +67,9 @@ class ImageEnvironmentFactory {
{ name: 'RUNNER_WORKSPACE', value: process.env.RUNNER_WORKSPACE },
];
if (parameters.cloudRunnerCluster === 'local-docker') {
for (const key of Object.keys(parameters)) {
const value = parameters[key];
if (environmentVariables.find((x) => value !== undefined && x !== undefined && x.name === key) === undefined) {
environmentVariables.push({ name: key, value });
for (const element of additionalVariables) {
if (environmentVariables.find((x) => x.name === element.name) === undefined) {
environmentVariables.push({ name: element.name, value: element.value });
}
}
}