Bug 1465181 - [taskgraph] Support use-artifacts with native-engine in run-task, r?dustin draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 24 May 2018 11:08:09 -0400
changeset 802311 9b02b8027d1951813fec75ce496fdd4e8d19f79e
parent 802102 763f30c3421233a45ef9e67a695c5c241a2c8a3a
child 802312 87d0ac8c56192de6333133ab92f17fc36f35e919
push id111858
push userahalberstadt@mozilla.com
push dateThu, 31 May 2018 17:24:02 +0000
reviewersdustin
bugs1465181
milestone62.0a1
Bug 1465181 - [taskgraph] Support use-artifacts with native-engine in run-task, r?dustin Extends support of the use-artifacts key to native-engine based tasks. MozReview-Commit-ID: FJILoyD5XVZ
taskcluster/taskgraph/transforms/job/common.py
taskcluster/taskgraph/transforms/job/run_task.py
--- a/taskcluster/taskgraph/transforms/job/common.py
+++ b/taskcluster/taskgraph/transforms/job/common.py
@@ -189,17 +189,17 @@ def docker_worker_add_tooltool(config, j
     ])
 
     if internal:
         taskdesc['scopes'].extend([
             'docker-worker:relengapi-proxy:tooltool.download.internal',
         ])
 
 
-def docker_worker_use_artifacts(config, job, taskdesc, use_artifacts):
+def support_use_artifacts(config, job, taskdesc, use_artifacts):
     """Set a JSON object of artifact URLs in an environment variable.
 
     This will tell the run-task script to download the artifacts.
     """
     urls = {}
     prefix = get_artifact_prefix(taskdesc)
     for kind, artifacts in use_artifacts.items():
         if kind not in taskdesc['dependencies']:
--- a/taskcluster/taskgraph/transforms/job/run_task.py
+++ b/taskcluster/taskgraph/transforms/job/run_task.py
@@ -4,17 +4,17 @@
 """
 Support for running jobs that are invoked via the `run-task` script.
 """
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 from taskgraph.transforms.job import run_job_using
 from taskgraph.util.schema import Schema
-from taskgraph.transforms.job.common import support_vcs_checkout, docker_worker_use_artifacts
+from taskgraph.transforms.job.common import support_use_artifacts, support_vcs_checkout
 from voluptuous import Required, Any
 
 run_task_schema = Schema({
     Required('using'): 'run-task',
 
     # if true, add a cache at ~worker/.cache, which is where things like pip
     # tend to hide their caches.  This cache is never added for level-1 jobs.
     Required('cache-dotcache'): bool,
@@ -46,48 +46,48 @@ run_task_schema = Schema({
 
 
 def common_setup(config, job, taskdesc):
     run = job['run']
     if run['checkout']:
         support_vcs_checkout(config, job, taskdesc,
                              sparse=bool(run['sparse-profile']))
 
+    if run['use-artifacts']:
+        support_use_artifacts(config, job, taskdesc, run['use-artifacts'])
+
     taskdesc['worker'].setdefault('env', {})['MOZ_SCM_LEVEL'] = config.params['level']
 
 
 def add_checkout_to_command(run, command):
     if not run['checkout']:
         return
 
     command.append('--vcs-checkout=/builds/worker/checkouts/gecko')
 
     if run['sparse-profile']:
         command.append('--sparse-profile=build/sparse-profiles/%s' %
                        run['sparse-profile'])
 
 
-docker_defaults = {
+defaults = {
     'cache-dotcache': False,
     'checkout': True,
     'comm-checkout': False,
     'sparse-profile': None,
     'use-artifacts': None,
 }
 
 
-@run_job_using("docker-worker", "run-task", schema=run_task_schema, defaults=docker_defaults)
+@run_job_using("docker-worker", "run-task", schema=run_task_schema, defaults=defaults)
 def docker_worker_run_task(config, job, taskdesc):
     run = job['run']
     worker = taskdesc['worker'] = job['worker']
     common_setup(config, job, taskdesc)
 
-    if run['use-artifacts']:
-        docker_worker_use_artifacts(config, job, taskdesc, run['use-artifacts'])
-
     if run.get('cache-dotcache'):
         worker['caches'].append({
             'type': 'persistent',
             'name': 'level-{level}-{project}-dotcache'.format(**config.params),
             'mount-point': '/builds/worker/.cache',
             'skip-untrusted': True,
         })
 
@@ -103,17 +103,17 @@ def docker_worker_run_task(config, job, 
     if run['comm-checkout']:
         command.append('--comm-checkout=/builds/worker/checkouts/gecko/comm')
     command.append('--fetch-hgfingerprint')
     command.append('--')
     command.extend(run_command)
     worker['command'] = command
 
 
-@run_job_using("native-engine", "run-task", schema=run_task_schema)
+@run_job_using("native-engine", "run-task", schema=run_task_schema, defaults=defaults)
 def native_engine_run_task(config, job, taskdesc):
     run = job['run']
     worker = taskdesc['worker'] = job['worker']
     common_setup(config, job, taskdesc)
 
     worker['context'] = '{}/raw-file/{}/taskcluster/scripts/run-task'.format(
         config.params['head_repository'], config.params['head_rev']
     )