Report current git commit of Spack to CDash
When using the CDash reporter, upload a Update.xml file that indicates the hash of Spack's current git commit.
This commit is contained in:
		 Zack Galbreath
					Zack Galbreath
				
			
				
					committed by
					
						 Todd Gamblin
						Todd Gamblin
					
				
			
			
				
	
			
			
			 Todd Gamblin
						Todd Gamblin
					
				
			
						parent
						
							7217b4a4b9
						
					
				
				
					commit
					8d0872083c
				
			| @@ -16,11 +16,13 @@ | |||||||
| from six.moves.urllib.request import build_opener, HTTPHandler, Request | from six.moves.urllib.request import build_opener, HTTPHandler, Request | ||||||
| from six.moves.urllib.parse import urlencode | from six.moves.urllib.parse import urlencode | ||||||
|  |  | ||||||
|  | from llnl.util.filesystem import working_dir | ||||||
| import spack.build_environment | import spack.build_environment | ||||||
| import spack.fetch_strategy | import spack.fetch_strategy | ||||||
| import spack.package | import spack.package | ||||||
| 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.log_parse import parse_log_events | from spack.util.log_parse import parse_log_events | ||||||
|  |  | ||||||
| __all__ = ['CDash'] | __all__ = ['CDash'] | ||||||
| @@ -37,6 +39,7 @@ | |||||||
|  |  | ||||||
| # Initialize data structures common to each phase's report. | # Initialize data structures common to each phase's report. | ||||||
| cdash_phases = set(map_phases_to_cdash.values()) | cdash_phases = set(map_phases_to_cdash.values()) | ||||||
|  | cdash_phases.add('update') | ||||||
|  |  | ||||||
|  |  | ||||||
| class CDash(Reporter): | class CDash(Reporter): | ||||||
| @@ -65,6 +68,10 @@ def __init__(self, args): | |||||||
|         self.buildstamp = time.strftime(buildstamp_format, |         self.buildstamp = time.strftime(buildstamp_format, | ||||||
|                                         time.localtime(self.starttime)) |                                         time.localtime(self.starttime)) | ||||||
|         self.buildId = None |         self.buildId = None | ||||||
|  |         self.revision = '' | ||||||
|  |         git = which('git') | ||||||
|  |         with working_dir(spack.paths.spack_root): | ||||||
|  |             self.revision = git('rev-parse', 'HEAD', output=str).strip() | ||||||
|  |  | ||||||
|     def build_report(self, filename, report_data): |     def build_report(self, filename, report_data): | ||||||
|         self.initialize_report(filename, report_data) |         self.initialize_report(filename, report_data) | ||||||
| @@ -105,6 +112,8 @@ def build_report(self, filename, report_data): | |||||||
|                             report_data[cdash_phase]['log'] += \ |                             report_data[cdash_phase]['log'] += \ | ||||||
|                                 xml.sax.saxutils.escape(line) + "\n" |                                 xml.sax.saxutils.escape(line) + "\n" | ||||||
|  |  | ||||||
|  |         phases_encountered.append('update') | ||||||
|  |  | ||||||
|         # Move the build phase to the front of the list if it occurred. |         # Move the build phase to the front of the list if it occurred. | ||||||
|         # This supports older versions of CDash that expect this phase |         # This supports older versions of CDash that expect this phase | ||||||
|         # to be reported before all others. |         # to be reported before all others. | ||||||
| @@ -147,12 +156,18 @@ def clean_log_event(event): | |||||||
|                     report_data[phase]['warnings'].append( |                     report_data[phase]['warnings'].append( | ||||||
|                         clean_log_event(warning)) |                         clean_log_event(warning)) | ||||||
|  |  | ||||||
|  |             if phase == 'update': | ||||||
|  |                 report_data[phase]['revision'] = self.revision | ||||||
|  |  | ||||||
|             # Write the report. |             # Write the report. | ||||||
|             report_name = phase.capitalize() + ".xml" |             report_name = phase.capitalize() + ".xml" | ||||||
|             phase_report = os.path.join(filename, report_name) |             phase_report = os.path.join(filename, report_name) | ||||||
|  |  | ||||||
|             with codecs.open(phase_report, 'w', 'utf-8') as f: |             with codecs.open(phase_report, 'w', 'utf-8') as f: | ||||||
|                 env = spack.tengine.make_environment() |                 env = spack.tengine.make_environment() | ||||||
|  |                 if phase != 'update': | ||||||
|  |                     # Update.xml stores site information differently | ||||||
|  |                     # than the rest of the CTest XML files. | ||||||
|                     site_template = os.path.join(self.template_dir, 'Site.xml') |                     site_template = os.path.join(self.template_dir, 'Site.xml') | ||||||
|                     t = env.get_template(site_template) |                     t = env.get_template(site_template) | ||||||
|                     f.write(t.render(report_data)) |                     f.write(t.render(report_data)) | ||||||
| @@ -166,9 +181,11 @@ def clean_log_event(event): | |||||||
|     def concretization_report(self, filename, msg): |     def concretization_report(self, filename, msg): | ||||||
|         report_data = {} |         report_data = {} | ||||||
|         self.initialize_report(filename, report_data) |         self.initialize_report(filename, report_data) | ||||||
|         report_data['starttime'] = self.starttime |         report_data['update'] = {} | ||||||
|         report_data['endtime'] = self.starttime |         report_data['update']['starttime'] = self.starttime | ||||||
|         report_data['msg'] = msg |         report_data['update']['endtime'] = self.starttime | ||||||
|  |         report_data['update']['revision'] = self.revision | ||||||
|  |         report_data['update']['log'] = msg | ||||||
|  |  | ||||||
|         env = spack.tengine.make_environment() |         env = spack.tengine.make_environment() | ||||||
|         update_template = os.path.join(self.template_dir, 'Update.xml') |         update_template = os.path.join(self.template_dir, 'Update.xml') | ||||||
|   | |||||||
| @@ -3,9 +3,12 @@ | |||||||
|   <Site>{{ site }}</Site> |   <Site>{{ site }}</Site> | ||||||
|   <BuildName>{{ buildname }}</BuildName> |   <BuildName>{{ buildname }}</BuildName> | ||||||
|   <BuildStamp>{{ buildstamp }}</BuildStamp> |   <BuildStamp>{{ buildstamp }}</BuildStamp> | ||||||
|   <StartTime>{{ starttime }}</StartTime> |   <StartTime>{{ update.starttime }}</StartTime> | ||||||
|   <EndTime>{{ endtime }}</EndTime> |   <UpdateCommand></UpdateCommand> | ||||||
| {% if msg %} |   <UpdateType>GIT</UpdateType> | ||||||
|   <UpdateReturnStatus>{{ msg }}</UpdateReturnStatus> |   <Revision>{{ update.revision }}</Revision> | ||||||
|  |   <EndTime>{{ update.endtime }}</EndTime> | ||||||
|  | {% if update.log %} | ||||||
|  |   <UpdateReturnStatus>{{ update.log }}</UpdateReturnStatus> | ||||||
| {% endif %} | {% endif %} | ||||||
| </Update> | </Update> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user