-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgbResponse.py
58 lines (40 loc) · 2.63 KB
/
gbResponse.py
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 gbHelpers
import os
checkType = "geometryDataCheck"
ws = os.environ['GITHUB_WORKSPACE']
sha = os.environ['gitsha']
in_path = os.path.expanduser("~") + "/tmp/www.logs.geoboundaries.org/artifacts/" + sha + "/"
theUrl = "http://www.logs.geoboundaries.org/artifacts/" + sha + "/"
checkTypes = ["fileChecks", "geometryDataChecks", "metaChecks"]
responseText = "**Hello! I am the geoBoundary Bot**, and I just did an initial check on your submitted files. <br /><br />"
responseText = responseText + "I will automatically re-run my checks when you edit your Pull Request, and provide the new results in a comment just like this. <br />"
responseText = responseText + "Once all of your files meet my programmed standards, I will flag your file for a manual human review. <br />"
responseText = responseText + "=========== Submission Findings =========== <br /><br />"
#First, establish the overall finding, then report out the subfindings.
checkResults = {}
checkFailed = 0
for check in checkTypes:
with open(in_path + check + "/RESULT.txt", "r") as f:
checkResults[check] = f.read()
if(checkResults[check] != "PASSED"):
checkFailed = checkFailed + 1
else:
responseText = responseText + "[Full logs for " + str(check) + "](" + theUrl + str(check) + "/" + str(check) +".txt" + ") <br /><br />"
if(checkFailed > 0):
responseText = responseText + "**OVERALL STATUS**: " + str(checkFailed) + " checks are failing. I have some recommendations for you on how you might fix these. <br /><br />"
for check in checkTypes:
with open(in_path + check + "/RESULT.txt", "r") as f:
checkResults[check] = f.read()
if(checkResults[check] != "PASSED"):
responseText = responseText + "**" + str(check) + "**: " + checkResults[check] + " <br />"
else:
responseText = responseText + "**" + str(check) + "**: All checks PASSED. Nothing that needs to be done here right now. <br />"
responseText = responseText + "[Full logs for " + str(check) + "](" + theUrl + str(check) + "/" + str(check) +".txt" + ") <br /><br />"
responseText = responseText + "----- Preview ----- <br />"
responseText = responseText + " <br />"
else:
responseText = responseText + "All checks have passed! I'll flag your boundary submission for a manual review by one of my humans. <br />"
responseText = responseText + " <br />"
print(responseText)
with open(os.path.expanduser("~") + "/tmp/response.txt", "w") as f:
f.write(responseText)