Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion buildRun.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
node $PSScriptRoot\build\engine\run.js --skipCommands.console dockerCompose $args
2 changes: 1 addition & 1 deletion buildRun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ cp -r playbooks build
cp -r environments build
cp -r runners build
npm test
node build/engine/run.js
node build/engine/run.js $*
25 changes: 23 additions & 2 deletions documentation/Development.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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'


30 changes: 28 additions & 2 deletions engine/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down Expand Up @@ -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
}
}


Expand Down
2 changes: 0 additions & 2 deletions engine/runner.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion localBuildRun.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
node $PSScriptRoot\build\engine\run.js $args
3 changes: 2 additions & 1 deletion localBuildRun.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ if [ $? -eq 1 ]; then
echo 'tests failed'
exit 1
fi
node build/engine/run.js

node build/engine/run.js $*