Bug 1340668 - Fix repo scopes in action.json generation r=garndt
authorBrian Stack <bstack@mozilla.com>
Fri, 17 Feb 2017 14:43:59 -0800
changeset 373073 69dc3f79527d7cef2d3036756ca43bbf1a2f31ff
parent 373072 577f20b0aa205169c779b340e8d73cff2cb791cd
child 373074 47725823427b20c6229d0e1fa690972b90de7efe
child 373124 bab76c9ef680c8ee8ff290bc02410923c4a1bde2
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgarndt
bugs1340668
milestone54.0a1
Bug 1340668 - Fix repo scopes in action.json generation r=garndt MozReview-Commit-ID: CprCcIiqsbH
taskcluster/actions/registry.py
--- a/taskcluster/actions/registry.py
+++ b/taskcluster/actions/registry.py
@@ -1,11 +1,12 @@
 import json
 import os
 import inspect
+import re
 from types import FunctionType
 from collections import namedtuple
 from taskgraph.util.docker import docker_image
 from taskgraph.parameters import Parameters
 
 
 GECKO = os.path.realpath(os.path.join(__file__, '..', '..', '..'))
 
@@ -154,32 +155,39 @@ def register_callback_action(title, symb
         assert not mem['registered'], 'register_callback_action must be used as decorator'
         assert cb.__name__ not in callbacks, 'callback name {} is not unique'.format(cb.__name__)
         source_path = os.path.relpath(inspect.stack()[1][1], GECKO)
 
         @register_task_action(title, description, order, context, schema)
         def build_callback_action_task(parameters):
             if not available(parameters):
                 return None
+
+            match = re.match(r'https://(hg.mozilla.org)/(.*?)/?$', parameters['head_repository'])
+            if not match:
+                raise Exception('Unrecognized head_repository')
+            repo_scope = 'assume:repo:{}/{}:*'.format(
+                match.group(1), match.group(2))
+
             return {
                 'created': {'$fromNow': ''},
                 'deadline': {'$fromNow': '12 hours'},
                 'expires': {'$fromNow': '14 days'},
                 'metadata': {
                     'owner': 'mozilla-taskcluster-maintenance@mozilla.com',
                     'source': '{}raw-file/{}/{}'.format(
                         parameters['head_repository'], parameters['head_rev'], source_path,
                     ),
                     'name': 'Action: {}'.format(title),
                     'description': 'Task executing callback for action.\n\n---\n' + description,
                 },
                 'workerType': 'gecko-decision',
                 'provisionerId': 'aws-provisioner-v1',
                 'scopes': [
-                    'assume:repo:hg.mozilla.org/projects/{}:*'.format(parameters['project']),
+                    repo_scope,
                 ],
                 'tags': {
                     'createdForUser': parameters['owner'],
                     'kind': 'action-callback',
                 },
                 'routes': [
                     'tc-treeherder.v2.{}.{}.{}'.format(
                         parameters['project'], parameters['head_rev'], parameters['pushlog_id']),