Bug 1527895 - Add code-review-issues task in CI, r=dustin,marco,tomprince

Differential Revision: https://phabricator.services.mozilla.com/D21348

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Bastien Abadie 2019-03-04 19:40:11 +00:00
Родитель 5046835f49
Коммит d35753d1d9
10 изменённых файлов: 118 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,41 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
---
loader: taskgraph.loader.transform:loader
transforms:
- taskgraph.transforms.code_review:transforms
- taskgraph.transforms.job:transforms
- taskgraph.transforms.task:transforms
kind-dependencies:
- source-test
jobs:
issues:
label: code-review-issues
description: List all issues found in static analysis and linting tasks
worker-type: aws-provisioner-v1/gecko-{level}-b-linux
# Only run by using the code-review target_tasks_method
run-on-projects: []
# This option permits to run the task
# regardless of the soft-dependencies tasks exit status
# as we are interested in the task failures
requires: all-resolved
# Publish on pulse
routes:
- project.relman.codereview.v1.try_ending
# Dummy execution for now, we only need the pulse message
worker:
docker-image:
in-tree: debian9-amd64-build
max-run-time: 600
run:
using: run-task
checkout: false
command: /bin/true

Просмотреть файл

@ -1,5 +1,7 @@
job-defaults:
always-target: true
attributes:
code-review: true
treeherder:
kind: test
tier: 1

Просмотреть файл

@ -295,3 +295,10 @@ The update channel the build is configured to use.
openh264_rev
============
Only used for openh264 plugin builds, used to signify the revision (and thus inform artifact name) of the given build.
code-review
===========
If a task set this boolean attribute to `true`, it will be processed by the code
review bot, the task will ran for every new Phabricator diff.
Any supported and detected issue will be automatically reported on the
Phabricator revision.

Просмотреть файл

@ -61,6 +61,12 @@ unit tests, source-code analysis, or measurement work. While source-test tasks r
a source checkout, it is still possible for them to depend on a build artifact, though
often they do not.
code-review
-----------
Publish issues found by source-test tasks on Phabricator.
This is a part of Release Management code review Bot.
upload-symbols
--------------

Просмотреть файл

@ -194,3 +194,10 @@ them are specified, they must all be specified.
``comm_head_repository``
``comm_head_rev``
``comm_head_ref``
Code Review
-----------
``phabricator_diff``
The code review process needs to know the Phabricator Differential diff that
started the analysis. This parameter must start with `PHID-DIFF-`

Просмотреть файл

@ -236,6 +236,7 @@ def get_decision_parameters(config, options):
get_hg_commit_message(os.path.join(GECKO, product_dir)))
parameters['hg_branch'] = get_hg_revision_branch(GECKO, revision=parameters['head_rev'])
parameters['next_version'] = None
parameters['phabricator_diff'] = None
parameters['release_type'] = ''
parameters['release_eta'] = ''
parameters['release_enable_partners'] = False

Просмотреть файл

@ -68,6 +68,7 @@ PARAMETERS = {
'project': 'mozilla-central',
'pushdate': lambda: int(time.time()),
'pushlog_id': '0',
'phabricator_diff': None,
'release_enable_emefree': False,
'release_enable_partners': False,
'release_eta': '',

Просмотреть файл

@ -655,3 +655,21 @@ def target_tasks_release_simulation(full_task_graph, parameters, graph_config):
and filter_out_cron(t, parameters)
and filter_for_target_project(t)
and filter_out_android_on_esr(t)]
@_target_task('codereview')
def target_tasks_codereview(full_task_graph, parameters, graph_config):
"""Select all code review tasks needed to produce a report"""
def filter(task):
# Ending tasks
if task.kind in ['code-review']:
return True
# Analyzer tasks
if task.attributes.get('code-review') is True:
return True
return False
return [l for l, t in full_task_graph.tasks.iteritems() if filter(t)]

Просмотреть файл

@ -0,0 +1,34 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
"""
Add soft dependencies and configuration to code-review tasks.
"""
from __future__ import absolute_import, print_function, unicode_literals
from taskgraph.transforms.base import TransformSequence
transforms = TransformSequence()
@transforms.add
def add_dependencies(config, jobs):
for job in jobs:
job.setdefault('soft-dependencies', [])
job['soft-dependencies'] += [
dep_task.label
for dep_task in config.kind_dependencies_tasks
if dep_task.attributes.get('code-review') is True
]
yield job
@transforms.add
def add_phabricator_config(config, jobs):
for job in jobs:
diff = config.params.get('phabricator_diff')
if diff is not None:
code_review = job.setdefault('extra', {}).setdefault('code-review', {})
code_review['phabricator-diff'] = diff
yield job

Просмотреть файл

@ -49,6 +49,7 @@ job_description_schema = Schema({
Optional('job-from'): task_description_schema['job-from'],
Optional('dependencies'): task_description_schema['dependencies'],
Optional('soft-dependencies'): task_description_schema['soft-dependencies'],
Optional('requires'): task_description_schema['requires'],
Optional('expires-after'): task_description_schema['expires-after'],
Optional('routes'): task_description_schema['routes'],
Optional('scopes'): task_description_schema['scopes'],