From ff9a2ed949ffb6af525f0c362d909d8a39efda19 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Thu, 4 Apr 2019 18:41:12 +0000 Subject: [PATCH] Bug 1195299 - [ci] Use 'mach python' to run mozharness scripts when we have a srcdir r=catlee This makes sure that the mozharness scripts have access to all the packages in the build system virtualenv (namely mozbase). Differential Revision: https://phabricator.services.mozilla.com/D22184 --HG-- extra : moz-landing-system : lando --- taskcluster/scripts/builder/build-linux.sh | 4 ++-- taskcluster/scripts/tester/test-linux.sh | 11 ++++++++--- taskcluster/taskgraph/transforms/job/mozharness.py | 13 ++++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/taskcluster/scripts/builder/build-linux.sh b/taskcluster/scripts/builder/build-linux.sh index 64224dfcd33a..8b646da52221 100755 --- a/taskcluster/scripts/builder/build-linux.sh +++ b/taskcluster/scripts/builder/build-linux.sh @@ -88,7 +88,7 @@ export TOOLTOOL_CACHE config_path_cmds="" for path in ${MOZHARNESS_CONFIG_PATHS}; do - config_path_cmds="${config_path_cmds} --extra-config-path ${WORKSPACE}/build/src/${path}" + config_path_cmds="${config_path_cmds} --extra-config-path ${GECKO_PATH}/${path}" done # support multiple, space delimited, config files @@ -117,7 +117,7 @@ fi cd /builds/worker -python2.7 $WORKSPACE/build/src/testing/${MOZHARNESS_SCRIPT} \ +$GECKO_PATH/mach python $GECKO_PATH/testing/${MOZHARNESS_SCRIPT} \ ${config_path_cmds} \ ${config_cmds} \ $debug_flag \ diff --git a/taskcluster/scripts/tester/test-linux.sh b/taskcluster/scripts/tester/test-linux.sh index 4823e3f185ff..3c5d36889d8e 100755 --- a/taskcluster/scripts/tester/test-linux.sh +++ b/taskcluster/scripts/tester/test-linux.sh @@ -19,6 +19,7 @@ fi # Inputs, with defaults +: GECKO_PATH ${GECKO_PATH} : MOZHARNESS_PATH ${MOZHARNESS_PATH} : MOZHARNESS_URL ${MOZHARNESS_URL} : MOZHARNESS_SCRIPT ${MOZHARNESS_SCRIPT} @@ -183,16 +184,20 @@ if [ -n "$MOZHARNESS_OPTIONS" ]; then done fi +# Use |mach python| if a source checkout exists so in-tree packages are +# available. +[[ -d "${GECKO_PATH}" ]] && python="${GECKO_PATH}/mach python" || python="python2.7" + +# Save the computed mozharness command to a binary which is useful for +# interactive mode. mozharness_bin="$HOME/bin/run-mozharness" mkdir -p $(dirname $mozharness_bin) -# Save the computed mozharness command to a binary which is useful -# for interactive mode. echo -e "#!/usr/bin/env bash # Some mozharness scripts assume base_work_dir is in # the current working directory, see bug 1279237 cd "$WORKSPACE" -cmd=\"python2.7 ${MOZHARNESS_PATH}/scripts/${MOZHARNESS_SCRIPT} ${config_cmds} ${options} ${@} \${@}\" +cmd=\"${python} ${MOZHARNESS_PATH}/scripts/${MOZHARNESS_SCRIPT} ${config_cmds} ${options} ${@} \${@}\" echo \"Running: \${cmd}\" exec \${cmd}" > ${mozharness_bin} chmod +x ${mozharness_bin} diff --git a/taskcluster/taskgraph/transforms/job/mozharness.py b/taskcluster/taskgraph/transforms/job/mozharness.py index 7e03932a0002..320a00daf0d5 100644 --- a/taskcluster/taskgraph/transforms/job/mozharness.py +++ b/taskcluster/taskgraph/transforms/job/mozharness.py @@ -300,16 +300,19 @@ def mozharness_on_generic_worker(config, job, taskdesc): "Task generation for mozharness build jobs currently only supported on Windows" ) - mh_command = [r'c:\mozilla-build\python\python.exe'] - mh_command.append('\\'.join([r'.\build\src\testing', run['script'].replace('/', '\\')])) + gecko = env['GECKO_PATH'].replace('.', '%cd%') + mh_command = [ + 'c:/mozilla-build/python/python.exe', + '{}/mach'.format(gecko), 'python', + ] + mh_command.append('/'.join([gecko, 'testing', run['script']])) if 'config-paths' in run: for path in run['config-paths']: - mh_command.append(r'--extra-config-path ' - r'.\build\src\{}'.format(path.replace('/', '\\'))) + mh_command.append('--extra-config-path {}/{}'.format(gecko, path)) for cfg in run['config']: - mh_command.append('--config ' + cfg.replace('/', '\\')) + mh_command.append('--config ' + cfg) if run['use-magic-mh-args']: mh_command.append('--branch ' + config.params['project']) mh_command.append(r'--work-dir %cd:Z:=z:%\build')