Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: appengine/findit/waterfall/identify_culprit_pipeline.py

Issue 2302223002: [Findit] Change the criteria of sending notification to code review. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging
5 6
6 from common import time_util 7 from common import time_util
7 from common.pipeline_wrapper import BasePipeline 8 from common.pipeline_wrapper import BasePipeline
8 from model import result_status 9 from model import result_status
9 from model import analysis_status 10 from model import analysis_status
10 from model.wf_analysis import WfAnalysis 11 from model.wf_analysis import WfAnalysis
11 from waterfall import build_failure_analysis 12 from waterfall import build_failure_analysis
13 from waterfall.send_notification_for_culprit_pipeline import (
14 SendNotificationForCulpritPipeline)
12 15
13 16
14 def _GetResultAnalysisStatus(analysis_result): 17 def _GetResultAnalysisStatus(analysis_result):
15 """Returns the status of the analysis result. 18 """Returns the status of the analysis result.
16 19
17 We can decide the status based on: 20 We can decide the status based on:
18 1. whether we found any suspected CL(s). 21 1. whether we found any suspected CL(s).
19 2. whether we have triaged the failure. 22 2. whether we have triaged the failure.
20 3. whether our analysis result is the same as triaged result. 23 3. whether our analysis result is the same as triaged result.
21 """ 24 """
(...skipping 21 matching lines...) Expand all
43 'repo_name': suspected_cl['repo_name'], 46 'repo_name': suspected_cl['repo_name'],
44 'revision': suspected_cl['revision'], 47 'revision': suspected_cl['revision'],
45 'commit_position': suspected_cl['commit_position'], 48 'commit_position': suspected_cl['commit_position'],
46 'url': suspected_cl['url'] 49 'url': suspected_cl['url']
47 } 50 }
48 if cl_info not in suspected_cls: 51 if cl_info not in suspected_cls:
49 suspected_cls.append(cl_info) 52 suspected_cls.append(cl_info)
50 return suspected_cls 53 return suspected_cls
51 54
52 55
56 def _GetSuspectedCLFoundByHeuristicForCompile(analysis):
57 """For compile failure, gets the suspected revision found by heuristic."""
58 if not analysis or not analysis.result:
59 return None
60 for failure in analysis.result.get('failures', []):
61 if (failure['step_name'].lower() == 'compile' and
62 len(failure['suspected_cls']) == 1):
63 # Based on confidence calculation, suspected_cl found by heuristic for
64 # compile is very likely to be the culprit.
65 # Since the current confidence calculation is for results with single
66 # suspected_cl, we might need to have the same regulation here.
67 return failure['suspected_cls'][0]
68 return None
69
70
71 def _NotifyCompileCulprits(
lijeffrey 2016/09/02 06:37:34 nit: Since this is for compile, shouldn't there on
chanli 2016/09/02 16:57:19 The changes on identify_culprit_pipeline has been
72 master_name, builder_name, build_number, analysis):
73 """Notifies code review if found a culprit for compile failure."""
74 suspect_cl_for_compile = _GetSuspectedCLFoundByHeuristicForCompile(analysis)
75 if not suspect_cl_for_compile:
76 return
77
78 try:
79 pipeline = SendNotificationForCulpritPipeline(
80 master_name, builder_name, build_number,
81 suspect_cl_for_compile['repo_name'],
82 suspect_cl_for_compile['revision'])
83 pipeline.start()
84 except Exception: # pragma: no cover.
85 logging.exception(
86 'Failed to notify culprits found by heuristic for compile.')
87
88
53 class IdentifyCulpritPipeline(BasePipeline): 89 class IdentifyCulpritPipeline(BasePipeline):
54 """A pipeline to identify culprit CLs for a build failure.""" 90 """A pipeline to identify culprit CLs for a build failure."""
55 91
56 # Arguments number differs from overridden method - pylint: disable=W0221 92 # Arguments number differs from overridden method - pylint: disable=W0221
57 def run(self, failure_info, change_logs, deps_info, signals, build_completed): 93 def run(self, failure_info, change_logs, deps_info, signals, build_completed):
58 """Identifies culprit CL. 94 """Identifies culprit CL.
59 95
60 Args: 96 Args:
61 failure_info (dict): Output of pipeline DetectFirstFailurePipeline. 97 failure_info (dict): Output of pipeline DetectFirstFailurePipeline.
62 change_logs (dict): Output of pipeline PullChangelogPipeline. 98 change_logs (dict): Output of pipeline PullChangelogPipeline.
(...skipping 11 matching lines...) Expand all
74 failure_info, change_logs, deps_info, signals) 110 failure_info, change_logs, deps_info, signals)
75 analysis = WfAnalysis.Get(master_name, builder_name, build_number) 111 analysis = WfAnalysis.Get(master_name, builder_name, build_number)
76 analysis.build_completed = build_completed 112 analysis.build_completed = build_completed
77 analysis.result = analysis_result 113 analysis.result = analysis_result
78 analysis.status = analysis_status.COMPLETED 114 analysis.status = analysis_status.COMPLETED
79 analysis.result_status = _GetResultAnalysisStatus(analysis_result) 115 analysis.result_status = _GetResultAnalysisStatus(analysis_result)
80 analysis.suspected_cls = _GetSuspectedCLs(analysis_result) 116 analysis.suspected_cls = _GetSuspectedCLs(analysis_result)
81 analysis.end_time = time_util.GetUTCNow() 117 analysis.end_time = time_util.GetUTCNow()
82 analysis.put() 118 analysis.put()
83 119
84 return analysis_result 120 _NotifyCompileCulprits(
121 master_name, builder_name, build_number, analysis)
122
123 return analysis_result
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698