From aed9a532c6edb24f336aa8a5114ad465b22c318c Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Mon, 22 Oct 2018 11:29:39 -0400 Subject: Get buildId from CDash at submit time Pass extra data when submitting to CDash. If CDash responds with a buildId, construct and display helpful URL that links to the uploaded report. --- lib/spack/spack/reporters/cdash.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/reporters/cdash.py b/lib/spack/spack/reporters/cdash.py index 068f9275b7..2f74e4ec0d 100644 --- a/lib/spack/spack/reporters/cdash.py +++ b/lib/spack/spack/reporters/cdash.py @@ -63,6 +63,7 @@ class CDash(Reporter): buildstamp_format = "%Y%m%d-%H%M-{0}".format(args.cdash_track) self.buildstamp = time.strftime(buildstamp_format, time.localtime(self.starttime)) + self.buildId = None def build_report(self, filename, report_data): self.initialize_report(filename, report_data) @@ -159,6 +160,7 @@ class CDash(Reporter): t = env.get_template(phase_template) f.write(t.render(report_data)) self.upload(phase_report) + self.print_cdash_link() def concretization_report(self, filename, msg): report_data = {} @@ -174,6 +176,7 @@ class CDash(Reporter): with open(output_filename, 'w') as f: f.write(t.render(report_data)) self.upload(output_filename) + self.print_cdash_link() def initialize_report(self, filename, report_data): if not os.path.exists(filename): @@ -191,13 +194,29 @@ class CDash(Reporter): # Compute md5 checksum for the contents of this file. md5sum = checksum(hashlib.md5, filename, block_size=8192) + buildid_regexp = re.compile("([0-9]+)") opener = build_opener(HTTPHandler) with open(filename, 'rb') as f: - url = "{0}&MD5={1}".format(self.cdash_upload_url, md5sum) + url = "{0}&build={1}&site={2}&stamp={3}&MD5={4}".format( + self.cdash_upload_url, self.buildname, self.site, + self.buildstamp, md5sum) request = Request(url, data=f) request.add_header('Content-Type', 'text/xml') request.add_header('Content-Length', os.path.getsize(filename)) # By default, urllib2 only support GET and POST. # CDash needs expects this file to be uploaded via PUT. request.get_method = lambda: 'PUT' - url = opener.open(request) + response = opener.open(request) + if not self.buildId: + match = buildid_regexp.search(response.read()) + if match: + self.buildId = match.group(1) + + def print_cdash_link(self): + if self.buildId: + # Construct and display a helpful link if CDash responded with + # a buildId. + build_url = self.cdash_upload_url + build_url = build_url[0:build_url.find("submit.php")] + build_url += "buildSummary.php?buildid={0}".format(self.buildId) + print("View your build results here:\n {0}\n".format(build_url)) -- cgit v1.2.3-70-g09d2