Skip to content

Commit a9cf0a7

Browse files
authored
Merge branch 'master' into httpinput
2 parents 6a4d1f0 + eefff3d commit a9cf0a7

File tree

5 files changed

+106
-16
lines changed

5 files changed

+106
-16
lines changed

cwltool/pack.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,9 @@ def rewrite_id(r, mainuri):
157157

158158
import_embed(packed, set())
159159

160+
if len(packed["$graph"]) == 1:
161+
# duplicate 'cwlVersion' inside $graph when there is a single item
162+
# because we're printing contents inside '$graph' rather than whole dict
163+
packed["$graph"][0]["cwlVersion"] = packed["cwlVersion"]
164+
160165
return packed

jenkins.bash

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,40 @@ cloneorpull() {
1414
}
1515
venv() {
1616
if ! test -d "$1" ; then
17-
virtualenv "$1"
17+
virtualenv -p python${PYTHON_VERSION} "$1"
1818
fi
1919
# shellcheck source=/dev/null
2020
source "$1"/bin/activate
2121
}
22-
git clean --force -d -x || /bin/true
22+
2323
cloneorpull common-workflow-language https://github.com/common-workflow-language/common-workflow-language.git
24-
venv cwltool-venv
2524
docker pull node:slim
26-
export PIP_DOWNLOAD_CACHE=/var/lib/jenkins/pypi-cache/
27-
pip install -U setuptools wheel pip
28-
python setup.py install
29-
pip install "cwltest>=1.0.20160825151655"
30-
pushd common-workflow-language
25+
# clean both the repos before the loop
3126
git clean --force -d -x || /bin/true
32-
# shellcheck disable=SC2154
33-
if [[ "$version" = *dev* ]]
34-
then
35-
EXTRA="EXTRA=--enable-dev"
36-
fi
37-
./run_test.sh --junit-xml=result.xml RUNNER=cwltool -j4 DRAFT="${version}" ${EXTRA}
38-
CODE=$?
39-
popd
27+
git -C common-workflow-language clean --force -d -x || /bin/true
28+
29+
# Test for Python 2.7 and Python 3
30+
for PYTHON_VERSION in 2.7 3
31+
do
32+
venv cwltool-venv${PYTHON_VERSION}
33+
export PIP_DOWNLOAD_CACHE=/var/lib/jenkins/pypi-cache/
34+
# use pip2.7 and pip3 in separate loop runs
35+
pip${PYTHON_VERSION} install -U setuptools wheel pip
36+
pip${PYTHON_VERSION} install .
37+
pip${PYTHON_VERSION} install "cwltest>=1.0.20160825151655"
38+
pushd common-workflow-language
39+
# shellcheck disable=SC2154
40+
if [[ "$version" = *dev* ]]
41+
then
42+
EXTRA="EXTRA=--enable-dev"
43+
fi
44+
./run_test.sh --junit-xml=result${PYTHON_VERSION}.xml RUNNER=cwltool -j4 DRAFT=${version}
45+
CODE=$(($CODE+$?)) # capture return code of ./run_test.sh
46+
deactivate
47+
popd
48+
done
49+
50+
# build new docker container
4051
if [ "$GIT_BRANCH" = "origin/master" ] && [[ "$version" = "v1.0" ]]
4152
then
4253
./build-cwl-docker.sh && docker push commonworkflowlanguage/cwltool_module && docker push commonworkflowlanguage/cwltool

tests/test_pack.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from functools import partial
66

77
import cwltool.pack
8+
from cwltool.main import print_pack as print_pack
89
import cwltool.workflow
910
from cwltool.load_tool import fetch_document, validate_document
1011
from cwltool.main import makeRelative
@@ -33,3 +34,29 @@ def test_pack(self):
3334
del expect_packed["$schemas"]
3435

3536
self.assertEqual(expect_packed, packed)
37+
38+
def test_pack_missing_cwlVersion(self):
39+
"""Test to ensure the generated pack output is not missing
40+
the `cwlVersion` in case of single tool workflow and single step workflow"""
41+
# Since diff is longer than 3174 characters
42+
self.maxDiff = None
43+
44+
# Testing single tool workflow
45+
document_loader, workflowobj, uri = fetch_document(
46+
get_data("tests/wf/hello_single_tool.cwl"))
47+
document_loader, avsc_names, processobj, metadata, uri = validate_document(
48+
document_loader, workflowobj, uri)
49+
# generate pack output dict
50+
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
51+
52+
self.assertEqual('v1.0', packed["cwlVersion"])
53+
54+
# Testing single step workflow
55+
document_loader, workflowobj, uri = fetch_document(
56+
get_data("tests/wf/hello-workflow.cwl"))
57+
document_loader, avsc_names, processobj, metadata, uri = validate_document(
58+
document_loader, workflowobj, uri)
59+
# generate pack output dict
60+
packed = json.loads(print_pack(document_loader, processobj, uri, metadata))
61+
62+
self.assertEqual('v1.0', packed["cwlVersion"])

tests/wf/hello-workflow.cwl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/usr/bin/env cwl-runner
2+
3+
cwlVersion: v1.0
4+
class: Workflow
5+
6+
label: "Hello World"
7+
doc: "Outputs a message using echo"
8+
9+
inputs:
10+
usermessage: string
11+
12+
outputs:
13+
response:
14+
outputSource: step0/response
15+
type: File
16+
17+
steps:
18+
step0:
19+
run:
20+
class: CommandLineTool
21+
inputs:
22+
message:
23+
type: string
24+
doc: "The message to print"
25+
default: "Hello World"
26+
inputBinding:
27+
position: 1
28+
baseCommand: echo
29+
arguments:
30+
- "-n"
31+
- "-e"
32+
stdout: response.txt
33+
outputs:
34+
response:
35+
type: stdout
36+
in:
37+
message: usermessage
38+
out: [response]

tests/wf/hello_single_tool.cwl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cwlVersion: v1.0
2+
class: CommandLineTool
3+
baseCommand: echo
4+
inputs:
5+
message:
6+
type: string
7+
inputBinding:
8+
position: 1
9+
outputs: []

0 commit comments

Comments
 (0)