generated from wikipathways/wikipathways-curation-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
summarizeFails.groovy
58 lines (51 loc) · 1.93 KB
/
summarizeFails.groovy
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
import java.util.ArrayList
import java.util.List
import java.util.Map
import java.util.HashMap
import java.util.HashSet
import static groovy.io.FileType.FILES
Map testsWithDescription = new HashMap<>();
Map<String,List> failedTests = new HashMap<>();
def dir = new File("reports");
def files = [];
dir.traverse(type: FILES, maxDepth: 0) {
if (it.name.endsWith(".md") && !it.name.endsWith(".ng.md")) {
files.add(it)
}
};
files.each { file ->
wpid = file.name.split(".md")[0]
boolean fails = false
file.eachLine { line ->
if (line.startsWith("## Fails")) {
fails = true;
} else if (fails == true) {
if (line.startsWith("## ")) {
failedTest = line.substring(3)
pathways = failedTests.get(failedTest)
if (pathways == null) pathways = new ArrayList()
pathways.add(wpid)
failedTests.put(failedTest, pathways)
} else if (line.startsWith("More details at [https://www.wikipathways.org/WikiPathwaysCurator/")) {
link = line.substring(line.indexOf('[') + 1, line.indexOf(']'))
link = link.replace("https://www.wikipathways.org/WikiPathwaysCurator/", "")
testsWithDescription.put(failedTest, link)
}
}
}
}
println "<img style=\"float: right; width: 200px\" src=\"https://cms-assets.nporadio.nl/npo3fm/NPO-Serious-Request-Logo-Groen-Ik-Steun-RGB.png\" />"
println "# Validation Reports\n"
failedTests.keySet().sort().each { key ->
testname = key
println "## ${testname}\n"
if (testsWithDescription.containsKey(key)) {
descriptionURL = "https://www.wikipathways.org/WikiPathwaysCurator/" + testsWithDescription.get(key)
println "\nRead more about why these fails happen and how to fix them in these [instructions](${descriptionURL}).\n"
}
failedTests.get(key).sort().each { pathway ->
hashcode = key.replace(".", "").replace(" ","-").toLowerCase()
print "[${pathway}](reports/${pathway}#${hashcode}) "
}
println "\n"
}