Return non-zero from CDash reporter when errors are detected (#22962)

This commit is contained in:
Zack Galbreath 2021-04-15 17:11:08 -04:00 committed by GitHub
parent e8454e498a
commit 080d9b094f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,6 +22,7 @@
import spack.build_environment import spack.build_environment
import spack.fetch_strategy import spack.fetch_strategy
import spack.package import spack.package
from spack.error import SpackError
from spack.reporter import Reporter from spack.reporter import Reporter
from spack.util.crypto import checksum from spack.util.crypto import checksum
from spack.util.executable import which from spack.util.executable import which
@ -60,6 +61,7 @@ class CDash(Reporter):
def __init__(self, args): def __init__(self, args):
Reporter.__init__(self, args) Reporter.__init__(self, args)
tty.set_verbose(args.verbose) tty.set_verbose(args.verbose)
self.success = True
self.template_dir = os.path.join('reports', 'cdash') self.template_dir = os.path.join('reports', 'cdash')
self.cdash_upload_url = args.cdash_upload_url self.cdash_upload_url = args.cdash_upload_url
@ -166,6 +168,7 @@ def build_report_for_package(self, directory_name, package, duration):
if phase == 'configure' and nerrors > 0: if phase == 'configure' and nerrors > 0:
report_data[phase]['status'] = 1 report_data[phase]['status'] = 1
self.success = False
if phase == 'build': if phase == 'build':
# Convert log output from ASCII to Unicode and escape for XML. # Convert log output from ASCII to Unicode and escape for XML.
@ -190,6 +193,8 @@ def clean_log_event(event):
if package['result'] == 'success': if package['result'] == 'success':
warnings = errors + warnings warnings = errors + warnings
errors = [] errors = []
else:
self.success = False
report_data[phase]['errors'] = [] report_data[phase]['errors'] = []
report_data[phase]['warnings'] = [] report_data[phase]['warnings'] = []
@ -254,7 +259,7 @@ def build_report(self, directory_name, input_data):
for package in spec['packages']: for package in spec['packages']:
self.build_report_for_package( self.build_report_for_package(
directory_name, package, duration) directory_name, package, duration)
self.print_cdash_link() self.finalize_report()
def test_report_for_package(self, directory_name, package, duration): def test_report_for_package(self, directory_name, package, duration):
if 'stdout' not in package: if 'stdout' not in package:
@ -360,7 +365,7 @@ def test_report(self, directory_name, input_data):
for package in spec['packages']: for package in spec['packages']:
self.test_report_for_package( self.test_report_for_package(
directory_name, package, duration) directory_name, package, duration)
self.print_cdash_link() self.finalize_report()
def concretization_report(self, directory_name, msg): def concretization_report(self, directory_name, msg):
self.buildname = self.base_buildname self.buildname = self.base_buildname
@ -381,7 +386,8 @@ def concretization_report(self, directory_name, msg):
# errors so refer to this report with the base buildname instead. # errors so refer to this report with the base buildname instead.
self.current_package_name = self.base_buildname self.current_package_name = self.base_buildname
self.upload(output_filename) self.upload(output_filename)
self.print_cdash_link() self.success = False
self.finalize_report()
def initialize_report(self, directory_name): def initialize_report(self, directory_name):
if not os.path.exists(directory_name): if not os.path.exists(directory_name):
@ -430,7 +436,7 @@ def upload(self, filename):
buildid = match.group(1) buildid = match.group(1)
self.buildIds[self.current_package_name] = buildid self.buildIds[self.current_package_name] = buildid
def print_cdash_link(self): def finalize_report(self):
if self.buildIds: if self.buildIds:
print("View your build results here:") print("View your build results here:")
for package_name, buildid in iteritems(self.buildIds): for package_name, buildid in iteritems(self.buildIds):
@ -440,3 +446,5 @@ def print_cdash_link(self):
build_url = build_url[0:build_url.find("submit.php")] build_url = build_url[0:build_url.find("submit.php")]
build_url += "buildSummary.php?buildid={0}".format(buildid) build_url += "buildSummary.php?buildid={0}".format(buildid)
print("{0}: {1}".format(package_name, build_url)) print("{0}: {1}".format(package_name, build_url))
if not self.success:
raise SpackError("Errors encountered, see above for more details")