Bug 1497860: [taskgraph] Ensure that mozharness actions don't contain spaces; r=Callek
Differential Revision:
https://phabricator.services.mozilla.com/D9444
--- a/taskcluster/taskgraph/transforms/job/mozharness.py
+++ b/taskcluster/taskgraph/transforms/job/mozharness.py
@@ -10,16 +10,17 @@ way, and certainly anything using mozhar
from __future__ import absolute_import, print_function, unicode_literals
import json
from textwrap import dedent
from taskgraph.util.schema import Schema
from voluptuous import Required, Optional, Any
+from voluptuous.validators import Match
from taskgraph.transforms.job import run_job_using
from taskgraph.transforms.job.common import (
docker_worker_add_workspace_cache,
docker_worker_setup_secrets,
docker_worker_add_artifacts,
docker_worker_add_tooltool,
generic_worker_add_artifacts,
@@ -39,20 +40,26 @@ mozharness_run_schema = Schema({
Optional('config-paths'): [basestring],
# the config files required for the task, relative to
# testing/mozharness/configs or one of the paths specified in
# `config-paths` and using forward slashes even on Windows
Required('config'): [basestring],
# any additional actions to pass to the mozharness command
- Optional('actions'): [basestring],
+ Optional('actions'): [Match(
+ '^[a-z0-9-]+$',
+ "actions must be `-` seperated alphanumeric strings"
+ )],
# any additional options (without leading --) to be passed to mozharness
- Optional('options'): [basestring],
+ Optional('options'): [Match(
+ '^[a-z0-9-]+(=[^ ]+)?$',
+ "options must be `-` seperated alphanumeric strings (with optional argument)"
+ )],
# --custom-build-variant-cfg value
Optional('custom-build-variant-cfg'): basestring,
# Extra configuration options to pass to mozharness.
Optional('extra-config'): dict,
# Extra metadata to use toward the workspace caching.
@@ -285,21 +292,19 @@ def mozharness_on_generic_worker(config,
r'.\build\src\{}'.format(path.replace('/', '\\')))
for cfg in run['config']:
mh_command.append('--config ' + cfg.replace('/', '\\'))
if run['use-magic-mh-args']:
mh_command.append('--branch ' + config.params['project'])
mh_command.append(r'--work-dir %cd:Z:=z:%\build')
for action in run.get('actions', []):
- assert ' ' not in action
mh_command.append('--' + action)
for option in run.get('options', []):
- assert ' ' not in option
mh_command.append('--' + option)
if run.get('custom-build-variant-cfg'):
mh_command.append('--custom-build-variant')
mh_command.append(run['custom-build-variant-cfg'])
hg_commands = generic_worker_hg_commands(
base_repo=env['GECKO_BASE_REPOSITORY'],
head_repo=env['GECKO_HEAD_REPOSITORY'],