2016-09-12 21:34:06 +03:00
|
|
|
# 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/.
|
|
|
|
"""
|
|
|
|
|
|
|
|
Support for running jobs via mozharness. Ideally, most stuff gets run this
|
|
|
|
way, and certainly anything using mozharness should use this approach.
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import absolute_import, print_function, unicode_literals
|
2017-05-02 22:12:51 +03:00
|
|
|
import slugid
|
2016-09-12 21:34:06 +03:00
|
|
|
|
2017-04-06 19:50:41 +03:00
|
|
|
from textwrap import dedent
|
|
|
|
|
2017-03-22 19:24:38 +03:00
|
|
|
from taskgraph.util.schema import Schema
|
|
|
|
from voluptuous import Required, Optional, Any
|
2016-09-12 21:34:06 +03:00
|
|
|
|
|
|
|
from taskgraph.transforms.job import run_job_using
|
|
|
|
from taskgraph.transforms.job.common import (
|
|
|
|
docker_worker_add_workspace_cache,
|
|
|
|
docker_worker_add_gecko_vcs_env_vars,
|
|
|
|
docker_worker_setup_secrets,
|
2016-09-30 02:51:15 +03:00
|
|
|
docker_worker_add_public_artifacts,
|
2017-07-17 22:40:57 +03:00
|
|
|
generic_worker_add_public_artifacts,
|
2017-03-04 01:49:23 +03:00
|
|
|
support_vcs_checkout,
|
2016-09-12 21:34:06 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
COALESCE_KEY = 'builds.{project}.{name}'
|
|
|
|
|
|
|
|
mozharness_run_schema = Schema({
|
|
|
|
Required('using'): 'mozharness',
|
|
|
|
|
|
|
|
# the mozharness script used to run this task, relative to the testing/
|
|
|
|
# directory and using forward slashes even on Windows
|
|
|
|
Required('script'): basestring,
|
|
|
|
|
|
|
|
# the config files required for the task, relative to
|
|
|
|
# testing/mozharness/configs and using forward slashes even on Windows
|
|
|
|
Required('config'): [basestring],
|
|
|
|
|
|
|
|
# any additional actions to pass to the mozharness command; not supported
|
|
|
|
# on Windows
|
|
|
|
Optional('actions'): [basestring],
|
|
|
|
|
|
|
|
# any additional options (without leading --) to be passed to mozharness;
|
|
|
|
# not supported on Windows
|
|
|
|
Optional('options'): [basestring],
|
|
|
|
|
|
|
|
# --custom-build-variant-cfg value (not supported on Windows)
|
|
|
|
Optional('custom-build-variant-cfg'): basestring,
|
|
|
|
|
2017-06-16 22:34:43 +03:00
|
|
|
# Extra metadata to use toward the workspace caching.
|
|
|
|
# Only supported on docker-worker
|
|
|
|
Optional('extra-workspace-cache-key'): basestring,
|
|
|
|
|
2016-09-12 21:34:06 +03:00
|
|
|
# If not false, tooltool downloads will be enabled via relengAPIProxy
|
|
|
|
# for either just public files, or all files. Not supported on Windows
|
|
|
|
Required('tooltool-downloads', default=False): Any(
|
|
|
|
False,
|
|
|
|
'public',
|
|
|
|
'internal',
|
|
|
|
),
|
|
|
|
|
|
|
|
# The set of secret names to which the task has access; these are prefixed
|
|
|
|
# with `project/releng/gecko/{treeherder.kind}/level-{level}/`. Setting
|
|
|
|
# this will enable any worker features required and set the task's scopes
|
|
|
|
# appropriately. `true` here means ['*'], all secrets. Not supported on
|
|
|
|
# Windows
|
|
|
|
Required('secrets', default=False): Any(bool, [basestring]),
|
|
|
|
|
|
|
|
# If true, taskcluster proxy will be enabled; note that it may also be enabled
|
|
|
|
# automatically e.g., for secrets support. Not supported on Windows.
|
|
|
|
Required('taskcluster-proxy', default=False): bool,
|
|
|
|
|
|
|
|
# If true, the build scripts will start Xvfb. Not supported on Windows.
|
|
|
|
Required('need-xvfb', default=False): bool,
|
|
|
|
|
|
|
|
# If false, indicate that builds should skip producing artifacts. Not
|
|
|
|
# supported on Windows.
|
|
|
|
Required('keep-artifacts', default=True): bool,
|
2016-10-10 22:01:28 +03:00
|
|
|
|
|
|
|
# If specified, use the in-tree job script specified.
|
|
|
|
Optional('job-script'): basestring,
|
2017-06-29 23:50:13 +03:00
|
|
|
|
|
|
|
Required('requires-signed-builds', default=False): bool,
|
2017-07-17 22:25:19 +03:00
|
|
|
|
|
|
|
# If false, don't set MOZ_SIMPLE_PACKAGE_NAME
|
2017-07-17 22:26:36 +03:00
|
|
|
# Only disableable on windows
|
2017-07-17 22:25:19 +03:00
|
|
|
Required('use-simple-package', default=True): bool,
|
2017-07-17 22:26:36 +03:00
|
|
|
|
|
|
|
# If false don't pass --branch or --skip-buildbot-actions to mozharness script
|
|
|
|
# Only disableable on windows
|
|
|
|
Required('use-magic-mh-args', default=True): bool,
|
2016-09-12 21:34:06 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
@run_job_using("docker-worker", "mozharness", schema=mozharness_run_schema)
|
|
|
|
def mozharness_on_docker_worker_setup(config, job, taskdesc):
|
|
|
|
run = job['run']
|
|
|
|
|
|
|
|
worker = taskdesc['worker']
|
|
|
|
worker['implementation'] = job['worker']['implementation']
|
|
|
|
|
2017-07-17 22:25:19 +03:00
|
|
|
if not run['use-simple-package']:
|
|
|
|
raise NotImplementedError("Simple packaging cannot be disabled via"
|
|
|
|
"'use-simple-package' on docker-workers")
|
2017-07-17 22:26:36 +03:00
|
|
|
if not run['use-magic-mh-args']:
|
|
|
|
raise NotImplementedError("Cannot disabled mh magic arg passing via"
|
|
|
|
"'use-magic-mh-args' on docker-workers")
|
2017-07-17 22:25:19 +03:00
|
|
|
|
2016-09-12 21:34:06 +03:00
|
|
|
# running via mozharness assumes desktop-build (which contains build.sh)
|
|
|
|
taskdesc['worker']['docker-image'] = {"in-tree": "desktop-build"}
|
|
|
|
|
|
|
|
worker['relengapi-proxy'] = False # but maybe enabled for tooltool below
|
|
|
|
worker['taskcluster-proxy'] = run.get('taskcluster-proxy')
|
|
|
|
|
|
|
|
docker_worker_add_public_artifacts(config, job, taskdesc)
|
2017-06-16 22:34:43 +03:00
|
|
|
docker_worker_add_workspace_cache(config, job, taskdesc,
|
|
|
|
extra=run.get('extra-workspace-cache-key'))
|
2017-03-04 01:49:23 +03:00
|
|
|
support_vcs_checkout(config, job, taskdesc)
|
2016-09-12 21:34:06 +03:00
|
|
|
|
|
|
|
env = worker.setdefault('env', {})
|
|
|
|
env.update({
|
|
|
|
'MOZHARNESS_CONFIG': ' '.join(run['config']),
|
|
|
|
'MOZHARNESS_SCRIPT': run['script'],
|
|
|
|
'MH_BRANCH': config.params['project'],
|
|
|
|
'MH_BUILD_POOL': 'taskcluster',
|
2016-11-03 05:23:27 +03:00
|
|
|
'MOZ_BUILD_DATE': config.params['moz_build_date'],
|
2016-09-12 21:34:06 +03:00
|
|
|
'MOZ_SCM_LEVEL': config.params['level'],
|
Bug 1359976: base worker payload generation on worker-type; r=wcosta r=aki
To date we have variously specified both worker-type and worker-implementation,
often manually coordinated. We also embedded a few awkward assumptions such as
that the native engine only runs on OS X.
But a worker type has one and only one implementation, and that implementation
is stable over time (as changing it would require simultaneous landings on all
trees).
Instead, this change makes worker-type the primary configuration, and derives
both a worker implementation (defining the payload format) and worker OS
(determining what to include in the payload) from that value. The derivation
occurs when deciding how to implement a particular job, where the run_using
functions are distinguished by worker implementation.
The two-part logic to determine how and where to run a test task based on its
platform is combined into a single transform, `set_worker_type`.
This contains some other related changes:
- MOZ_AUTOMATION is set in specific jobs, rather than everywhere docker-worker
is used
- the URL to test packages is factored out into a shared function
- docker-worker test defaults are applied in `mozharness_test.py`
- the WORKER_TYPE array in `task.py`, formerly mixing two types of keys, is
split
- the 'invalid' workerType is assigned an 'invalid' implementation
- all tasks that do not use job descriptions but use docker-worker, etc. have
`worker.os` added
Tested to not produce a substantially different taskgraph for a regular push, a
try push, or a nightly cron.
MozReview-Commit-ID: LDHrmrpBo7I
--HG--
extra : rebase_source : 4cdfe6b8d9874b0c156671515b213d820b48482f
2017-05-09 01:53:50 +03:00
|
|
|
'MOZ_AUTOMATION': '1',
|
2016-09-12 21:34:06 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
if 'actions' in run:
|
|
|
|
env['MOZHARNESS_ACTIONS'] = ' '.join(run['actions'])
|
|
|
|
|
|
|
|
if 'options' in run:
|
|
|
|
env['MOZHARNESS_OPTIONS'] = ' '.join(run['options'])
|
|
|
|
|
|
|
|
if 'custom-build-variant-cfg' in run:
|
|
|
|
env['MH_CUSTOM_BUILD_VARIANT_CFG'] = run['custom-build-variant-cfg']
|
|
|
|
|
2016-10-10 22:01:28 +03:00
|
|
|
if 'job-script' in run:
|
|
|
|
env['JOB_SCRIPT'] = run['job-script']
|
|
|
|
|
2016-09-12 21:34:06 +03:00
|
|
|
# if we're not keeping artifacts, set some env variables to empty values
|
|
|
|
# that will cause the build process to skip copying the results to the
|
|
|
|
# artifacts directory. This will have no effect for operations that are
|
|
|
|
# not builds.
|
|
|
|
if not run['keep-artifacts']:
|
|
|
|
env['DIST_TARGET_UPLOADS'] = ''
|
|
|
|
env['DIST_UPLOADS'] = ''
|
|
|
|
|
|
|
|
# Xvfb
|
|
|
|
if run['need-xvfb']:
|
|
|
|
env['NEED_XVFB'] = 'true'
|
|
|
|
|
|
|
|
# tooltool downloads
|
|
|
|
if run['tooltool-downloads']:
|
|
|
|
worker['relengapi-proxy'] = True
|
|
|
|
worker['caches'].append({
|
|
|
|
'type': 'persistent',
|
|
|
|
'name': 'tooltool-cache',
|
2017-07-01 00:45:26 +03:00
|
|
|
'mount-point': '/home/worker/tooltool-cache',
|
2016-09-12 21:34:06 +03:00
|
|
|
})
|
|
|
|
taskdesc['scopes'].extend([
|
|
|
|
'docker-worker:relengapi-proxy:tooltool.download.public',
|
|
|
|
])
|
|
|
|
if run['tooltool-downloads'] == 'internal':
|
|
|
|
taskdesc['scopes'].append(
|
|
|
|
'docker-worker:relengapi-proxy:tooltool.download.internal')
|
2017-07-01 00:45:26 +03:00
|
|
|
env['TOOLTOOL_CACHE'] = '/home/worker/tooltool-cache'
|
2016-09-12 21:34:06 +03:00
|
|
|
|
2016-10-07 19:20:15 +03:00
|
|
|
# Retry if mozharness returns TBPL_RETRY
|
|
|
|
worker['retry-exit-status'] = 4
|
|
|
|
|
2016-09-12 21:34:06 +03:00
|
|
|
docker_worker_setup_secrets(config, job, taskdesc)
|
|
|
|
|
2016-09-30 02:51:15 +03:00
|
|
|
command = [
|
2017-07-01 00:45:26 +03:00
|
|
|
'/home/worker/bin/run-task',
|
2016-09-30 02:51:15 +03:00
|
|
|
# Various caches/volumes are default owned by root:root.
|
2017-07-01 00:45:26 +03:00
|
|
|
'--chown-recursive', '/home/worker/workspace',
|
|
|
|
'--chown-recursive', '/home/worker/tooltool-cache',
|
|
|
|
'--vcs-checkout', '/home/worker/workspace/build/src',
|
|
|
|
'--tools-checkout', '/home/worker/workspace/build/tools',
|
2016-09-30 02:51:15 +03:00
|
|
|
'--',
|
|
|
|
]
|
2017-07-01 00:45:26 +03:00
|
|
|
command.append("/home/worker/workspace/build/src/{}".format(
|
2016-10-10 22:01:28 +03:00
|
|
|
run.get('job-script',
|
|
|
|
"taskcluster/scripts/builder/build-linux.sh"
|
|
|
|
)))
|
2016-09-30 02:51:15 +03:00
|
|
|
|
|
|
|
worker['command'] = command
|
2016-09-12 21:34:06 +03:00
|
|
|
|
|
|
|
|
|
|
|
@run_job_using("generic-worker", "mozharness", schema=mozharness_run_schema)
|
2017-04-06 19:50:41 +03:00
|
|
|
def mozharness_on_generic_worker(config, job, taskdesc):
|
Bug 1359976: base worker payload generation on worker-type; r=wcosta r=aki
To date we have variously specified both worker-type and worker-implementation,
often manually coordinated. We also embedded a few awkward assumptions such as
that the native engine only runs on OS X.
But a worker type has one and only one implementation, and that implementation
is stable over time (as changing it would require simultaneous landings on all
trees).
Instead, this change makes worker-type the primary configuration, and derives
both a worker implementation (defining the payload format) and worker OS
(determining what to include in the payload) from that value. The derivation
occurs when deciding how to implement a particular job, where the run_using
functions are distinguished by worker implementation.
The two-part logic to determine how and where to run a test task based on its
platform is combined into a single transform, `set_worker_type`.
This contains some other related changes:
- MOZ_AUTOMATION is set in specific jobs, rather than everywhere docker-worker
is used
- the URL to test packages is factored out into a shared function
- docker-worker test defaults are applied in `mozharness_test.py`
- the WORKER_TYPE array in `task.py`, formerly mixing two types of keys, is
split
- the 'invalid' workerType is assigned an 'invalid' implementation
- all tasks that do not use job descriptions but use docker-worker, etc. have
`worker.os` added
Tested to not produce a substantially different taskgraph for a regular push, a
try push, or a nightly cron.
MozReview-Commit-ID: LDHrmrpBo7I
--HG--
extra : rebase_source : 4cdfe6b8d9874b0c156671515b213d820b48482f
2017-05-09 01:53:50 +03:00
|
|
|
assert job['worker']['os'] == 'windows', 'only supports windows right now'
|
|
|
|
|
2016-09-12 21:34:06 +03:00
|
|
|
run = job['run']
|
|
|
|
|
|
|
|
# fail if invalid run options are included
|
|
|
|
invalid = []
|
2017-06-29 06:31:21 +03:00
|
|
|
for prop in ['tooltool-downloads',
|
|
|
|
'secrets', 'taskcluster-proxy', 'need-xvfb']:
|
2016-09-12 21:34:06 +03:00
|
|
|
if prop in run and run[prop]:
|
|
|
|
invalid.append(prop)
|
|
|
|
if not run.get('keep-artifacts', True):
|
|
|
|
invalid.append('keep-artifacts')
|
|
|
|
if invalid:
|
|
|
|
raise Exception("Jobs run using mozharness on Windows do not support properties " +
|
|
|
|
', '.join(invalid))
|
|
|
|
|
|
|
|
worker = taskdesc['worker']
|
|
|
|
|
2017-07-17 22:40:57 +03:00
|
|
|
generic_worker_add_public_artifacts(config, job, taskdesc)
|
2016-09-12 21:34:06 +03:00
|
|
|
|
|
|
|
docker_worker_add_gecko_vcs_env_vars(config, job, taskdesc)
|
|
|
|
|
|
|
|
env = worker['env']
|
|
|
|
env.update({
|
2016-11-03 05:23:27 +03:00
|
|
|
'MOZ_BUILD_DATE': config.params['moz_build_date'],
|
2016-09-12 21:34:06 +03:00
|
|
|
'MOZ_SCM_LEVEL': config.params['level'],
|
Bug 1359976: base worker payload generation on worker-type; r=wcosta r=aki
To date we have variously specified both worker-type and worker-implementation,
often manually coordinated. We also embedded a few awkward assumptions such as
that the native engine only runs on OS X.
But a worker type has one and only one implementation, and that implementation
is stable over time (as changing it would require simultaneous landings on all
trees).
Instead, this change makes worker-type the primary configuration, and derives
both a worker implementation (defining the payload format) and worker OS
(determining what to include in the payload) from that value. The derivation
occurs when deciding how to implement a particular job, where the run_using
functions are distinguished by worker implementation.
The two-part logic to determine how and where to run a test task based on its
platform is combined into a single transform, `set_worker_type`.
This contains some other related changes:
- MOZ_AUTOMATION is set in specific jobs, rather than everywhere docker-worker
is used
- the URL to test packages is factored out into a shared function
- docker-worker test defaults are applied in `mozharness_test.py`
- the WORKER_TYPE array in `task.py`, formerly mixing two types of keys, is
split
- the 'invalid' workerType is assigned an 'invalid' implementation
- all tasks that do not use job descriptions but use docker-worker, etc. have
`worker.os` added
Tested to not produce a substantially different taskgraph for a regular push, a
try push, or a nightly cron.
MozReview-Commit-ID: LDHrmrpBo7I
--HG--
extra : rebase_source : 4cdfe6b8d9874b0c156671515b213d820b48482f
2017-05-09 01:53:50 +03:00
|
|
|
'MOZ_AUTOMATION': '1',
|
2016-09-12 21:34:06 +03:00
|
|
|
})
|
2017-07-17 22:25:19 +03:00
|
|
|
if run['use-simple-package']:
|
|
|
|
env.update({'MOZ_SIMPLE_PACKAGE_NAME': 'target'})
|
2016-09-12 21:34:06 +03:00
|
|
|
|
2017-04-06 19:50:41 +03:00
|
|
|
if not job['attributes']['build_platform'].startswith('win'):
|
|
|
|
raise Exception(
|
|
|
|
"Task generation for mozharness build jobs currently only supported on Windows"
|
|
|
|
)
|
|
|
|
|
2016-09-12 21:34:06 +03:00
|
|
|
mh_command = [r'c:\mozilla-build\python\python.exe']
|
|
|
|
mh_command.append('\\'.join([r'.\build\src\testing', run['script'].replace('/', '\\')]))
|
|
|
|
for cfg in run['config']:
|
|
|
|
mh_command.append('--config ' + cfg.replace('/', '\\'))
|
2017-07-17 22:26:36 +03:00
|
|
|
if run['use-magic-mh-args']:
|
|
|
|
mh_command.append('--branch ' + config.params['project'])
|
|
|
|
mh_command.append(r'--skip-buildbot-actions')
|
|
|
|
mh_command.append(r'--work-dir %cd:Z:=z:%\build')
|
2017-06-29 06:31:21 +03:00
|
|
|
for action in run.get('actions', []):
|
2017-07-17 22:35:02 +03:00
|
|
|
assert ' ' not in action
|
2017-06-29 06:31:21 +03:00
|
|
|
mh_command.append('--' + action)
|
|
|
|
|
2016-09-29 09:49:30 +03:00
|
|
|
for option in run.get('options', []):
|
2017-07-17 22:35:02 +03:00
|
|
|
assert ' ' not in option
|
2016-09-29 09:49:30 +03:00
|
|
|
mh_command.append('--' + option)
|
2017-06-22 19:49:03 +03:00
|
|
|
if run.get('custom-build-variant-cfg'):
|
|
|
|
mh_command.append('--custom-build-variant')
|
|
|
|
mh_command.append(run['custom-build-variant-cfg'])
|
2016-10-12 18:06:17 +03:00
|
|
|
|
|
|
|
hg_command = ['"c:\\Program Files\\Mercurial\\hg.exe"']
|
|
|
|
hg_command.append('robustcheckout')
|
|
|
|
hg_command.extend(['--sharebase', 'y:\\hg-shared'])
|
|
|
|
hg_command.append('--purge')
|
|
|
|
hg_command.extend(['--upstream', 'https://hg.mozilla.org/mozilla-unified'])
|
|
|
|
hg_command.extend(['--revision', env['GECKO_HEAD_REV']])
|
|
|
|
hg_command.append(env['GECKO_HEAD_REPOSITORY'])
|
|
|
|
hg_command.append('.\\build\\src')
|
|
|
|
|
2016-11-14 19:47:59 +03:00
|
|
|
worker['command'] = []
|
|
|
|
if taskdesc.get('needs-sccache'):
|
|
|
|
worker['command'].extend([
|
2017-04-06 19:50:41 +03:00
|
|
|
# Make the comment part of the first command, as it will help users to
|
|
|
|
# understand what is going on, and why these steps are implemented.
|
|
|
|
dedent('''\
|
|
|
|
:: sccache currently uses the full compiler commandline as input to the
|
|
|
|
:: cache hash key, so create a symlink to the task dir and build from
|
|
|
|
:: the symlink dir to get consistent paths.
|
|
|
|
if exist z:\\build rmdir z:\\build'''),
|
2016-11-14 19:47:59 +03:00
|
|
|
r'mklink /d z:\build %cd%',
|
|
|
|
# Grant delete permission on the link to everyone.
|
|
|
|
r'icacls z:\build /grant *S-1-1-0:D /L',
|
|
|
|
r'cd /d z:\build',
|
|
|
|
])
|
|
|
|
|
|
|
|
worker['command'].extend([
|
2016-10-12 18:06:17 +03:00
|
|
|
' '.join(hg_command),
|
|
|
|
' '.join(mh_command)
|
2016-11-14 19:47:59 +03:00
|
|
|
])
|
2017-05-02 22:12:51 +03:00
|
|
|
|
|
|
|
|
|
|
|
@run_job_using('buildbot-bridge', 'mozharness', schema=mozharness_run_schema)
|
|
|
|
def mozharness_on_buildbot_bridge(config, job, taskdesc):
|
|
|
|
run = job['run']
|
|
|
|
worker = taskdesc['worker']
|
|
|
|
branch = config.params['project']
|
|
|
|
product = run.get('index', {}).get('product', 'firefox')
|
|
|
|
|
|
|
|
worker.pop('env', None)
|
|
|
|
|
2017-06-15 17:18:31 +03:00
|
|
|
if 'devedition' in job['attributes']['build_platform']:
|
|
|
|
buildername = 'OS X 10.7 {} devedition build'.format(branch)
|
|
|
|
else:
|
|
|
|
buildername = 'OS X 10.7 {} build'.format(branch)
|
|
|
|
|
2017-05-02 22:12:51 +03:00
|
|
|
worker.update({
|
2017-06-15 17:18:31 +03:00
|
|
|
'buildername': buildername,
|
2017-05-02 22:12:51 +03:00
|
|
|
'sourcestamp': {
|
|
|
|
'branch': branch,
|
|
|
|
'repository': config.params['head_repository'],
|
|
|
|
'revision': config.params['head_rev'],
|
|
|
|
},
|
|
|
|
'properties': {
|
|
|
|
'product': product,
|
|
|
|
'who': config.params['owner'],
|
|
|
|
'upload_to_task_id': slugid.nice(),
|
|
|
|
}
|
|
|
|
})
|