Bug 1405408 - Part 2: Add taskcluster-proxy and scopes to tasks consuming non-public/ toolchains. r=dustin
authorNick Alexander <nalexander@mozilla.com>
Thu, 05 Oct 2017 16:41:43 -0700
changeset 679133 20cae3b446bf279f79ef011a9b742d248e1a2897
parent 679132 74e5d77b144db73cdeac30bfa2a323d0510817c1
child 679134 5fa05ab4204d94707e8f72ce8514d05588345daf
push id84141
push userbmo:schien@mozilla.com
push dateThu, 12 Oct 2017 11:13:04 +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
             )