Bug 1405408 - Part 2: Add taskcluster-proxy and scopes to tasks consuming non-public/ toolchains. r=dustin draft
authorNick Alexander <nalexander@mozilla.com>
Thu, 05 Oct 2017 16:41:43 -0700
changeset 678723 8628be21bacacbd782dffc47933d000c57dc2fb2
parent 678722 8346a0d9822834fe1ab2bb463c826cb15b69a0e9
child 678724 23e1bc683248f69f6e4c90204e9bc0701f4a778a
push id84017
push usernalexander@mozilla.com
push dateWed, 11 Oct 2017 19:53:59 +0000
reviewersdustin
bugs1405408
milestone58.0a1
Bug 1405408 - Part 2: Add taskcluster-proxy and scopes to tasks consuming non-public/ toolchains. r=dustin MozReview-Commit-ID: BIGjLXmTSli
taskcluster/taskgraph/transforms/use_toolchains.py
--- a/taskcluster/taskgraph/transforms/use_toolchains.py
+++ b/taskcluster/taskgraph/transforms/use_toolchains.py
@@ -63,41 +63,51 @@ def use_toolchains(config, jobs):
                     % (job['name'], key, aliases[key])
                 )
             return key
     else:
         def get_alias(key):
             return aliases.get(key, key)
 
     for job in jobs:
+        scopes = job.setdefault('scopes', [])
         env = job.setdefault('worker', {}).setdefault('env', {})
 
         toolchains = [get_alias(t)
                       for t in job.pop('toolchains', [])]
 
         if config.kind == 'toolchain' and job['name'] in toolchains:
             raise Exception("Toolchain job %s can't use itself as toolchain"
                             % job['name'])
 
         filenames = {}
         for t in toolchains:
             if t not in artifacts:
                 raise Exception('Missing toolchain job for %s-%s: %s'
                                 % (config.kind, job['name'], t))
 
-            f = os.path.basename(artifacts[t])
+            dirname, f = os.path.split(artifacts[t])
             if f in filenames:
                 # Build jobs don't support toolchain artifacts with the same
                 # name: they would overwrite one with the other.
                 raise Exception('%s-%s cannot use both %s and %s toolchains: '
                                 'they both have the same artifact name %s'
                                 % (config.kind, job['name'], filenames[f],
                                    t, f))
             filenames[f] = t
 
+            if not artifacts[t].startswith('public/'):
+                # Use taskcluster-proxy and request appropriate scope.
+                # For example, add 'scopes: [queue:get-artifact:path/to/*]'
+                # for 'path/to/artifact.tar.xz'.
+                job['worker']['taskcluster-proxy'] = True
+                scope = 'queue:get-artifact:{}/*'.format(dirname)
+                if scope not in scopes:
+                    scopes.append(scope)
+
             if t.endswith('-sccache'):
                 job['needs-sccache'] = True
 
         if toolchains:
             job.setdefault('dependencies', {}).update(
                 ('toolchain-%s' % t, 'toolchain-%s' % t)
                 for t in toolchains
             )