From a0b4be23a9a7a1fde2dfa78e46afe8deeddac715 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Tue, 22 Dec 2020 15:16:04 +0100 Subject: [PATCH 01/27] initial dockerCompose --- runners/console/index.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/runners/console/index.ts b/runners/console/index.ts index 04feb102..c2bd155a 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -143,6 +143,19 @@ export class Console extends Runner { return result; } + runDockerCompose(step: Step, command: Command): RunResult { + let result = new RunResult(); + result.returnCode = 0; + + let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); + let filepath = path.join(workspaceDir, command.parameters[0]); + if (fs.existsSync(path.join(filepath, "Dockerfile"))) { + this.executeCommandSync("docker-compose up", filepath, result); + } + return result; + + } + async assertInstallDevonfwIde(step: Step, command: Command, result: RunResult) { let installedTools = command.parameters[0]; @@ -222,6 +235,12 @@ export class Console extends Runner { .fileContains(filepath, content); } + assertDockerCompose(step: Step, command: Command, result: RunResult) { + new Assertions() + .noErrorCode(result) + .noException(result); + } + private executeCommandSync(command: string, directory: string, result: RunResult, input?: string) { if(result.returnCode != 0) return; From 769bf9f2c1a02a2c1dfda4670cf88a1230385b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 20 Jan 2021 17:51:43 +0100 Subject: [PATCH 02/27] Added dokumentation and dockercompose async execution for observable result --- documentation/Functions.md | 14 ++++++++++++ runners/console/index.ts | 47 +++++++++++++++++++++++++++++++++++--- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index 6dd9e9dc..68e9edc3 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -11,6 +11,7 @@ The following functions are already implemented: * cloneRepository * runServerJava * npmInstall +* dockerCompose *** @@ -147,3 +148,16 @@ path: The URL path on which is checked if the server is running npmInstall("my-thai-star/angular") *** + +### dockerCompose +#### parameter +1. Path to the directory where the docker-compose.yml file is located, relative to workspace. +2. Assertion information. Only needed for the console runner to check if the server was started properly. +#### example +dockerCompose("my-thai-star", { "startupTime": 600, "port": 8081 }) + +##### Assertion information +startupTime = Time in seconds to wait before checking if the server is running +port: Port on which the server is running + +*** \ No newline at end of file diff --git a/runners/console/index.ts b/runners/console/index.ts index bb146f0f..6b64f074 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -9,6 +9,7 @@ import * as path from 'path'; import * as child_process from "child_process"; import * as fs from "fs"; import * as psList from "ps-list"; +import * as yaml from "yaml"; const findProcess = require("find-process"); const os = require("os"); @@ -182,9 +183,15 @@ export class Console extends Runner { let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); let filepath = path.join(workspaceDir, command.parameters[0]); - if (fs.existsSync(path.join(filepath, "Dockerfile"))) { - this.executeCommandSync("docker-compose up", filepath, result); + let processV = child_process.spawnSync("docker-compose --version", { shell: true, cwd: filepath, maxBuffer: Infinity }); + if(processV.status != 0) { + throw new Error("Error checking version of docker-compose: docker-compose is not installed") } + let process = this.executeDevonCommandAsync("docker-compose up", filepath, result); + if(process.pid && command.parameters.length == 2) { + this.asyncProcesses.push({ pid: process.pid, name: "dockerCompose", port: command.parameters[1].port }); + } + return result; } @@ -310,9 +317,28 @@ export class Console extends Runner { async assertDockerCompose(step: Step, command: Command, result: RunResult) { - new Assertions() + let assert = new Assertions() .noErrorCode(result) .noException(result); + + if(command.parameters.length > 1) { + if(!command.parameters[1].startupTime) { + console.warn("No startup time for command dockerCompose has been set") + } + let startupTimeInSeconds = command.parameters[1].startupTime ? command.parameters[1].startupTime : 0; + await this.sleep(command.parameters[1].startupTime); + + if(!command.parameters[1].port) { + this.killAsyncProcesses(); + throw new Error("Missing arguments for command dockerCompose. You have to specify a port and a path for the server. For further information read the function documentation."); + } else { + let isReachable = await assert.serverIsReachable(command.parameters[1].port, ""); + if(!isReachable) { + this.killAsyncProcesses(); + throw new Error("The server has not become reachable in " + startupTimeInSeconds + " seconds: " + "http://localhost:" + command.parameters[1].port) + } + } + } } async assertRunServerJava(step: Step, command: Command, result: RunResult) { @@ -434,5 +460,20 @@ export class Console extends Runner { }) } } + + private lookup(obj, lookupkey) { + for(var key in obj) { + + if(key == lookupkey) { + return [lookupkey, obj[key]]; + } + if(obj[key] instanceof Object) { + var y = this.lookup(obj[key], lookupkey); + if (y && y[0] == lookupkey) return y; + } + } + return null; + } + } \ No newline at end of file From ccb3ed85da36fc94b1b0ab79507fdf0c093ff2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 20 Jan 2021 17:56:19 +0100 Subject: [PATCH 03/27] Removed unused import --- runners/console/index.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 6b64f074..8c8f80e5 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -9,7 +9,6 @@ import * as path from 'path'; import * as child_process from "child_process"; import * as fs from "fs"; import * as psList from "ps-list"; -import * as yaml from "yaml"; const findProcess = require("find-process"); const os = require("os"); From 259dfc9b93c60dac2a3ac7c4a153aaf961dd94e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 22 Jan 2021 09:35:55 +0100 Subject: [PATCH 04/27] Added logging for execution of docker-compose --- runners/console/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/runners/console/index.ts b/runners/console/index.ts index 8c8f80e5..4fa0625e 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -187,6 +187,7 @@ export class Console extends Runner { throw new Error("Error checking version of docker-compose: docker-compose is not installed") } let process = this.executeDevonCommandAsync("docker-compose up", filepath, result); + console.log(process.stdout); if(process.pid && command.parameters.length == 2) { this.asyncProcesses.push({ pid: process.pid, name: "dockerCompose", port: command.parameters[1].port }); } From d18d2fcdc6d0c1af4b891803986b0273d3043b2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 22 Jan 2021 11:13:28 +0100 Subject: [PATCH 05/27] Fixed logging --- runners/console/index.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 4fa0625e..a80628ed 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -182,12 +182,16 @@ export class Console extends Runner { let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); let filepath = path.join(workspaceDir, command.parameters[0]); - let processV = child_process.spawnSync("docker-compose --version", { shell: true, cwd: filepath, maxBuffer: Infinity }); - if(processV.status != 0) { - throw new Error("Error checking version of docker-compose: docker-compose is not installed") - } - let process = this.executeDevonCommandAsync("docker-compose up", filepath, result); - console.log(process.stdout); + //let processV = this.executeCommandSync + let process = this.executeCommandAsync("docker-compose up --build", filepath, result); + process.stderr.setEncoding('utf-8'); + process.stderr.on('data', (data) => { + console.log(data); + }); + process.stdout.setEncoding('utf8'); + process.stdout.on('data', (data) => { + console.log(data); + }); if(process.pid && command.parameters.length == 2) { this.asyncProcesses.push({ pid: process.pid, name: "dockerCompose", port: command.parameters[1].port }); } From 0bbc0cd95d51c75996e89f5b01747e5836b88580 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 22 Jan 2021 13:01:47 +0100 Subject: [PATCH 06/27] small changes --- runners/console/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index a80628ed..4220415c 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -183,10 +183,10 @@ export class Console extends Runner { let workspaceDir = path.join(this.getWorkingDirectory(), "devonfw", "workspaces", "main"); let filepath = path.join(workspaceDir, command.parameters[0]); //let processV = this.executeCommandSync - let process = this.executeCommandAsync("docker-compose up --build", filepath, result); + let process = this.executeCommandAsync("docker-compose up", filepath, result); process.stderr.setEncoding('utf-8'); process.stderr.on('data', (data) => { - console.log(data); + console.log("stderr: " + data); }); process.stdout.setEncoding('utf8'); process.stdout.on('data', (data) => { From af7142631945091bc00c4964fda04b1379dea3f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 29 Jan 2021 13:47:48 +0100 Subject: [PATCH 07/27] Added switch to linux engine if on windows --- runners/console/index.ts | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 840671c9..962cf77d 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -9,6 +9,7 @@ import * as path from 'path'; import * as child_process from "child_process"; import * as fs from "fs"; import * as psList from "ps-list"; +import { info } from "console"; const findProcess = require("find-process"); const os = require("os"); @@ -205,9 +206,12 @@ export class Console extends Runner { let result = new RunResult(); result.returnCode = 0; - let workspaceDir = this.getVariable(this.workspaceDirectory); - let filepath = path.join(workspaceDir, command.parameters[0]); - + let filepath = path.join(this.getVariable(this.workspaceDirectory), command.parameters[0]); + + if(this.platform == ConsolePlatform.WINDOWS) { + child_process.execFileSync("./DockerCli.exe", ["-SwitchLinuxEngine"], {cwd : "C:/Program Files/Docker/Docker"}); + this.executeCommandSync("sleep 60", filepath, result); + } let process = this.executeCommandAsync("docker-compose up", filepath, result); process.stderr.setEncoding('utf-8'); process.stderr.on('data', (data) => { @@ -217,12 +221,17 @@ export class Console extends Runner { process.stdout.on('data', (data) => { console.log(data); }); - if(process.pid && command.parameters.length == 2) { + if(process.pid && command.parameters.length == 3) { this.asyncProcesses.push({ pid: process.pid, name: "dockerCompose", port: command.parameters[1].port }); } return result; - } + + } + + private dockerCompose(filepath: String, result: RunResult) { + + } runRunServerJava(step: Step, command: Command): RunResult { let result = new RunResult(); @@ -552,6 +561,18 @@ export class Console extends Runner { } } + private lookup(obj, lookupkey) { + for(var key in obj) { + if(key == lookupkey) { + return [lookupkey, obj[key]]; + } + if(obj[key] instanceof Object) { + var y = this.lookup(obj[key], lookupkey); + if (y && y[0] == lookupkey) return y; + } + } + return null; + } } \ No newline at end of file From da82b6ff14c69f8f3073e16fe91b6aaa77f5f6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 5 Feb 2021 10:22:30 +0100 Subject: [PATCH 08/27] In assertion catch any error --- runners/console/index.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 962cf77d..c302499b 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -208,10 +208,6 @@ export class Console extends Runner { let filepath = path.join(this.getVariable(this.workspaceDirectory), command.parameters[0]); - if(this.platform == ConsolePlatform.WINDOWS) { - child_process.execFileSync("./DockerCli.exe", ["-SwitchLinuxEngine"], {cwd : "C:/Program Files/Docker/Docker"}); - this.executeCommandSync("sleep 60", filepath, result); - } let process = this.executeCommandAsync("docker-compose up", filepath, result); process.stderr.setEncoding('utf-8'); process.stderr.on('data', (data) => { @@ -221,17 +217,13 @@ export class Console extends Runner { process.stdout.on('data', (data) => { console.log(data); }); - if(process.pid && command.parameters.length == 3) { + if(process.pid && command.parameters.length == 2) { this.asyncProcesses.push({ pid: process.pid, name: "dockerCompose", port: command.parameters[1].port }); } return result; } - - private dockerCompose(filepath: String, result: RunResult) { - - } runRunServerJava(step: Step, command: Command): RunResult { let result = new RunResult(); @@ -423,7 +415,8 @@ export class Console extends Runner { } } catch(error) { this.cleanUp(); - throw error; + console.log(error); + console.log("docker-compose failed, this could be due to a wrong container engine.") } } From 44e8a4ef28a4d2a7a14727a73d375995e20ed4cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 10 Feb 2021 11:56:22 +0100 Subject: [PATCH 09/27] Added skip function --- engine/engine.ts | 13 ++++++++++++- engine/runner.ts | 14 ++++++++++++++ runners/console/index.ts | 26 ++++++++++---------------- 3 files changed, 36 insertions(+), 17 deletions(-) diff --git a/engine/engine.ts b/engine/engine.ts index 674b1fe6..26eb0448 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -23,9 +23,15 @@ export class Engine { for (let runnerIndex in this.environment.runners) { (await this.getRunner(this.environment.runners[runnerIndex])).init(this.playbook); } - + let stop = false; for (let stepIndex in this.playbook.steps) { + if(stop) { + break; + } for (let lineIndex in this.playbook.steps[stepIndex].lines) { + if(stop) { + break; + } for (let runnerIndex in this.environment.runners) { let runner = await this.getRunner(this.environment.runners[runnerIndex]); if (runner.supports(this.playbook.steps[stepIndex].lines[lineIndex].name)) { @@ -35,6 +41,11 @@ export class Engine { } catch (e) { result.exceptions.push(e); + if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex])) { + console.log("Should stop") + stop = true; + break; + } } await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); break; diff --git a/engine/runner.ts b/engine/runner.ts index c88db5e7..23cf434c 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -13,6 +13,7 @@ export abstract class Runner { public playbookTitle: string; protected readonly useDevonCommand: string = "useDevonCommand"; protected readonly workspaceDirectory: string = "workspaceDirectory"; + protected readonly skippableCommands: string = "skippableCommands"; private setVariableCallback: (name: string, value: any) => any; registerSetVariableCallback(callback: (name: string, value: any) => any) { @@ -84,6 +85,7 @@ export abstract class Runner { init(playbook: Playbook): void { this.setVariable(this.useDevonCommand, false); + this.setVariable(this.skippableCommands, new Array()); } run(step: Step, command: Command): RunResult { @@ -110,4 +112,16 @@ export abstract class Runner { fs.mkdirSync(path, { recursive: true }); return path; } + + commandIsSkippable(command: Command): Boolean { + let returnVal = false; + for (let skippableCommand in this.getVariable(this.skippableCommands)){ + console.log("skippable command: " + skippableCommand + ", command in question: " + command.name); + if (skippableCommand == command.name) { + returnVal = true; + break; + } + } + return returnVal; + } } \ No newline at end of file diff --git a/runners/console/index.ts b/runners/console/index.ts index c99287d2..4b201557 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -36,6 +36,7 @@ export class Console extends Runner { fs.renameSync(path.join(homedir, ".devon"), path.join(homedir, ".devon_backup")) } this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory())); + this.setVariable(this.skippableCommands, new Array()); this.env = process.env; } @@ -212,7 +213,7 @@ export class Console extends Runner { runDockerCompose(step: Step, command: Command): RunResult { let result = new RunResult(); result.returnCode = 0; - + this.addToSkippableCommands(command); let filepath = path.join(this.getVariable(this.workspaceDirectory), command.parameters[0]); let process = this.executeCommandAsync("docker-compose up", filepath, result); @@ -468,8 +469,7 @@ export class Console extends Runner { } } catch(error) { this.cleanUp(); - console.log(error); - console.log("docker-compose failed, this could be due to a wrong container engine.") + throw error; } } @@ -693,20 +693,14 @@ export class Console extends Runner { }) } } - - private lookup(obj, lookupkey) { - for(var key in obj) { - - if(key == lookupkey) { - return [lookupkey, obj[key]]; - } - if(obj[key] instanceof Object) { - var y = this.lookup(obj[key], lookupkey); - if (y && y[0] == lookupkey) return y; - } + addToSkippableCommands(command: Command) { + console.log("Add " + command.name + "to skippableCommands"); + try { + this.setVariable(this.skippableCommands, this.getVariable(this.skippableCommands).push(command.name)); + } catch(e) { + console.log(e); } - return null; } -} \ No newline at end of file +} From f20ccb2046bf07a87091a67873bda06a782ba023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 10 Feb 2021 12:15:59 +0100 Subject: [PATCH 10/27] try catch on assert in engine --- engine/engine.ts | 9 ++++++--- engine/runner.ts | 1 - runners/console/index.ts | 7 +------ 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/engine/engine.ts b/engine/engine.ts index 26eb0448..0fc3fb30 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -41,13 +41,16 @@ export class Engine { } catch (e) { result.exceptions.push(e); + } + try { + await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); + } catch(error) { if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex])) { - console.log("Should stop") stop = true; - break; + } else { + throw error; } } - await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); break; } } diff --git a/engine/runner.ts b/engine/runner.ts index 23cf434c..768308f5 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -116,7 +116,6 @@ export abstract class Runner { commandIsSkippable(command: Command): Boolean { let returnVal = false; for (let skippableCommand in this.getVariable(this.skippableCommands)){ - console.log("skippable command: " + skippableCommand + ", command in question: " + command.name); if (skippableCommand == command.name) { returnVal = true; break; diff --git a/runners/console/index.ts b/runners/console/index.ts index 4b201557..2b4230a4 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -694,12 +694,7 @@ export class Console extends Runner { } } addToSkippableCommands(command: Command) { - console.log("Add " + command.name + "to skippableCommands"); - try { - this.setVariable(this.skippableCommands, this.getVariable(this.skippableCommands).push(command.name)); - } catch(e) { - console.log(e); - } + this.setVariable(this.skippableCommands, this.getVariable(this.skippableCommands).push(command.name)); } From 64a2c2b92777575b4b501775a997cc93cb2bfb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 10 Feb 2021 12:36:22 +0100 Subject: [PATCH 11/27] Throws Error if Docker-compose does not exit with code 0 --- engine/engine.ts | 7 +------ runners/console/index.ts | 6 ++++++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/engine/engine.ts b/engine/engine.ts index 0fc3fb30..c6b7bcc0 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -41,16 +41,11 @@ export class Engine { } catch (e) { result.exceptions.push(e); - } - try { - await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); - } catch(error) { if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex])) { stop = true; - } else { - throw error; } } + await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); break; } } diff --git a/runners/console/index.ts b/runners/console/index.ts index 2b4230a4..ae7ec8de 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -225,6 +225,12 @@ export class Console extends Runner { process.stdout.on('data', (data) => { console.log(data); }); + process.on('close', (code) => { + if (code !== 0) { + result.returnCode = code; + throw new Error(`Docker-Compose process exited with code ${code}`); + } + }); if(process.pid && command.parameters.length == 2) { this.asyncProcesses.push({ pid: process.pid, name: "dockerCompose", port: command.parameters[1].port }); } From 8a79cbed0ac4120202ff534cdf0a51276189bbb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 10 Feb 2021 12:40:26 +0100 Subject: [PATCH 12/27] Added break if skippable --- engine/engine.ts | 1 + runners/console/index.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/engine/engine.ts b/engine/engine.ts index c6b7bcc0..7366356b 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -43,6 +43,7 @@ export class Engine { result.exceptions.push(e); if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex])) { stop = true; + break; } } await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); diff --git a/runners/console/index.ts b/runners/console/index.ts index ae7ec8de..4f02fad0 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -228,7 +228,7 @@ export class Console extends Runner { process.on('close', (code) => { if (code !== 0) { result.returnCode = code; - throw new Error(`Docker-Compose process exited with code ${code}`); + throw new Error("Docker-Compose process exited with code " + code); } }); if(process.pid && command.parameters.length == 2) { From b928462f579ff6dc36b3f94f1061531c02bbcd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 10 Feb 2021 14:17:30 +0100 Subject: [PATCH 13/27] next test --- engine/engine.ts | 17 +++++++++++++---- runners/console/index.ts | 3 +-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/engine/engine.ts b/engine/engine.ts index 7366356b..22c370f8 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -35,18 +35,27 @@ export class Engine { for (let runnerIndex in this.environment.runners) { let runner = await this.getRunner(this.environment.runners[runnerIndex]); if (runner.supports(this.playbook.steps[stepIndex].lines[lineIndex].name)) { + if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex])) { + stop = true; + } var result = new RunResult(); try { result = runner.run(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex]); } catch (e) { result.exceptions.push(e); - if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex])) { - stop = true; - break; + } + console.log("Assertions start"); + try { + await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); + } catch(error){ + if(stop) { + continue; + } else { + throw error; } } - await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); + stop = false; break; } } diff --git a/runners/console/index.ts b/runners/console/index.ts index 4f02fad0..0a9d9661 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -227,8 +227,7 @@ export class Console extends Runner { }); process.on('close', (code) => { if (code !== 0) { - result.returnCode = code; - throw new Error("Docker-Compose process exited with code " + code); + result.returnCode = code; } }); if(process.pid && command.parameters.length == 2) { From 79a3399f1e63d24031acc661a76164f3cbb35cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 10 Feb 2021 16:06:17 +0100 Subject: [PATCH 14/27] next test for windows pipeline --- engine/engine.ts | 9 +++++---- engine/runner.ts | 13 ++----------- runners/console/index.ts | 18 ++++++++++++++---- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/engine/engine.ts b/engine/engine.ts index 22c370f8..2fe8955f 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -35,9 +35,6 @@ export class Engine { for (let runnerIndex in this.environment.runners) { let runner = await this.getRunner(this.environment.runners[runnerIndex]); if (runner.supports(this.playbook.steps[stepIndex].lines[lineIndex].name)) { - if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex])) { - stop = true; - } var result = new RunResult(); try { result = runner.run(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex]); @@ -45,11 +42,15 @@ export class Engine { catch (e) { result.exceptions.push(e); } - console.log("Assertions start"); + if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex].name)) { + stop = true; + } + console.log(this.playbook.steps[stepIndex].lines[lineIndex].name + ": is skippable: " + stop); try { await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); } catch(error){ if(stop) { + console.log("Catched failed assertion of skippable command"); continue; } else { throw error; diff --git a/engine/runner.ts b/engine/runner.ts index 768308f5..c98cc2d0 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -13,7 +13,6 @@ export abstract class Runner { public playbookTitle: string; protected readonly useDevonCommand: string = "useDevonCommand"; protected readonly workspaceDirectory: string = "workspaceDirectory"; - protected readonly skippableCommands: string = "skippableCommands"; private setVariableCallback: (name: string, value: any) => any; registerSetVariableCallback(callback: (name: string, value: any) => any) { @@ -85,7 +84,6 @@ export abstract class Runner { init(playbook: Playbook): void { this.setVariable(this.useDevonCommand, false); - this.setVariable(this.skippableCommands, new Array()); } run(step: Step, command: Command): RunResult { @@ -113,14 +111,7 @@ export abstract class Runner { return path; } - commandIsSkippable(command: Command): Boolean { - let returnVal = false; - for (let skippableCommand in this.getVariable(this.skippableCommands)){ - if (skippableCommand == command.name) { - returnVal = true; - break; - } - } - return returnVal; + commandIsSkippable(command: String): Boolean { + return false; } } \ No newline at end of file diff --git a/runners/console/index.ts b/runners/console/index.ts index 0a9d9661..efe3e494 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -19,6 +19,7 @@ export class Console extends Runner { private asyncProcesses: AsyncProcess[] = []; private mapIdeTools: Map = new Map(); private env: any; + private skippableCommands: Array = new Array(); init(playbook: Playbook): void { if(process.platform=="win32") { @@ -36,7 +37,6 @@ export class Console extends Runner { fs.renameSync(path.join(homedir, ".devon"), path.join(homedir, ".devon_backup")) } this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory())); - this.setVariable(this.skippableCommands, new Array()); this.env = process.env; } @@ -213,7 +213,7 @@ export class Console extends Runner { runDockerCompose(step: Step, command: Command): RunResult { let result = new RunResult(); result.returnCode = 0; - this.addToSkippableCommands(command); + this.skippableCommands.push(command.name); let filepath = path.join(this.getVariable(this.workspaceDirectory), command.parameters[0]); let process = this.executeCommandAsync("docker-compose up", filepath, result); @@ -698,8 +698,18 @@ export class Console extends Runner { }) } } - addToSkippableCommands(command: Command) { - this.setVariable(this.skippableCommands, this.getVariable(this.skippableCommands).push(command.name)); + + commandIsSkippable(command: String): Boolean { + let returnVal = false; + var arr = this.skippableCommands; + for (var i=0; i < arr.length; i++){ + console.log("skippableCommand: " + arr[i]); + if (arr[i] == command) { + returnVal = true; + break; + } + } + return returnVal; } From f99dca2ef3a46fffa6e77cee9cab22fc3ecc1a98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 10 Feb 2021 16:38:55 +0100 Subject: [PATCH 15/27] removed some unnessessary logging --- engine/engine.ts | 23 ++++++++--------------- runners/console/index.ts | 1 - 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/engine/engine.ts b/engine/engine.ts index 2fe8955f..56451584 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -23,43 +23,36 @@ export class Engine { for (let runnerIndex in this.environment.runners) { (await this.getRunner(this.environment.runners[runnerIndex])).init(this.playbook); } - let stop = false; for (let stepIndex in this.playbook.steps) { - if(stop) { - break; - } for (let lineIndex in this.playbook.steps[stepIndex].lines) { - if(stop) { - break; - } for (let runnerIndex in this.environment.runners) { let runner = await this.getRunner(this.environment.runners[runnerIndex]); if (runner.supports(this.playbook.steps[stepIndex].lines[lineIndex].name)) { var result = new RunResult(); + try { result = runner.run(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex]); } catch (e) { result.exceptions.push(e); } - if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex].name)) { - stop = true; - } - console.log(this.playbook.steps[stepIndex].lines[lineIndex].name + ": is skippable: " + stop); + + let allowedToStop = runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex].name); + try { await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); } catch(error){ - if(stop) { - console.log("Catched failed assertion of skippable command"); + if(allowedToStop) { + console.log("Catched failed assertion of skippable command: " + this.playbook.steps[stepIndex].lines[lineIndex].name); continue; } else { throw error; } } - stop = false; break; } - } + } + } } diff --git a/runners/console/index.ts b/runners/console/index.ts index efe3e494..9b984882 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -703,7 +703,6 @@ export class Console extends Runner { let returnVal = false; var arr = this.skippableCommands; for (var i=0; i < arr.length; i++){ - console.log("skippableCommand: " + arr[i]); if (arr[i] == command) { returnVal = true; break; From b3320324e7dff6830f227ab073a81d4975557447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Wed, 10 Feb 2021 16:44:09 +0100 Subject: [PATCH 16/27] Added missing logic --- engine/engine.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/engine.ts b/engine/engine.ts index 56451584..241342fb 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -23,8 +23,10 @@ export class Engine { for (let runnerIndex in this.environment.runners) { (await this.getRunner(this.environment.runners[runnerIndex])).init(this.playbook); } - for (let stepIndex in this.playbook.steps) { + + mainloop: for (let stepIndex in this.playbook.steps) { for (let lineIndex in this.playbook.steps[stepIndex].lines) { + let foundRunnerToExecuteCommand = false; for (let runnerIndex in this.environment.runners) { let runner = await this.getRunner(this.environment.runners[runnerIndex]); if (runner.supports(this.playbook.steps[stepIndex].lines[lineIndex].name)) { @@ -49,9 +51,13 @@ export class Engine { throw error; } } + foundRunnerToExecuteCommand = true; break; } - } + } + if(!foundRunnerToExecuteCommand) { + break mainloop; + } } } From b786674056fa3fa2457e5157de7c099c8c2520c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 12 Feb 2021 10:39:39 +0100 Subject: [PATCH 17/27] Added skippableCommands as console parameter --- buildRun.ps1 | 2 +- engine/engine.ts | 19 +++++-------------- engine/runner.ts | 11 ++++++++++- runners/console/index.ts | 33 ++++++++++++--------------------- 4 files changed, 28 insertions(+), 37 deletions(-) diff --git a/buildRun.ps1 b/buildRun.ps1 index 4d94d544..d7f1d108 100644 --- a/buildRun.ps1 +++ b/buildRun.ps1 @@ -4,4 +4,4 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\playbooks\ -Destination $PSScriptR Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build npm test -node $PSScriptRoot\build\engine\run.js \ No newline at end of file +node $PSScriptRoot\build\engine\run.js -consolerunner '["dockerCompose"]' \ No newline at end of file diff --git a/engine/engine.ts b/engine/engine.ts index 241342fb..a214d3f1 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -31,7 +31,9 @@ export class Engine { let runner = await this.getRunner(this.environment.runners[runnerIndex]); if (runner.supports(this.playbook.steps[stepIndex].lines[lineIndex].name)) { var result = new RunResult(); - + if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex].name)) { + continue; + } try { result = runner.run(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex]); } @@ -39,26 +41,15 @@ export class Engine { result.exceptions.push(e); } - let allowedToStop = runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex].name); + await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); - try { - await runner.assert(this.playbook.steps[stepIndex], this.playbook.steps[stepIndex].lines[lineIndex], result); - } catch(error){ - if(allowedToStop) { - console.log("Catched failed assertion of skippable command: " + this.playbook.steps[stepIndex].lines[lineIndex].name); - continue; - } else { - throw error; - } - } foundRunnerToExecuteCommand = true; break; } } if(!foundRunnerToExecuteCommand) { break mainloop; - } - + } } } diff --git a/engine/runner.ts b/engine/runner.ts index c98cc2d0..86cff998 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -13,6 +13,8 @@ export abstract class Runner { public playbookTitle: string; protected readonly useDevonCommand: string = "useDevonCommand"; protected readonly workspaceDirectory: string = "workspaceDirectory"; + protected argv = require('minimist')(process.argv.slice(2)); + protected skippableCommands: Array = new Array(); private setVariableCallback: (name: string, value: any) => any; registerSetVariableCallback(callback: (name: string, value: any) => any) { @@ -112,6 +114,13 @@ export abstract class Runner { } commandIsSkippable(command: String): Boolean { - return false; + let returnVal = false; + for (var i=0; i < this.skippableCommands.length; i++){ + if (this.skippableCommands[i] == command) { + returnVal = true; + break; + } + } + return returnVal; } } \ No newline at end of file diff --git a/runners/console/index.ts b/runners/console/index.ts index 9b984882..7144f8bf 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -19,7 +19,6 @@ export class Console extends Runner { private asyncProcesses: AsyncProcess[] = []; private mapIdeTools: Map = new Map(); private env: any; - private skippableCommands: Array = new Array(); init(playbook: Playbook): void { if(process.platform=="win32") { @@ -38,6 +37,9 @@ export class Console extends Runner { } this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory())); this.env = process.env; + if(this.argv.consolerunner) { + this.skippableCommands = JSON.parse(this.argv.consolerunner); + } } destroy(playbook: Playbook): void { @@ -213,18 +215,18 @@ export class Console extends Runner { runDockerCompose(step: Step, command: Command): RunResult { let result = new RunResult(); result.returnCode = 0; - this.skippableCommands.push(command.name); + let filepath = path.join(this.getVariable(this.workspaceDirectory), command.parameters[0]); let process = this.executeCommandAsync("docker-compose up", filepath, result); - process.stderr.setEncoding('utf-8'); - process.stderr.on('data', (data) => { - console.log("stderr: " + data); - }); - process.stdout.setEncoding('utf8'); - process.stdout.on('data', (data) => { - console.log(data); - }); + // process.stderr.setEncoding('utf-8'); + // process.stderr.on('data', (data) => { + // console.log("stderr: " + data); + // }); + // process.stdout.setEncoding('utf8'); + // process.stdout.on('data', (data) => { + // console.log(data); + // }); process.on('close', (code) => { if (code !== 0) { result.returnCode = code; @@ -699,17 +701,6 @@ export class Console extends Runner { } } - commandIsSkippable(command: String): Boolean { - let returnVal = false; - var arr = this.skippableCommands; - for (var i=0; i < arr.length; i++){ - if (arr[i] == command) { - returnVal = true; - break; - } - } - return returnVal; - } } From f5194ff86af5442153bb0854a4a6f920831e28ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 12 Feb 2021 10:42:33 +0100 Subject: [PATCH 18/27] Added dependency for minimist --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 243e096d..827ed3ef 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,8 @@ "ps-list": "^7.2.0", "rimraf": "^3.0.2", "ts-pegjs": "^0.2.7", - "yargs": "^16.1.0" + "yargs": "^16.1.0", + "minimist": "^1.2.5" }, "devDependencies": { "@types/jasmine": "^3.6.2", From 94ee1b7b7d200418853d3c183750e22457ded53c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 12 Feb 2021 11:59:37 +0100 Subject: [PATCH 19/27] use one parameter skipCommands --- buildRun.ps1 | 2 +- engine/engine.ts | 3 ++- engine/runner.ts | 20 +++++++++++++------- package.json | 3 +-- runners/console/index.ts | 4 +--- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/buildRun.ps1 b/buildRun.ps1 index d7f1d108..68c1ded2 100644 --- a/buildRun.ps1 +++ b/buildRun.ps1 @@ -4,4 +4,4 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\playbooks\ -Destination $PSScriptR Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build npm test -node $PSScriptRoot\build\engine\run.js -consolerunner '["dockerCompose"]' \ No newline at end of file +node $PSScriptRoot\build\engine\run.js -skipCommands '{"consolerunner": ["dockerCompose"]}' \ No newline at end of file diff --git a/engine/engine.ts b/engine/engine.ts index a214d3f1..b8a7bd21 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -31,7 +31,8 @@ export class Engine { let runner = await this.getRunner(this.environment.runners[runnerIndex]); if (runner.supports(this.playbook.steps[stepIndex].lines[lineIndex].name)) { var result = new RunResult(); - if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex].name)) { + if(runner.commandIsSkippable(runner.name, this.playbook.steps[stepIndex].lines[lineIndex].name)) { + console.log("Command " + this.playbook.steps[stepIndex].lines[lineIndex].name + " will be skipped."); continue; } try { diff --git a/engine/runner.ts b/engine/runner.ts index 86cff998..5a9a9ed0 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -13,8 +13,6 @@ export abstract class Runner { public playbookTitle: string; protected readonly useDevonCommand: string = "useDevonCommand"; protected readonly workspaceDirectory: string = "workspaceDirectory"; - protected argv = require('minimist')(process.argv.slice(2)); - protected skippableCommands: Array = new Array(); private setVariableCallback: (name: string, value: any) => any; registerSetVariableCallback(callback: (name: string, value: any) => any) { @@ -113,12 +111,20 @@ export abstract class Runner { return path; } - commandIsSkippable(command: String): Boolean { + commandIsSkippable(runnerName: String, command: String): Boolean { let returnVal = false; - for (var i=0; i < this.skippableCommands.length; i++){ - if (this.skippableCommands[i] == command) { - returnVal = true; - break; + if(this.getVariable("skipCommands")) { + let json = JSON.parse(this.getVariable("skipCommands")); + for(var key in json) { + if(key == runnerName) { + for (var i=0; i < json[key].length; i++){ + if (json[key][i] == command) { + returnVal = true; + break; + } + } + break; + } } } return returnVal; diff --git a/package.json b/package.json index 827ed3ef..243e096d 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,7 @@ "ps-list": "^7.2.0", "rimraf": "^3.0.2", "ts-pegjs": "^0.2.7", - "yargs": "^16.1.0", - "minimist": "^1.2.5" + "yargs": "^16.1.0" }, "devDependencies": { "@types/jasmine": "^3.6.2", diff --git a/runners/console/index.ts b/runners/console/index.ts index 7144f8bf..f89d39af 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -37,9 +37,7 @@ export class Console extends Runner { } this.setVariable(this.workspaceDirectory, path.join(this.getWorkingDirectory())); this.env = process.env; - if(this.argv.consolerunner) { - this.skippableCommands = JSON.parse(this.argv.consolerunner); - } + } destroy(playbook: Playbook): void { From 5c60621c2bee6d3fc6e4b5473b9ec338e7d27f4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 12 Feb 2021 12:08:35 +0100 Subject: [PATCH 20/27] added logging to debug --- engine/runner.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/engine/runner.ts b/engine/runner.ts index 5a9a9ed0..175a12dc 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -116,6 +116,7 @@ export abstract class Runner { if(this.getVariable("skipCommands")) { let json = JSON.parse(this.getVariable("skipCommands")); for(var key in json) { + console.log("key: " + key + " runnername: " + runnerName); if(key == runnerName) { for (var i=0; i < json[key].length; i++){ if (json[key][i] == command) { From 728a0b38982d0d6b65b1ae6a48485b2364b670ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 12 Feb 2021 15:06:38 +0100 Subject: [PATCH 21/27] Different parsing --- buildRun.ps1 | 2 +- engine/engine.ts | 2 +- engine/run.ts | 6 +++++- engine/runner.ts | 26 ++++++++++++-------------- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/buildRun.ps1 b/buildRun.ps1 index 68c1ded2..17546cc7 100644 --- a/buildRun.ps1 +++ b/buildRun.ps1 @@ -4,4 +4,4 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\playbooks\ -Destination $PSScriptR Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScriptRoot\build Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build npm test -node $PSScriptRoot\build\engine\run.js -skipCommands '{"consolerunner": ["dockerCompose"]}' \ No newline at end of file +node $PSScriptRoot\build\engine\run.js --skipCommands.console dockerCompose \ No newline at end of file diff --git a/engine/engine.ts b/engine/engine.ts index b8a7bd21..3aafebd7 100644 --- a/engine/engine.ts +++ b/engine/engine.ts @@ -31,7 +31,7 @@ export class Engine { let runner = await this.getRunner(this.environment.runners[runnerIndex]); if (runner.supports(this.playbook.steps[stepIndex].lines[lineIndex].name)) { var result = new RunResult(); - if(runner.commandIsSkippable(runner.name, this.playbook.steps[stepIndex].lines[lineIndex].name)) { + if(runner.commandIsSkippable(this.playbook.steps[stepIndex].lines[lineIndex].name)) { console.log("Command " + this.playbook.steps[stepIndex].lines[lineIndex].name + " will be skipped."); continue; } diff --git a/engine/run.ts b/engine/run.ts index 436f5bf6..c955ae3b 100644 --- a/engine/run.ts +++ b/engine/run.ts @@ -71,13 +71,17 @@ class Run { parseArgs() { var argv = yargs(process.argv.slice(2)).argv; + console.log(argv); this.traverseArgs('', argv); + console.log(this.args); + } traverseArgs(parentName, obj) { for (let index in obj) { - if (isObject(obj[index])) { + if (obj[index] instanceof Object) { + this.args.set(parentName + index, obj[index]); this.traverseArgs(parentName + index + ".", obj[index]); } else { diff --git a/engine/runner.ts b/engine/runner.ts index 175a12dc..84000d03 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -111,23 +111,21 @@ export abstract class Runner { return path; } - commandIsSkippable(runnerName: String, command: String): Boolean { - let returnVal = false; - if(this.getVariable("skipCommands")) { - let json = JSON.parse(this.getVariable("skipCommands")); - for(var key in json) { - console.log("key: " + key + " runnername: " + runnerName); - if(key == runnerName) { - for (var i=0; i < json[key].length; i++){ - if (json[key][i] == command) { - returnVal = true; - break; - } + commandIsSkippable(command: String): Boolean { + let returnVal = false; + let runner = this.getVariable("skipCommands." + this.getRunnerName()); + if(runner) { + if(runner instanceof Array) { + for (var i=0; i < runner.length; i++){ + if (runner[i] == command) { + returnVal = true; + break; } - break; } + } else if (runner == command) { + returnVal = true; } - } + } return returnVal; } } \ No newline at end of file From d0bed5b186a8c9bd3721598068126d8183c32e6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 12 Feb 2021 15:09:49 +0100 Subject: [PATCH 22/27] Removed logging --- engine/run.ts | 3 --- 1 file changed, 3 deletions(-) diff --git a/engine/run.ts b/engine/run.ts index c955ae3b..4d613348 100644 --- a/engine/run.ts +++ b/engine/run.ts @@ -71,10 +71,7 @@ class Run { parseArgs() { var argv = yargs(process.argv.slice(2)).argv; - console.log(argv); this.traverseArgs('', argv); - console.log(this.args); - } traverseArgs(parentName, obj) { From ceb9d687e478f05af0bfa3e95bceddb1a6052e3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 12 Feb 2021 17:20:10 +0100 Subject: [PATCH 23/27] Removed logs and changed small part in commandIsSkippable --- engine/runner.ts | 11 +++-------- runners/console/index.ts | 9 --------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/engine/runner.ts b/engine/runner.ts index 84000d03..e97332cb 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -115,15 +115,10 @@ export abstract class Runner { let returnVal = false; let runner = this.getVariable("skipCommands." + this.getRunnerName()); if(runner) { - if(runner instanceof Array) { - for (var i=0; i < runner.length; i++){ - if (runner[i] == command) { - returnVal = true; - break; - } - } + if(runner instanceof Array && runner.indexOf(command) != -1) { + returnVal = true; } else if (runner == command) { - returnVal = true; + returnVal = true; } } return returnVal; diff --git a/runners/console/index.ts b/runners/console/index.ts index f89d39af..c6b64fcc 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -9,7 +9,6 @@ import * as path from 'path'; import * as child_process from "child_process"; import * as fs from "fs"; import * as psList from "ps-list"; -import { info } from "console"; const findProcess = require("find-process"); const os = require("os"); @@ -217,14 +216,6 @@ export class Console extends Runner { let filepath = path.join(this.getVariable(this.workspaceDirectory), command.parameters[0]); let process = this.executeCommandAsync("docker-compose up", filepath, result); - // process.stderr.setEncoding('utf-8'); - // process.stderr.on('data', (data) => { - // console.log("stderr: " + data); - // }); - // process.stdout.setEncoding('utf8'); - // process.stdout.on('data', (data) => { - // console.log(data); - // }); process.on('close', (code) => { if (code !== 0) { result.returnCode = code; From ef751dbc4e74ae1c9bf0eadcccdafbf4a39e22ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Fri, 12 Feb 2021 17:22:05 +0100 Subject: [PATCH 24/27] removed else branch of comamndIsSkippable --- engine/runner.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/engine/runner.ts b/engine/runner.ts index e97332cb..c6e029cb 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -115,9 +115,7 @@ export abstract class Runner { let returnVal = false; let runner = this.getVariable("skipCommands." + this.getRunnerName()); if(runner) { - if(runner instanceof Array && runner.indexOf(command) != -1) { - returnVal = true; - } else if (runner == command) { + if((runner instanceof Array && runner.indexOf(command) != -1) || runner == command) { returnVal = true; } } From 066b4f16838db5549193e9f85360555377ef9441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Mon, 15 Feb 2021 09:51:11 +0100 Subject: [PATCH 25/27] Added parameter for path in assertion --- runners/console/index.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index c6b64fcc..6d0e3b8c 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -456,10 +456,15 @@ export class Console extends Runner { this.killAsyncProcesses(); throw new Error("Missing arguments for command dockerCompose. You have to specify a port and a path for the server. For further information read the function documentation."); } else { - let isReachable = await assert.serverIsReachable(command.parameters[1].port, ""); + let path = (command.parameters[1].path) || ""; + if (path) { + path = "/" + path; + } + console.log(path); + let isReachable = await assert.serverIsReachable(command.parameters[1].port, path); if(!isReachable) { this.killAsyncProcesses(); - throw new Error("The server has not become reachable in " + startupTimeInSeconds + " seconds: " + "http://localhost:" + command.parameters[1].port) + throw new Error("The server has not become reachable in " + startupTimeInSeconds + " seconds: " + "http://localhost" + path + ":" + command.parameters[1].port) } } } From 9b3206413f9e77cdfb0a2dde56382747b7611c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcel=20Die=C3=9Fner?= Date: Mon, 15 Feb 2021 10:02:20 +0100 Subject: [PATCH 26/27] path handling --- runners/console/index.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/runners/console/index.ts b/runners/console/index.ts index 6d0e3b8c..b9e7e325 100644 --- a/runners/console/index.ts +++ b/runners/console/index.ts @@ -456,15 +456,10 @@ export class Console extends Runner { this.killAsyncProcesses(); throw new Error("Missing arguments for command dockerCompose. You have to specify a port and a path for the server. For further information read the function documentation."); } else { - let path = (command.parameters[1].path) || ""; - if (path) { - path = "/" + path; - } - console.log(path); - let isReachable = await assert.serverIsReachable(command.parameters[1].port, path); + let isReachable = await assert.serverIsReachable(command.parameters[1].port, command.parameters[1].path); if(!isReachable) { this.killAsyncProcesses(); - throw new Error("The server has not become reachable in " + startupTimeInSeconds + " seconds: " + "http://localhost" + path + ":" + command.parameters[1].port) + throw new Error("The server has not become reachable in " + startupTimeInSeconds + " seconds: " + "http://localhost:" + command.parameters[1].port + "/" + command.parameters[1].path); } } } From c6aeb082adf0efab5777a745753e9caebbed3019 Mon Sep 17 00:00:00 2001 From: MarcelDiessner <64065623+MarcelDiessner@users.noreply.github.com> Date: Mon, 15 Feb 2021 10:35:03 +0100 Subject: [PATCH 27/27] Update Functions.md Added path to docker-compose --- documentation/Functions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/documentation/Functions.md b/documentation/Functions.md index badd8b90..11abb8e4 100644 --- a/documentation/Functions.md +++ b/documentation/Functions.md @@ -158,11 +158,12 @@ npmInstall("my-thai-star/angular") 1. Path to the directory where the docker-compose.yml file is located, relative to workspace. 2. Assertion information. Only needed for the console runner to check if the server was started properly. #### example -dockerCompose("my-thai-star", { "startupTime": 600, "port": 8081 }) +dockerCompose("my-thai-star", { "startupTime": 600, "port": 8081, "path": "" }) ##### Assertion information startupTime = Time in seconds to wait before checking if the server is running port: Port on which the server is running +path: The URL path on which is checked if the server is running ***