Bug 1384729 - Move actions into taskgraph dir draft
authorBrian Stack <bstack@mozilla.com>
Thu, 27 Jul 2017 10:47:37 -0700
changeset 617154 e1bcfa6e44491e226e23d3ab9faea04e0a17abae
parent 616915 36f95aeb4c77f7cf3b3366583008cd6e4b6b1dba
child 617155 7f4761e4a013e38b5a304eaae4c9708add2d6f5e
push id70950
push userbstack@mozilla.com
push dateFri, 28 Jul 2017 01:45:49 +0000
bugs1384729
milestone56.0a1
Bug 1384729 - Move actions into taskgraph dir MozReview-Commit-ID: HK5MR8Xw3On
taskcluster/actions/__init__.py
taskcluster/actions/add-new-jobs.py
taskcluster/actions/hello-action.py
taskcluster/actions/registry.py
taskcluster/actions/retrigger.py
taskcluster/actions/run_missing_tests.py
taskcluster/actions/test-retrigger-action.py
taskcluster/actions/util.py
taskcluster/mach_commands.py
taskcluster/taskgraph/actions/__init__.py
taskcluster/taskgraph/actions/add-new-jobs.py
taskcluster/taskgraph/actions/hello-action.py
taskcluster/taskgraph/actions/registry.py
taskcluster/taskgraph/actions/retrigger.py
taskcluster/taskgraph/actions/run_missing_tests.py
taskcluster/taskgraph/actions/test-retrigger-action.py
taskcluster/taskgraph/actions/util.py
taskcluster/taskgraph/decision.py
--- a/taskcluster/mach_commands.py
+++ b/taskcluster/mach_commands.py
@@ -289,28 +289,28 @@ class MachCommands(MachCommandBase):
             return taskgraph.action.add_talos(options['decision_task_id'], options['times'])
         except Exception:
             traceback.print_exc()
             sys.exit(1)
 
     @SubCommand('taskgraph', 'action-callback',
                 description='Run action callback used by action tasks')
     def action_callback(self, **options):
-        import actions
+        import taskgraph.actions
         try:
             self.setup_logging()
 
             task_group_id = os.environ.get('ACTION_TASK_GROUP_ID', None)
             task_id = json.loads(os.environ.get('ACTION_TASK_ID', 'null'))
             task = json.loads(os.environ.get('ACTION_TASK', 'null'))
             input = json.loads(os.environ.get('ACTION_INPUT', 'null'))
             callback = os.environ.get('ACTION_CALLBACK', None)
             parameters = json.loads(os.environ.get('ACTION_PARAMETERS', '{}'))
 
