Skip to content

Commit

Permalink
Add Dockerfile, more documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Amstutz committed Jul 15, 2019
1 parent 36cee56 commit 6a2dada
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 32 deletions.
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ Design principals:
* Useful default behaviors when not specified
* Be fun to use

Note! Although cwl-ex tool already offers a lot of functionality, the
error reporting still needs a lot of work. If you are trying to use
it and running into problems, please file an issue.
# Quickstart using Docker

# Installation:
Build a self-contained script (no imports)

```
cwl-runner cwlex.cwl --inp myscript.cwlex
```

Build script with imports:

```
cwl-runner cwlex.cwl --inpdir . --inpfile myscript.cwlex
```

# Installing

```
npm install cwl-ex
Expand Down Expand Up @@ -235,20 +245,30 @@ def workflow main(v1="hello", v2="world") {
Generate the parser (requires antlr4):

```
$ cwl-runner antlr.cwl
$ cd src && cwl-runner antlr.cwl
```

Install dependencies (requires node.js and npm):

Run local code in Docker
```
$ npm install
cwl-runner cwlex.cwl --inp src/cwlex-dev.cwlex
cwl-runner cwlex-dev.cwl --inp myscript.cwlex
```

Run tests:

```
$ ./cwlex.js cwlex-tests.cwlex > cwlex-tests.cwl
$ cwl-runner cwlex.cwl --inpdir . --inpfile cwlex-tests.cwlex
$ cwl-runner cwlex-tests.cwl
```

TODO: Create Docker image with antlr4, nodejs and dependencies.
Install dependencies (requires node.js and npm):

```
$ npm install
```

Generate Docker image
```
npm pack
docker build -f cwlex.Dockerfile .
```
40 changes: 30 additions & 10 deletions README.md.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ Design principals:
* Useful default behaviors when not specified
* Be fun to use

Note! Although cwl-ex tool already offers a lot of functionality, the
error reporting still needs a lot of work. If you are trying to use
it and running into problems, please file an issue.
# Quickstart using Docker

# Installation:
Build a self-contained script (no imports)

```
cwl-runner cwlex.cwl --inp myscript.cwlex
```

Build script with imports:

```
cwl-runner cwlex.cwl --inpdir . --inpfile myscript.cwlex
```

# Installing

```
npm install cwl-ex
Expand Down Expand Up @@ -159,20 +169,30 @@ $include: ex14.cwlex
Generate the parser (requires antlr4):

```
$ cwl-runner antlr.cwl
$ cd src && cwl-runner antlr.cwl
```

Install dependencies (requires node.js and npm):

Run local code in Docker
```
$ npm install
cwl-runner cwlex.cwl --inp src/cwlex-dev.cwlex
cwl-runner cwlex-dev.cwl --inp myscript.cwlex
```

Run tests:

```
$ ./cwlex.js cwlex-tests.cwlex > cwlex-tests.cwl
$ cwl-runner cwlex.cwl --inpdir . --inpfile cwlex-tests.cwlex
$ cwl-runner cwlex-tests.cwl
```

TODO: Create Docker image with antlr4, nodejs and dependencies.
Install dependencies (requires node.js and npm):

```
$ npm install
```

Generate Docker image
```
npm pack
docker build -f cwlex.Dockerfile .
```
2 changes: 1 addition & 1 deletion cwlex-tests.cwlex
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "cwlex.cwlex" as cwlex
import "src/cwlex.cwlex" as cwlex

def workflow main(
cases = [
Expand Down
5 changes: 5 additions & 0 deletions cwlex.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from node:slim

COPY cwl-ex-1.0.0.tgz /root

RUN npm install --global /root/cwl-ex-1.0.0.tgz
13 changes: 2 additions & 11 deletions src/cwlex.cwlex
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
def tool main(
cwlex = File("cwlex.js", "cwlex-convert.js", "cwlexLexer.js", "cwlexListener.js", "cwlexParser.js"),
node_modules = Directory("node_modules"),
inp? File,
inpdir? Directory,
inpfile? string,
outname? string)
{
requirements {
InitialWorkDirRequirement {
listing: [{
entry: "$(inputs.node_modules)"
}, {
entry: "$(inputs.cwlex)"
}]
}
DockerRequirement { dockerPull: "node:slim" }
DockerRequirement { dockerPull: "commonworkflowlanguage/cwlex" }
InlineJavascriptRequirement { expressionLib: ["
function outname(inputs) {
return inputs.outname ? inputs.outname : (inputs.inp ? inputs.inp.nameroot+'.cwl' : inputs.inpfile.replace(/(.*)\.cwlex/, '$1.cwl'));
}
"]}
}
nodejs $(inputs.cwlex) "$(inputs.inp ? inputs.inp.path : inputs.inpdir.path+'/'+inputs.inpfile)" > "$(outname(inputs))"
cwlex "$(inputs.inp ? inputs.inp.path : inputs.inpdir.path+'/'+inputs.inpfile)" > "$(outname(inputs))"
return File(outname(inputs)) as converted
}

0 comments on commit 6a2dada

Please sign in to comment.