Bug 1462791 - Add helper function for VCS checkout on generic-worker; r=dustin

This functionality was implemented at least 3 times. Let's consolidate
it to a central function.

Returning multiple command strings is kind of funky. I preserved
existing behavior and mozharness jobs are the only ones printing the
forensic logging. We should probably move this logging into
robustcheckout so we don't need to involve taskgraph with this. But
that can be deferred to another day.

MozReview-Commit-ID: I2LglJvfI6

--HG--
extra : rebase_source : 7cb413694aee4e46a6522febe9daa4b73b5307ca
extra : source : 096d7d374af427ee950c7a550878781eebad4135
This commit is contained in:
Gregory Szorc 2018-04-20 13:34:45 -07:00
Родитель aa3feebecc
Коммит d37f10a88a
4 изменённых файлов: 52 добавлений и 51 удалений

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

@ -132,6 +132,34 @@ def support_vcs_checkout(config, job, taskdesc, sparse=False):
taskdesc['worker']['taskcluster-proxy'] = True
def generic_worker_hg_commands(base_repo, head_repo, head_rev, path):
"""Obtain commands needed to obtain a Mercurial checkout on generic-worker.
Returns two command strings. One performs the checkout. Another logs.
"""
args = [
r'"c:\Program Files\Mercurial\hg.exe"',
'robustcheckout',
'--sharebase', r'y:\hg-shared',
'--purge',
'--upstream', base_repo,
'--revision', head_rev,
head_repo,
path,
]
logging_args = [
b":: TinderboxPrint:<a href={source_repo}/rev/{revision} "
b"title='Built from {repo_name} revision {revision}'>{revision}</a>"
b"\n".format(
revision=head_rev,
source_repo=head_repo,
repo_name=head_repo.split('/')[-1]),
]
return ' '.join(args), ' '.join(logging_args)
def docker_worker_setup_secrets(config, job, taskdesc):
"""Set up access to secrets via taskcluster-proxy. The value of
run['secrets'] should be a boolean or a list of secret names that

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

@ -24,6 +24,7 @@ from taskgraph.transforms.job.common import (
docker_worker_add_artifacts,
docker_worker_add_tooltool,
generic_worker_add_artifacts,
generic_worker_hg_commands,
support_vcs_checkout,
)
@ -292,43 +293,20 @@ def mozharness_on_generic_worker(config, job, taskdesc):
mh_command.append('--custom-build-variant')
mh_command.append(run['custom-build-variant-cfg'])
def checkout_repo(base_repo, head_repo, head_rev, path):
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', base_repo])
hg_command.extend(['--revision', head_rev])
hg_command.append(head_repo)
hg_command.append(path)
logging_command = [
b":: TinderboxPrint:<a href={source_repo}/rev/{revision} "
b"title='Built from {repo_name} revision {revision}'>{revision}</a>\n".format(
revision=head_rev,
source_repo=head_repo,
repo_name=head_repo.split('/')[-1],
)]
return [
' '.join(hg_command),
' '.join(logging_command),
]
hg_commands = checkout_repo(
hg_commands = generic_worker_hg_commands(
base_repo=env['GECKO_BASE_REPOSITORY'],
head_repo=env['GECKO_HEAD_REPOSITORY'],
head_rev=env['GECKO_HEAD_REV'],
path='.\\build\\src')
path=r'.\build\src',
)
if run['comm-checkout']:
hg_commands.extend(
checkout_repo(
generic_worker_hg_commands(
base_repo=env['COMM_BASE_REPOSITORY'],
head_repo=env['COMM_HEAD_REPOSITORY'],
head_rev=env['COMM_HEAD_REV'],
path='.\\build\\src\\comm')
)
path=r'.\build\src\comm'))
worker['command'] = []
if taskdesc.get('needs-sccache'):

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

@ -14,6 +14,7 @@ from taskgraph.transforms.job import run_job_using
from taskgraph.transforms.job.common import (
docker_worker_add_artifacts,
generic_worker_add_artifacts,
generic_worker_hg_commands,
docker_worker_add_gecko_vcs_env_vars,
docker_worker_add_tooltool,
support_vcs_checkout,
@ -115,20 +116,17 @@ def generic_worker_spidermonkey(config, job, taskdesc):
# Don't allow untested configurations yet
raise Exception("spidermonkey-rust-bindings is not a supported configuration")
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('.\\src')
hg_command = generic_worker_hg_commands(
'https://hg.mozilla.org/mozilla-unified',
env['GECKO_HEAD_REPOSITORY'],
env['GECKO_HEAD_REV'],
r'.\src',
)[0]
command = ['c:\\mozilla-build\\msys\\bin\\bash.exe ' # string concat
'"./src/taskcluster/scripts/builder/%s"' % script]
worker['command'] = []
worker['command'].extend([
' '.join(hg_command),
' '.join(command)
])
worker['command'] = [
hg_command,
' '.join(command),
]

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

@ -17,6 +17,7 @@ from taskgraph.transforms.job.common import (
docker_worker_add_gecko_vcs_env_vars,
docker_worker_add_artifacts,
docker_worker_add_tooltool,
generic_worker_hg_commands,
support_vcs_checkout,
)
from taskgraph.util.hash import hash_paths
@ -205,15 +206,11 @@ def windows_toolchain(config, job, taskdesc):
'MOZ_AUTOMATION': '1',
})
hg = r'c:\Program Files\Mercurial\hg.exe'
hg_command = ['"{}"'.format(hg)]
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', '%GECKO_HEAD_REV%'])
hg_command.append('%GECKO_HEAD_REPOSITORY%')
hg_command.append('.\\build\\src')
hg_command = generic_worker_hg_commands(
'https://hg.mozilla.org/mozilla-unified',
env['GECKO_HEAD_REPOSITORY'],
env['GECKO_HEAD_REV'],
r'.\build\src')[0]
# Use `mach` to invoke python scripts so in-tree libraries are available.
if run['script'].endswith('.py'):
@ -225,7 +222,7 @@ def windows_toolchain(config, job, taskdesc):
bash = r'c:\mozilla-build\msys\bin\bash'
worker['command'] = [
' '.join(hg_command),
hg_command,
# do something intelligent.
r'{} build/src/taskcluster/scripts/misc/{}{}'.format(
bash, run['script'], args)