-            return actions.trigger_action_callback(
+            return taskgraph.actions.trigger_action_callback(
                     task_group_id=task_group_id,
                     task_id=task_id,
                     task=task,
                     input=input,
                     callback=callback,
                     parameters=parameters,
                     test=False)
         except Exception:
@@ -331,17 +331,17 @@ class MachCommands(MachCommandBase):
     @CommandArgument('--task', default=None,
                      help='Task definition (.yml or .json; if omitted, the task will be'
                           'fetched from the queue)')
     @CommandArgument('callback', default=None,
                      help='Action callback name (Python function name)')
     def test_action_callback(self, **options):
         import taskgraph.parameters
         from taskgraph.util.taskcluster import get_task_definition
-        import actions
+        import taskgraph.actions
         import yaml
 
         def load_data(filename):
             with open(filename) as f:
                 if filename.endswith('.yml'):
                     return yaml.safe_load(f)
                 elif filename.endswith('.json'):
                     return json.load(f)
@@ -361,17 +361,17 @@ class MachCommands(MachCommandBase):
             if options['input']:
                 input = load_data(options['input'])
             else:
                 input = None
 
             parameters = taskgraph.parameters.load_parameters_file(options['parameters'])
             parameters.check()
 
-            return actions.trigger_action_callback(
+            return taskgraph.actions.trigger_action_callback(
                     task_group_id=options['task_group_id'],
                     task_id=task_id,
                     task=task,
                     input=input,
                     callback=options['callback'],
                     parameters=parameters,
                     test=True)
         except Exception:
rename from taskcluster/actions/__init__.py
rename to taskcluster/taskgraph/actions/__init__.py
rename from taskcluster/actions/add-new-jobs.py
rename to taskcluster/taskgraph/actions/add-new-jobs.py
--- a/taskcluster/actions/add-new-jobs.py
+++ b/taskcluster/taskgraph/actions/add-new-jobs.py
@@ -1,12 +1,20 @@
+# -*- coding: utf-8 -*-
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
 from .registry import register_callback_action
 from slugid import nice as slugid
 
-from actions.util import create_task
+from .util import create_task
 from taskgraph.util.taskcluster import get_artifact
 from taskgraph.util.parameterization import resolve_task_references
 from taskgraph.taskgraph import TaskGraph
 
 
 @register_callback_action(
     name='add-new-jobs',
     title='Add new jobs',
rename from taskcluster/actions/hello-action.py
rename to taskcluster/taskgraph/actions/hello-action.py
rename from taskcluster/actions/registry.py
rename to taskcluster/taskgraph/actions/registry.py
--- a/taskcluster/actions/registry.py
+++ b/taskcluster/taskgraph/actions/registry.py
@@ -10,17 +10,17 @@ import json
 import os
 import inspect
 import re
 from mozbuild.util import memoize
 from types import FunctionType
 from collections import namedtuple
 from taskgraph.util.docker import docker_image
 from taskgraph.parameters import Parameters
-from actions import util
+from . import util
 
 
 GECKO = os.path.realpath(os.path.join(__file__, '..', '..', '..'))
 
 actions = []
 callbacks = {}
 
 Action = namedtuple('Action', [
@@ -313,18 +313,18 @@ def trigger_action_callback(task_group_i
     cb(Parameters(**parameters), input, task_group_id, task_id, task)
 
 
 @memoize
 def _load():
     # Load all modules from this folder, relying on the side-effects of register_
     # functions to populate the action registry.
     for f in os.listdir(os.path.dirname(__file__)):
-        if f.endswith('.py') and f not in ('__init__.py', 'registry.py'):
-            __import__('actions.' + f[:-3])
+        if f.endswith('.py') and f not in ('__init__.py', 'registry.py', 'util.py'):
+            __import__('taskgraph.actions.' + f[:-3])
     return callbacks, actions
 
 
 def get_callbacks():
     return _load()[0]
 
 
 def get_actions():
rename from taskcluster/actions/retrigger.py
rename to taskcluster/taskgraph/actions/retrigger.py
--- a/taskcluster/actions/retrigger.py
+++ b/taskcluster/taskgraph/actions/retrigger.py
@@ -1,9 +1,17 @@
-from registry import register_task_action
+# -*- coding: utf-8 -*-
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+from .registry import register_task_action
 
 
 @register_task_action(
     title='Retrigger',
     name='retrigger',
     description='Create a clone of the task',
     order=1,
     context=[{}],
rename from taskcluster/actions/run_missing_tests.py
rename to taskcluster/taskgraph/actions/run_missing_tests.py
--- a/taskcluster/actions/run_missing_tests.py
+++ b/taskcluster/taskgraph/actions/run_missing_tests.py
@@ -5,17 +5,17 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import logging
 from slugid import nice as slugid
 
 from .registry import register_callback_action
-from actions.util import create_task, find_decision_task
+from .util import create_task, find_decision_task
 from taskgraph.util.taskcluster import get_artifact
 from taskgraph.util.parameterization import resolve_task_references
 from taskgraph.taskgraph import TaskGraph
 
 logger = logging.getLogger(__name__)
 
 
 @register_callback_action(
rename from taskcluster/actions/test-retrigger-action.py
rename to taskcluster/taskgraph/actions/test-retrigger-action.py
--- a/taskcluster/actions/test-retrigger-action.py
+++ b/taskcluster/taskgraph/actions/test-retrigger-action.py
@@ -1,8 +1,16 @@
+# -*- coding: utf-8 -*-
+
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+from __future__ import absolute_import, print_function, unicode_literals
+
 import copy
 import json
 import logging
 
 import requests
 from slugid import nice as slugid
 
 from .registry import register_callback_action
rename from taskcluster/actions/util.py
rename to taskcluster/taskgraph/actions/util.py
--- a/taskcluster/actions/util.py
+++ b/taskcluster/taskgraph/actions/util.py
@@ -1,8 +1,10 @@
+# -*- coding: utf-8 -*-
+
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 import json
 import sys
--- a/taskcluster/taskgraph/decision.py
+++ b/taskcluster/taskgraph/decision.py
@@ -12,17 +12,17 @@ import re
 
 import time
 import yaml
 
 from .generator import TaskGraphGenerator
 from .create import create_tasks
 from .parameters import Parameters
 from .taskgraph import TaskGraph
-from actions import render_actions_json
+from .actions import render_actions_json
 from . import GECKO
 
 from taskgraph.util.templates import Templates
 from taskgraph.util.time import (
     json_time_from_now,
     current_json_time,
 )