diff --git a/buildRun.ps1 b/buildRun.ps1 index 17546cc7..883c3539 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.console dockerCompose \ No newline at end of file +node $PSScriptRoot\build\engine\run.js --skipCommands.console dockerCompose $args \ No newline at end of file diff --git a/buildRun.sh b/buildRun.sh index 7d6302c4..6edd2a7f 100644 --- a/buildRun.sh +++ b/buildRun.sh @@ -4,4 +4,4 @@ cp -r playbooks build cp -r environments build cp -r runners build npm test -node build/engine/run.js \ No newline at end of file +node build/engine/run.js $* \ No newline at end of file diff --git a/documentation/Development.md b/documentation/Development.md index fff96fd4..1abf6f52 100644 --- a/documentation/Development.md +++ b/documentation/Development.md @@ -11,7 +11,7 @@ To create a new command you can use in your playbooks, you have to implement a n The new method must match the following syntax: 'run' + name of the command. The first letter after 'run' has to be in upper case letters. ``` -runYourCommand(step: Step, command: Command): RunResult { +runYourCommand(runCommand: RunCommand): RunResult ...your code... let result = new RunResult(); result.returnCode = 1; @@ -22,7 +22,7 @@ With the RunResult object you can return a value after the function has executed The assert method has to match the same naming conventions as the run method (except the 'assert' at the beginning) and is located in the same runner class. The RunResult object of the run method is passed to this method as a parameter. ``` -async assertYourCommand(step: Step, command: Command, result: RunResult) { +async assertYourCommand(runCommand: RunCommand, result: RunResult) { new Assertions() .yourFirstAssertion(result) .yourSecondAssertion(result); @@ -55,3 +55,24 @@ public yourAssertionCode(): Assertions { ``` If you want to pass arguments to this method, you have to do this in the header of the 'run' method and in the call of the method. +## Choose the tutorial and the environment + +### Environment +flag: '-e' +value: 'katacoda', 'console' + +If you don't pass environment arguments to the file, it will run the playbooks on all environments. + +#### example +'bash localBuildRun.sh -e katacoda -e console' + +### Playbook +flag: '-p' +value: foldername of the tutorial + +If you don't pass playbook arguments to the file, it will run all playbooks, that are in the folder 'tutorials'. + +#### example +'bash localBuildRun.sh -p cobigen-cli' + + diff --git a/engine/run.ts b/engine/run.ts index 3e085d57..e6e46525 100644 --- a/engine/run.ts +++ b/engine/run.ts @@ -17,10 +17,12 @@ class Run { this.parseArgs(); this.parsePlaybooks(); this.parseEnvironments(); - for (let entry of Array.from(this.environments.entries())) { + let entries = this.filterEnv(Array.from(this.environments.entries())) + for (let entry of entries) { let key = entry[0]; let value = entry[1]; - for (let playbookIndex in this.playbooks) { + let playbookIndecies = this.filterPlaybooks(this.playbooks) + for (let playbookIndex of playbookIndecies) { let engine = new Engine(key, value, this.playbooks[playbookIndex]); for (let varEntry of Array.from(this.args.entries())) { @@ -97,6 +99,30 @@ class Run { } } } + + filterEnv(entries){ + if(!this.args.get('e')) + return entries; + + let filteredEntries = new Array(); + for(let entry of entries){ + if(this.args.get('e').includes(entry[0])) + filteredEntries.push(entry) + } + return filteredEntries + } + + filterPlaybooks(playbooks){ + if(!this.args.get('p')) + return Array.from(playbooks.keys()); + + let filteredIndecies = []; + for(let playbook of playbooks){ + if(this.args.get('p').includes(playbook['name'].replace("/", ""))) + filteredIndecies.push(playbooks.indexOf(playbook)) + } + return filteredIndecies + } } diff --git a/engine/runner.ts b/engine/runner.ts index 7fa590bc..705bef56 100644 --- a/engine/runner.ts +++ b/engine/runner.ts @@ -1,7 +1,5 @@ -import { Command } from "./command"; import { RunResult } from "./run_result"; import { Playbook } from "./playbook"; -import { Step } from "./step"; import * as fs from 'fs'; import * as rimraf from 'rimraf'; import { RunCommand } from "./run_command"; diff --git a/localBuildRun.ps1 b/localBuildRun.ps1 index 1394ca6d..9e20f5c4 100644 --- a/localBuildRun.ps1 +++ b/localBuildRun.ps1 @@ -5,4 +5,4 @@ Copy-Item -Force -Recurse -Path $PSScriptRoot\environments\ -Destination $PSScri Copy-Item -Force -Recurse -Path $PSScriptRoot\runners\ -Destination $PSScriptRoot\build npm test if(-not $?) { throw 'tests failed' } -node $PSScriptRoot\build\engine\run.js \ No newline at end of file +node $PSScriptRoot\build\engine\run.js $args \ No newline at end of file diff --git a/localBuildRun.sh b/localBuildRun.sh index 25076b0e..bfcc2da8 100644 --- a/localBuildRun.sh +++ b/localBuildRun.sh @@ -8,4 +8,5 @@ if [ $? -eq 1 ]; then echo 'tests failed' exit 1 fi -node build/engine/run.js \ No newline at end of file + +node build/engine/run.js $* \ No newline at end of file