Skip to content

Commit f7927a5

Browse files
authored
Merge pull request #6 from dockstore-testing/develop
Merge to master
2 parents 0ab8667 + 728a681 commit f7927a5

File tree

9 files changed

+95
-30
lines changed

9 files changed

+95
-30
lines changed

.travis.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
sudo: required
2+
3+
services:
4+
- docker
5+
6+
language: python
7+
8+
python:
9+
- "3.6"
10+
11+
before_install:
12+
# Download Cromwell
13+
- wget -O $TRAVIS_BUILD_DIR/cromwell-42.jar https://github.com/broadinstitute/cromwell/releases/download/42/cromwell-42.jar;
14+
- curl -o requirements.txt "https://dockstore.org/api/metadata/runner_dependencies?client_version=1.6.0&python_version=3"
15+
16+
install:
17+
- pip install -r requirements.txt
18+
19+
script:
20+
- docker build -t test-image -f checker/Dockerfile checker
21+
- >-
22+
sed 's/dockerPull:.*/dockerPull: test-image:latest/g' checker/md5sum-checker.cwl
23+
- >-
24+
sed 's/docker:.*/docker: "test-image:latest"/g' checker/md5sum-checker.wdl
25+
- python -m unittest discover -s .

checker-fail-cwl.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"input_file": {
3+
"class": "File",
4+
"path": "md5sum.input"
5+
},
6+
"expected_md5": "not a matching md5sum"
7+
}

checker/bin/check_md5sum

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,41 @@ import json
66
import sys
77
import os
88

9+
910
def main():
10-
parser = argparse.ArgumentParser(description='Checks to see if a given file contains a certain string and then returns a JSON.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
11-
parser.add_argument('--input-file', type=str, help='file input')
12-
parser.add_argument('--md5', type=str, help='expected md5')
13-
args = parser.parse_args()
11+
parser = argparse.ArgumentParser(description='Checks to see if a given file contains a certain string and then returns a JSON.', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
12+
parser.add_argument('--input-file', type=str, help='file input')
13+
parser.add_argument('--md5', type=str, help='expected md5')
14+
args = parser.parse_args()
15+
16+
result_code = check_file(args.input_file, args.md5)
1417

15-
result = check_file(args.input_file, args.md5)
18+
results_file = open("results.json", "w")
19+
if result_code == 0:
20+
results_file.write('{ "overall" : true, "steps" : { "md5sum_check" : true } }')
21+
else:
22+
results_file.write('{ "overall" : false, "steps" : { "md5sum_check" : false } }')
23+
results_file.close()
1624

17-
results_file = open("results.json", "w")
18-
if (result == 0):
19-
results_file.write('{ "overall" : true, "steps" : { "md5sum_check" : true } }')
20-
else:
21-
results_file.write('{ "overall" : false, "steps" : { "md5sum_check" : false } }')
22-
results_file.close()
25+
log_file = open("log.txt", "w")
26+
log_file.write("")
27+
log_file.close()
2328

24-
log_file = open("log.txt", "w")
25-
log_file.write("")
26-
log_file.close()
29+
sys.exit(result_code)
2730

28-
# correct way to do this?
29-
return(result)
3031

3132
def check_file(input_file, md5):
32-
file = open(input_file, "r")
33-
contents = file.read()
34-
contents = contents.rstrip()
35-
print ("FILE CONTENTS: "+contents)
36-
if (contents == md5):
37-
print("Contents match")
38-
return(0)
39-
else:
40-
print("Contents DO NOT match")
41-
return(1)
33+
file = open(input_file, "r")
34+
contents = file.read()
35+
contents = contents.rstrip()
36+
print("FILE CONTENTS: "+contents)
37+
if contents == md5:
38+
print("Contents match")
39+
return 0
40+
else:
41+
print("Contents DO NOT match")
42+
return 1
43+
4244

4345
if __name__ == "__main__":
4446
main()

checker/md5sum-checker.cwl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cwlVersion: v1.0
77

88
requirements:
99
- class: DockerRequirement
10-
dockerPull: quay.io/agduncan94/checker-md5sum
10+
dockerPull: quay.io/dockstore-testing/md5sum-checker:1.0.0
1111
- class: InlineJavascriptRequirement
1212

1313
hints:

checker/md5sum-checker.wdl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ task checkerTask {
77
}
88

99
runtime {
10-
docker: "quay.io/agduncan94/checker-md5sum"
10+
docker: "quay.io/dockstore-testing/md5sum-checker:1.0.0"
1111
}
1212
}

md5sum-fail-wdl.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"checkerWorkflow.inputFile": "md5sum.input",
3+
"checkerWorkflow.expectedMd5sum": "not a real md5sum"
4+
}

md5sum/md5sum-input-cwl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"input_file": {
33
"class": "File",
4-
"path": "md5sum.input"
4+
"path": "../md5sum.input"
55
}
66
}

md5sum/md5sum-wdl.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"ga4ghMd5.inputFile": "md5sum.input"
2+
"ga4ghMd5.inputFile": "../md5sum.input"
33
}

test.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import subprocess
2+
import unittest
3+
4+
5+
class TestMd5sumChecker(unittest.TestCase):
6+
# For each workflow, verify that it succeeds when the input file's md5sum matches and fails when it does not
7+
def test_cwl_success(self):
8+
process = subprocess.call(["cwltool", "checker-workflow-wrapping-tool.cwl", "checker-input-cwl.json"])
9+
self.assertEqual(process, 0)
10+
11+
def test_cwl_failure(self):
12+
process = subprocess.call(["cwltool", "checker-workflow-wrapping-tool.cwl", "checker-fail-cwl.json"])
13+
self.assertEqual(process, 1)
14+
15+
def test_wdl_success(self):
16+
process = subprocess.call(["java", "-jar", "cromwell-42.jar", "run", "checker-workflow-wrapping-workflow.wdl",
17+
"-i", "md5sum-wdl.json"])
18+
self.assertEqual(process, 0)
19+
20+
def test_wdl_failure(self):
21+
process = subprocess.call(["java", "-jar", "cromwell-42.jar", "run", "checker-workflow-wrapping-workflow.wdl",
22+
"-i", "md5sum-fail-wdl.json"])
23+
self.assertEqual(process, 1)
24+
25+
26+
if __name__ == '__main__':
27+
unittest.main()

0 commit comments

Comments
 (0)