-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun
executable file
·91 lines (81 loc) · 3.91 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
set -u
config=$(cat -)
file=$(echo "$config" | jq -r '."source"')
resources=$(echo "$config" | jq -r '."resources"')
workdir=$(echo "$config" | jq -r '."workdir"')
language=$(echo "$config" | jq -r '."natural_language"')
nextflow_arguments=$(echo "$config" | jq -r '."nextflow_arguments"')
title="Nextflow"
if [ "$language" = "nl" ]; then
empty="Lege oplossing"
run_fail="Nextflow run is gefaald"
file_not_found="Bestand is niet gevonden"
dir_not_found="Folder is niet gevonden"
file_check="Bestaan van bestand controleren"
directory_check="Bestaan van folder controleren"
else
empty="Empty submission"
run_fail="Nextflow run failed"
file_not_found="File not found"
dir_not_found="Directory not found"
file_check="Checking file existence"
directory_check="Checking directory existence"
fi
echo '{ "command": "start-judgement" }'
echo "{ \"command\": \"start-tab\", \"title\": \"$title\" }"
if [ -s "$file" ]; then
linter_out=$(mktemp)
nextflow-linter -report="json:$linter_out" -rulesetfiles=rulesets/general.xml -sourcefiles="$file" > /dev/null
jq --compact-output --monochrome-output '.packages[].files[].violations[] | .command = "annotate-code" | .column = 0 | .row = .lineNumber | .text = .message | .type = if .priority == 1 then "error" elif .priority == 2 then "warning" else "info" end | del(.ruleName, .priority, .lineNumber, .sourceLine, .message)' "$linter_out"
rm "$linter_out"
if [ -d "$resources/bin" ]; then
export PATH="$resources/bin:$PATH"
fi
if ! err=$(nextflow -quiet run "$file" $nextflow_arguments); then
# strip out submission filename
err=$(echo "$err" | sed "s|$file|<code>|")
# annotate code with the error if possible
echo "$err" \
| sed -nE 's/^.+cause: ([^"]+) @ line ([0-9]+), column ([0-9]+).+$/{ "text": "\1", "row": \2, "column": \3 }/p' \
| jq '. | .command = "annotate-code" | .row -=1 | .type = "error"'
jq --null-input --compact-output --monochrome-output \
--arg description "$err" \
'{ "command": "append-message", "message": { "format": "callout-danger", "description": $description } }'
echo "{ \"command\": \"escalate-status\", \"status\": { \"enum\": \"wrong\", \"human\": \"$run_fail\" } }"
fi
filename="$resources/files.json"
if [ -f "$filename" ]; then
echo '{ "command": "close-tab" }'
echo "{ \"command\": \"start-tab\", \"title\": \"Files\" }"
jq --compact-output '.[]' "$filename" | while read -r fileinfo; do
type=$(echo "$fileinfo" | jq -r '."type"')
path="$workdir/$(echo "$fileinfo" | jq -r '."path"')"
echo '{ "command": "start-context" }'
if [ "$type" = "file" ]; then
echo "{ \"command\": \"start-testcase\", \"description\": \"$file_check\" }"
echo "{ \"command\": \"start-test\", \"expected\": \"$path\" }"
if [ -f "$path" ]; then
echo "{ \"command\": \"close-test\", \"generated\": \"$path\", \"status\": { \"enum\": \"correct\" } }"
else
echo "{ \"command\": \"close-test\", \"generated\": \"\", \"status\": { \"enum\": \"wrong\", \"human\": \"$file_not_found\" } }"
fi
echo '{ "command": "close-testcase" }'
elif [ "$type" = "directory" ]; then
echo "{ \"command\": \"start-testcase\", \"description\": \"$directory_check\" }"
echo "{ \"command\": \"start-test\", \"expected\": \"$path\" }"
if [ -d "$path" ]; then
echo "{ \"command\": \"close-test\", \"generated\": \"$path\", \"status\": { \"enum\": \"correct\" } }"
else
echo "{ \"command\": \"close-test\", \"generated\": \"\", \"status\": { \"enum\": \"wrong\", \"human\": \"$dir_not_found\" } }"
fi
echo '{ "command": "close-testcase" }'
fi
echo '{ "command": "close-context" }'
done
fi
else
echo "{ \"command\": \"escalate-status\", \"status\": { \"enum\": \"wrong\", \"human\": \"$empty\" } } "
fi
echo '{ "command": "close-tab" }'
echo '{ "command": "close-judgement" }'