def process_results(commit_id, returncode, results_dir, output): msg = "\n\nFull test results can be found here: %s" % os.path.join(APP_URL, 'hosts', commit_id) doc_host = None for host in os.listdir(results_dir): try: with open(os.path.join(results_dir, host, 'run.out'), 'r') as f: results = f.read() passes, fails, skips, elapsed_time = parse_test_output(results) model.new_test(commit_id, results, host, passes=passes, fails=fails, skips=skips, elapsed_time=elapsed_time) if returncode == 0 and os.path.isfile(os.path.join(results_dir, host, 'html.tar.gz')): doc_host = host except Exception as err: model.new_test(commit_id, str(err), host) try: if returncode == 0: docout, returncode = push_docs(commit_id, doc_host) # update the dev docs if the tests passed if doc_host is None: docout = '\n\nReturn code was 0 but dev docs were not built???\n' else: docout = '\n\nDev docs built successfully on host %s\n' % doc_host else: docout = "\n\nDev docs were not built\n" model.new_doc_info(commit_id, docout) except Exception as err: returncode = -1 docout = str(err) send_mail(commit_id, returncode, output+docout+msg)
def process_results(commit_id, returncode, results_dir, output): msg = "\n\nFull test results can be found here: %s" % os.path.join(APP_URL, 'hosts', commit_id) doc_host = None hosts_failed = 0 hosts_skipped = 0 for host in os.listdir(results_dir): try: with open(os.path.join(results_dir, host, 'run.out'), 'r') as f: results = f.read() passes, fails, skips, elapsed_time = parse_test_output(results) model.new_test(commit_id, zlib.compress(results, 9), host, passes=passes, fails=fails, skips=skips, elapsed_time=elapsed_time) if fails > 0: hosts_failed +=1 elif fails==0 and passes==0 and skips==0: hosts_skipped += 1 if os.path.isfile(os.path.join(results_dir, host, 'html.tar.gz')): doc_host = host except Exception as err: model.new_test(commit_id, str(err), host) try: docout, returncode = push_docs(commit_id, doc_host) # update the dev docs if the tests passed if doc_host is None: docout = '\n\nDev docs were not built due to lack of host specified.\n' else: docout = '\n\nDev docs built successfully on host %s\n' % doc_host except Exception as err: returncode = -1 docout = str(err) passed_all = -1 if hosts_failed > 0 or hosts_skipped > 0: msg += "\n----------TESTING FAILED!----------" passed_all = 1 else: msg += "\n++++++++++TESTING SUCCEEDED!+++++++++" passed_all = 0 msg += "\nHosts failed: %s" % hosts_failed msg += "\nHosts that didn't launch: %s" % hosts_skipped msg += "\n" #Integrate test results to POST into a slack channel. import requests url = "https://openmdao.slack.com/services/hooks/incoming-webhook?token=hDJ2XPGqNj69P47il5rpekUV" status = 'TESTS SUCCEEDED: ' if passed_all == 0 else 'TESTS FAILED: ' slack_msg = status+msg payload = {"text":slack_msg} r = requests.post(url, data=json.dumps(payload)) #Still send mail, may remove this later, and just use Slack send_mail(commit_id, passed_all, output+docout+msg)