Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

Commit

Permalink
staticanalysis/bot: Do not update build status when phabricator repor…
Browse files Browse the repository at this point in the history
…ter is disabled (#2049)
  • Loading branch information
Bastien Abadie authored Apr 24, 2019
1 parent db2a4d9 commit 7019711
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/staticanalysis/bot/static_analysis_bot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,22 @@ def main(id,
)

# Load Phabricator API
phabricator_reporting_enabled = 'phabricator' in reporters
phabricator_api = PhabricatorAPI(phabricator['api_key'], phabricator['url'])
if 'phabricator' in reporters:
if phabricator_reporting_enabled:
reporters['phabricator'].setup_api(phabricator_api)

# Load unique revision
if settings.source == SOURCE_PHABRICATOR:
revision = PhabricatorRevision(phabricator_api, diff_phid=id)
elif settings.source == SOURCE_TRY:
revision = PhabricatorRevision(phabricator_api, try_task=queue_service.task(settings.try_task_id))
revision = PhabricatorRevision(
phabricator_api,
try_task=queue_service.task(settings.try_task_id),

# Update build status only when phabricator reporting is enabled
update_build=phabricator_reporting_enabled,
)
else:
raise Exception('Unsupported source {}'.format(settings.source))

Expand Down
7 changes: 6 additions & 1 deletion src/staticanalysis/bot/static_analysis_bot/revisions.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,13 @@ class PhabricatorRevision(Revision):
diff_phid = None
build_target_phid = None

def __init__(self, api, diff_phid=None, try_task=None):
def __init__(self, api, diff_phid=None, try_task=None, update_build=True):
super().__init__()
assert isinstance(api, PhabricatorAPI)
assert (diff_phid is not None) ^ (try_task is not None)
self.api = api
self.mercurial_revision = None
self.update_build = update_build

if diff_phid is not None:
# Load directly from the diff phid
Expand Down Expand Up @@ -286,6 +287,10 @@ def update_status(self, state, lint_issues=[]):
logger.info('No build target found, skipping HarborMaster update', state=state.value)
return

if not self.update_build:
logger.info('Update build disabled, skipping HarborMaster update', state=state.value)
return

self.api.update_build_target(
self.build_target_phid,
state,
Expand Down

0 comments on commit 7019711

Please sign in to comment.