зеркало из https://github.com/mozilla/bugbug.git
Assume there is only one testing tag per revision
This commit is contained in:
Родитель
c0095113be
Коммит
5cab40d5d2
|
@ -3,13 +3,16 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from typing import Collection, Iterator, List, NewType
|
||||
import logging
|
||||
from typing import Collection, Iterator, NewType, Optional
|
||||
|
||||
from libmozdata.phabricator import PhabricatorAPI
|
||||
from tqdm import tqdm
|
||||
|
||||
from bugbug import db
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
RevisionDict = NewType("RevisionDict", dict)
|
||||
|
||||
REVISIONS_DB = "data/revisions.json"
|
||||
|
@ -77,9 +80,17 @@ def download_revisions(rev_ids: Collection[int]) -> None:
|
|||
db.append(REVISIONS_DB, revisions)
|
||||
|
||||
|
||||
def get_testing_projects(rev: RevisionDict) -> List[str]:
|
||||
return [
|
||||
def get_testing_project(rev: RevisionDict) -> Optional[str]:
|
||||
testing_projects = [
|
||||
TESTING_PROJECTS[projectPHID]
|
||||
for projectPHID in rev["attachments"]["projects"]["projectPHIDs"]
|
||||
if projectPHID in TESTING_PROJECTS
|
||||
]
|
||||
|
||||
if len(testing_projects) > 1:
|
||||
logger.warning("Revision D{} has more than one testing tag.".format(rev["id"]))
|
||||
|
||||
if len(testing_projects) == 0:
|
||||
return None
|
||||
|
||||
return testing_projects[-1]
|
||||
|
|
|
@ -271,6 +271,25 @@ class LandingsRiskReportGenerator(object):
|
|||
# Evaluate risk of commits associated to this bug.
|
||||
probs = self.regressor_model.classify(commit_list, probabilities=True)
|
||||
|
||||
commits_data = []
|
||||
for i, commit in enumerate(commit_list):
|
||||
revision_id = repository.get_revision_id(commit)
|
||||
if revision_id in revision_map:
|
||||
testing = phabricator.get_testing_project(revision_map[revision_id])
|
||||
|
||||
if testing is None:
|
||||
testing = "none"
|
||||
else:
|
||||
testing = None
|
||||
|
||||
commits_data.append(
|
||||
{
|
||||
"id": commit["node"],
|
||||
"testing": testing,
|
||||
"risk": float(probs[i][1]),
|
||||
}
|
||||
)
|
||||
|
||||
commit_groups.append(
|
||||
{
|
||||
"id": bug_id,
|
||||
|
@ -279,18 +298,7 @@ class LandingsRiskReportGenerator(object):
|
|||
dateutil.parser.parse(commit["pushdate"])
|
||||
for commit in commit_list
|
||||
).strftime("%Y-%m-%d"),
|
||||
"commits": [
|
||||
{
|
||||
"id": commit["node"],
|
||||
"testing": phabricator.get_testing_projects(
|
||||
revision_map[repository.get_revision_id(commit)]
|
||||
)
|
||||
if repository.get_revision_id(commit) in revision_map
|
||||
else None,
|
||||
"risk": float(probs[i][1]),
|
||||
}
|
||||
for i, commit in enumerate(commit_list)
|
||||
],
|
||||
"commits": commits_data,
|
||||
"meta_ids": list(blocker_to_meta[bug_id]),
|
||||
"prev_regressions": prev_regressions[-3:],
|
||||
"prev_fixed_bugs": prev_fixed_bugs[-3:],
|
||||
|
|
|
@ -96,26 +96,26 @@ class TestingPolicyStatsGenerator(object):
|
|||
commits = [
|
||||
commit
|
||||
for commit in commits
|
||||
if len(
|
||||
phabricator.get_testing_projects(
|
||||
revision_map[repository.get_revision_id(commit)]
|
||||
)
|
||||
if phabricator.get_testing_project(
|
||||
revision_map[repository.get_revision_id(commit)]
|
||||
)
|
||||
> 0
|
||||
is not None
|
||||
]
|
||||
logger.info(f"{len(commits)} revisions with testing tags")
|
||||
|
||||
def list_testing_projects(
|
||||
commits: Iterable[repository.CommitDict],
|
||||
) -> Collection[str]:
|
||||
return sum(
|
||||
(
|
||||
phabricator.get_testing_projects(
|
||||
revision_map[repository.get_revision_id(commit)]
|
||||
)
|
||||
for commit in commits
|
||||
),
|
||||
[],
|
||||
return list(
|
||||
filter(
|
||||
None,
|
||||
(
|
||||
phabricator.get_testing_project(
|
||||
revision_map[repository.get_revision_id(commit)]
|
||||
)
|
||||
for commit in commits
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
testing_projects = list_testing_projects(commits)
|
||||
|
|
Загрузка…
Ссылка в новой задаче