##// END OF EJS Templates
Handle testing unmergeable pull requests.
Thomas Kluyver -
Show More
@@ -82,13 +82,18 b' def get_missing_libraries(log):'
82 if m:
82 if m:
83 return m.group(1)
83 return m.group(1)
84
84
85 def merge_branch(repo, branch, owner):
85 def get_branch(repo, branch, owner, mergeable):
86 merged_branch = "%s-%s" % (owner, branch)
87 os.chdir(repodir)
86 os.chdir(repodir)
88 # Delete the branch first
87 if mergeable:
89 call(['git', 'branch', '-D', merged_branch])
88 merged_branch = "%s-%s" % (owner, branch)
90 check_call(['git', 'checkout', '-b', merged_branch])
89 # Delete the branch first
91 check_call(['git', 'pull', repo, branch])
90 call(['git', 'branch', '-D', merged_branch])
91 check_call(['git', 'checkout', '-b', merged_branch])
92 check_call(['git', 'pull', repo, branch])
93 else:
94 # Fetch the branch without merging it.
95 check_call(['git', 'fetch', repo, branch])
96 check_call(['git', 'checkout', 'FETCH_HEAD'])
92 os.chdir(basedir)
97 os.chdir(basedir)
93
98
94 def run_tests(venv):
99 def run_tests(venv):
@@ -135,12 +140,16 b' def markdown_format(pr, results):'
135 s += " (libraries not available: " + missing_libraries + ")"
140 s += " (libraries not available: " + missing_libraries + ")"
136 return s
141 return s
137
142
138 lines = ["**Test results for commit %s merged into master**" % pr['head']['sha'][:7],
143 if pr['mergeable']:
144 com = pr['head']['sha'][:7] + " merged into master"
145 else:
146 com = pr['head']['sha'][:7] + " (can't merge cleanly)"
147 lines = ["**Test results for commit %s**" % com,
139 "Platform: " + sys.platform,
148 "Platform: " + sys.platform,
140 ""] + \
149 ""] + \
141 [format_result(*r) for r in results] + \
150 [format_result(*r) for r in results] + \
142 ["",
151 ["",
143 "Not available for testing:" + ", ".join(unavailable_pythons)]
152 "Not available for testing: " + ", ".join(unavailable_pythons)]
144 return "\n".join(lines)
153 return "\n".join(lines)
145
154
146 def post_results_comment(pr, results, num):
155 def post_results_comment(pr, results, num):
@@ -157,9 +166,11 b" if __name__ == '__main__':"
157 num = sys.argv[1]
166 num = sys.argv[1]
158 setup()
167 setup()
159 pr = get_pull_request(num)
168 pr = get_pull_request(num)
160 merge_branch(repo=pr['head']['repo']['clone_url'],
169 get_branch(repo=pr['head']['repo']['clone_url'],
161 branch=pr['head']['ref'],
170 branch=pr['head']['ref'],
162 owner=pr['head']['repo']['owner']['login'])
171 owner=pr['head']['repo']['owner']['login'],
172 mergeable=pr['mergeable'],
173 )
163
174
164 results = []
175 results = []
165 for py, venv in venvs:
176 for py, venv in venvs:
@@ -172,7 +183,10 b" if __name__ == '__main__':"
172 results.append((py, False, gist_url, missing_libraries))
183 results.append((py, False, gist_url, missing_libraries))
173
184
174 print("\n")
185 print("\n")
175 print("**Test results for commit %s merged into master**" % pr['head']['sha'][:7])
186 if pr['mergeable']:
187 print("**Test results for commit %s merged into master**" % pr['head']['sha'][:7])
188 else:
189 print("**Test results for commit %s (can't merge cleanly)**" % pr['head']['sha'][:7])
176 print("Platform:", sys.platform)
190 print("Platform:", sys.platform)
177 for py, passed, gist_url, missing_libraries in results:
191 for py, passed, gist_url, missing_libraries in results:
178 if passed:
192 if passed:
General Comments 0
You need to be logged in to leave comments. Login now