зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1563090 - Fetch visual metrics task definition from a template r=nalexander,tomprince,ahal
The `./mach try {fuzzy,chooser}` commands now support a `--visual-metrics-jobs` option which can be used to pass the job descriptions to the visual-metrics task. Differential Revision: https://phabricator.services.mozilla.com/D41878 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
1ab6ec337d
Коммит
a9de9d21e2
|
@ -10,6 +10,7 @@ kind-dependencies:
|
|||
transforms:
|
||||
- taskgraph.transforms.job:transforms
|
||||
- taskgraph.transforms.task:transforms
|
||||
- taskgraph.transforms.visual_metrics:transforms
|
||||
|
||||
jobs:
|
||||
visual-metrics:
|
||||
|
|
|
@ -58,6 +58,8 @@ class Job:
|
|||
video_url = attr.ib(type=str)
|
||||
|
||||
|
||||
# NB: Keep in sync with try_task_config_schema in
|
||||
# taskcluster/taskgraph.decision.py
|
||||
#: The schema for validating jobs.
|
||||
JOB_SCHEMA = Schema(
|
||||
{
|
||||
|
|
|
@ -27,7 +27,7 @@ from .util.schema import validate_schema, Schema
|
|||
from .util.taskcluster import get_artifact
|
||||
from .util.taskgraph import find_decision_task, find_existing_tasks_from_previous_kinds
|
||||
from .util.yaml import load_yaml
|
||||
from voluptuous import Required, Optional
|
||||
from voluptuous import Required, Optional, Url
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
@ -117,11 +117,22 @@ PER_PROJECT_PARAMETERS = {
|
|||
}
|
||||
}
|
||||
|
||||
visual_metrics_jobs_schema = Schema({
|
||||
Required('jobs'): [
|
||||
{
|
||||
Required('browsertime_json_url'): Url(),
|
||||
Required('video_url'): Url(),
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
try_task_config_schema = Schema({
|
||||
Required('tasks'): [basestring],
|
||||
Optional('templates'): {basestring: object},
|
||||
Optional('disable-pgo'): bool,
|
||||
Optional('browsertime'): bool,
|
||||
# Keep in sync with JOB_SCHEMA in taskcluster/docker/visual-metrics/run-visual-metrics.py.
|
||||
Optional('visual-metrics-jobs'): visual_metrics_jobs_schema,
|
||||
})
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# 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/.
|
||||
"""
|
||||
These transformations take a task description for a visual metrics task and
|
||||
add the necessary environment variables to run on the given inputs.
|
||||
"""
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import json
|
||||
|
||||
from taskgraph.transforms.base import TransformSequence
|
||||
|
||||
transforms = TransformSequence()
|
||||
|
||||
|
||||
@transforms.add
|
||||
def set_visual_metrics_jobs(config, jobs):
|
||||
"""Set the visual metrics configuration for the given jobs."""
|
||||
vismet_jobs = config.params['try_task_config'].get('visual-metrics-jobs')
|
||||
|
||||
if vismet_jobs:
|
||||
vismet_jobs = json.dumps(vismet_jobs)
|
||||
|
||||
for job in jobs:
|
||||
if vismet_jobs:
|
||||
job['task']['payload'].setdefault('env', {}).update(
|
||||
VISUAL_METRICS_JOBS_JSON=vismet_jobs)
|
||||
|
||||
yield job
|
|
@ -129,6 +129,7 @@ def resolve_keyed_by(item, field, item_name, **extra_values):
|
|||
WHITELISTED_SCHEMA_IDENTIFIERS = [
|
||||
# upstream-artifacts are handed directly to scriptWorker, which expects interCaps
|
||||
lambda path: "[u'upstream-artifacts']" in path,
|
||||
lambda path: "[u'browsertime_json_url']" in path or "[u'video_url']" in path,
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ class ChooserParser(BaseTryParser):
|
|||
'gecko-profile',
|
||||
'path',
|
||||
'rebuild',
|
||||
'visual-metrics-jobs',
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -130,6 +130,7 @@ class FuzzyParser(BaseTryParser):
|
|||
'gecko-profile',
|
||||
'path',
|
||||
'rebuild',
|
||||
'visual-metrics-jobs',
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -14,8 +14,11 @@ import os
|
|||
import sys
|
||||
from abc import ABCMeta, abstractmethod, abstractproperty
|
||||
from argparse import Action, SUPPRESS
|
||||
from textwrap import dedent
|
||||
|
||||
import mozpack.path as mozpath
|
||||
import voluptuous
|
||||
from taskgraph.decision import visual_metrics_jobs_schema
|
||||
from mozbuild.base import BuildEnvironmentNotFoundException, MozbuildObject
|
||||
from .tasks import resolve_tests_by_suite
|
||||
|
||||
|
@ -251,6 +254,62 @@ class DisablePgo(TryConfig):
|
|||
}
|
||||
|
||||
|
||||
visual_metrics_jobs_description = dedent("""\
|
||||
The file should be a JSON file of the format:
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"browsertime_json_url": "http://example.com/browsertime.json",
|
||||
"video_url": "http://example.com/video.mp4"
|
||||
}
|
||||
]
|
||||
}
|
||||
""")
|
||||
|
||||
|
||||
class VisualMetricsJobs(TryConfig):
|
||||
|
||||
arguments = [
|
||||
[['--visual-metrics-jobs'],
|
||||
{'dest': 'visual_metrics_jobs',
|
||||
'metavar': 'PATH',
|
||||
'help': (
|
||||
'The path to a visual metrics jobs file. Only required when '
|
||||
'running a "visual-metrics" job.\n'
|
||||
'%s' % visual_metrics_jobs_description
|
||||
)}],
|
||||
]
|
||||
|
||||
def try_config(self, **kwargs):
|
||||
file_path = kwargs.get('visual_metrics_jobs')
|
||||
|
||||
if not file_path:
|
||||
return None
|
||||
|
||||
try:
|
||||
with open(file_path) as f:
|
||||
visual_metrics_jobs = json.load(f)
|
||||
|
||||
visual_metrics_jobs_schema(visual_metrics_jobs)
|
||||
except (IOError, OSError) as e:
|
||||
print('Failed to read file %s: %s' % (file_path, f))
|
||||
sys.exit(1)
|
||||
except TypeError:
|
||||
print('Failed to parse file %s as JSON: %s' % (file_path, f))
|
||||
sys.exit(1)
|
||||
except voluptuous.Error as e:
|
||||
print(
|
||||
'The file %s does not match the expected format: %s\n'
|
||||
'%s'
|
||||
% (file_path, e, visual_metrics_jobs_description)
|
||||
)
|
||||
sys.exit(1)
|
||||
|
||||
return {
|
||||
'visual-metrics-jobs': visual_metrics_jobs,
|
||||
}
|
||||
|
||||
|
||||
all_templates = {
|
||||
'artifact': Artifact,
|
||||
'browsertime': Browsertime,
|
||||
|
@ -260,4 +319,5 @@ all_templates = {
|
|||
'gecko-profile': GeckoProfile,
|
||||
'path': Path,
|
||||
'rebuild': Rebuild,
|
||||
'visual-metrics-jobs': VisualMetricsJobs,
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче