Skip to content

Commit

Permalink
Upload crash artifacts per target by its name. (google#6660)
Browse files Browse the repository at this point in the history
Rather than always upload to the "current" artifact.
  • Loading branch information
oliverchang authored Oct 27, 2021
1 parent f460c03 commit d951635
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions infra/cifuzz/clusterfuzz_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,6 @@ def _get_corpus_name(self, target_name): # pylint: disable=no-self-use
"""Returns the name of the corpus artifact."""
return target_name

def _get_crashes_artifact_name(self): # pylint: disable=no-self-use
"""Returns the name of the crashes artifact."""
return 'current'

def upload_corpus(self, target_name, corpus_dir, replace=False):
"""Upload the corpus produced by |target_name|."""
logging.info('Uploading corpus in %s for %s.', corpus_dir, target_name)
Expand All @@ -177,19 +173,24 @@ def upload_build(self, commit):

def upload_crashes(self):
"""Uploads crashes."""
if not os.listdir(self.workspace.artifacts):
artifact_dirs = os.listdir(self.workspace.artifacts)
if not artifact_dirs:
logging.info('No crashes in %s. Not uploading.', self.workspace.artifacts)
return

crashes_artifact_name = self._get_crashes_artifact_name()
for crash_target in artifact_dirs:
artifact_dir = os.path.join(self.workspace.artifacts, crash_target)
if not os.path.isdir(artifact_dir):
logging.warning('%s is not an expected artifact directory, skipping.',
crash_target)
continue

logging.info('Uploading crashes in %s.', self.workspace.artifacts)
try:
self.filestore.upload_crashes(crashes_artifact_name,
self.workspace.artifacts)
logging.info('Done uploading crashes.')
except Exception as error: # pylint: disable=broad-except
logging.error('Failed to upload crashes. Error: %s', error)
logging.info('Uploading crashes in %s.', artifact_dir)
try:
self.filestore.upload_crashes(crash_target, artifact_dir)
logging.info('Done uploading crashes.')
except Exception as error: # pylint: disable=broad-except
logging.error('Failed to upload crashes. Error: %s', error)

def upload_coverage(self):
"""Uploads the coverage report to the filestore."""
Expand Down

0 comments on commit d951635

Please sign in to comment.