in bot/code_review_bot/workflow.py [0:0]
def ingest_revision(self, revision, group_id):
"""
Simpler workflow to ingest a revision
"""
assert revision.head_repository in (
REPO_AUTOLAND,
REPO_MOZILLA_CENTRAL,
), "Need a revision from autoland or mozilla-central"
logger.info(
"Starting revision ingestion",
bugzilla=revision.bugzilla_id,
title=revision.title,
head_repository=revision.head_repository,
head_changeset=revision.head_changeset,
)
assert (
self.backend_api.enabled
), "Backend storage is disabled, revision ingestion is not possible"
supported_tasks = []
def _build_tasks(tasks):
for task_status in tasks["tasks"]:
try:
task_name = task_status["task"]["metadata"]["name"]
# Only analyze tasks stating with `source-test-` to avoid checking artifacts every time
if not task_name.startswith("source-test-"):
logger.debug(
f"Task with name '{task_name}' is not supported during the ingestion of a revision"
)
continue
task = self.build_task(task_status)
except Exception as e:
logger.warning(f"Could not proceed task {task_name}: {e}")
continue
if task is None or getattr(task, "parse_issues", None) is None:
# Do ignore tasks that cannot be parsed as issues
continue
supported_tasks.append(task)
# Find potential issues in the task group
self.queue_service.listTaskGroup(group_id, paginationHandler=_build_tasks)
logger.info(
"Loaded all supported tasks in the task group",
group_id=group_id,
nb=len(supported_tasks),
)
# Load all the artifacts and potential issues
issues = []
for task in supported_tasks:
artifacts = task.load_artifacts(self.queue_service)
if artifacts is not None:
task_issues = task.parse_issues(artifacts, revision)
logger.info(
f"Found {len(task_issues)} issues",
task=task.name,
id=task.id,
)
issues += task_issues
# Store the revision & diff in the backend
self.backend_api.publish_revision(revision)
# Publish issues when there are some
if not issues:
logger.info("No issues for that revision")
return
# Clone local repo when required
self.clone_repository(revision)
# Publish issues in the backend
self.backend_api.publish_issues(issues, revision)