cbuildbot: split out release engineering builder logic

Start a new release engineering builder module to hold the various RE
related builders.  This is not for our "release" configs (i.e. canaries)
but for general release engineering needs.

BUG=brillo:134, chromium:299943
TEST=`./cbuildbot/run_tests` passes

Change-Id: I80bfbcfc18e1a208edce3a4c5eb76dc9b31701f1
Reviewed-on: https://chromium-review.googlesource.com/253710
Trybot-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
Reviewed-by: Don Garrett <dgarrett@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
diff --git a/cbuildbot/builders/release_builders.py b/cbuildbot/builders/release_builders.py
new file mode 100644
index 0000000..b982d16
--- /dev/null
+++ b/cbuildbot/builders/release_builders.py
@@ -0,0 +1,18 @@
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Module containing release engineering related builders."""
+
+from __future__ import print_function
+
+from chromite.cbuildbot.builders import simple_builders
+from chromite.cbuildbot.stages import branch_stages
+
+
+class CreateBranchBuilder(simple_builders.SimpleBuilder):
+  """Create release branches in the manifest."""
+
+  def RunStages(self):
+    """Runs through build process."""
+    self._RunStage(branch_stages.BranchUtilStage)
diff --git a/cbuildbot/builders/simple_builders.py b/cbuildbot/builders/simple_builders.py
index 118db35..8b2a54c 100644
--- a/cbuildbot/builders/simple_builders.py
+++ b/cbuildbot/builders/simple_builders.py
@@ -16,7 +16,6 @@
 from chromite.cbuildbot.builders import generic_builders
 from chromite.cbuildbot.stages import afdo_stages
 from chromite.cbuildbot.stages import artifact_stages
-from chromite.cbuildbot.stages import branch_stages
 from chromite.cbuildbot.stages import build_stages
 from chromite.cbuildbot.stages import chrome_stages
 from chromite.cbuildbot.stages import completion_stages
@@ -290,8 +289,6 @@
     # TODO(sosa): Split these out into classes.
     if self._run.config.build_type == constants.PRE_CQ_LAUNCHER_TYPE:
       self._RunStage(sync_stages.PreCQLauncherStage)
-    elif self._run.config.build_type == constants.CREATE_BRANCH_TYPE:
-      self._RunStage(branch_stages.BranchUtilStage)
     elif self._run.config.build_type == constants.CHROOT_BUILDER_TYPE:
       self._RunChrootBuilderTypeBuild()
     elif ((self._run.config.build_type == constants.PALADIN_TYPE or
diff --git a/cbuildbot/cbuildbot_config.py b/cbuildbot/cbuildbot_config.py
index 4f217a3..62b6ed1 100755
--- a/cbuildbot/cbuildbot_config.py
+++ b/cbuildbot/cbuildbot_config.py
@@ -2133,7 +2133,9 @@
   # Disable postsync_reexec to continue running the 'master' branch chromite
   # for all stages, rather than the chromite in the branch buildroot.
   postsync_reexec=False,
-  build_type=constants.CREATE_BRANCH_TYPE,
+  # Need to reset the paladin build_type we inherited.
+  build_type=None,
+  builder_class_name='release_builders.CreateBranchBuilder',
   description='Used for creating/deleting branches (TPMs only)',
 )
 
diff --git a/cbuildbot/cbuildbot_config_unittest.py b/cbuildbot/cbuildbot_config_unittest.py
index 525aa79..4d26057 100644
--- a/cbuildbot/cbuildbot_config_unittest.py
+++ b/cbuildbot/cbuildbot_config_unittest.py
@@ -316,9 +316,11 @@
   def testBuildType(self):
     """Verifies that all configs use valid build types."""
     for build_name, config in cbuildbot_config.config.iteritems():
-      self.assertTrue(
-          config['build_type'] in constants.VALID_BUILD_TYPES,
-          'Config %s: has unexpected build_type value.' % build_name)
+      # For builders that have explicit classes, this check doesn't make sense.
+      if config['builder_class_name']:
+        continue
+      self.assertIn(config['build_type'], constants.VALID_BUILD_TYPES,
+                    'Config %s: has unexpected build_type value.' % build_name)
 
   def testGCCGitHash(self):
     """Verifies that gcc_githash is not set without setting latest_toolchain."""
diff --git a/cbuildbot/config_dump.json b/cbuildbot/config_dump.json
index eba55d4..f855607 100644
--- a/cbuildbot/config_dump.json
+++ b/cbuildbot/config_dump.json
@@ -6925,7 +6925,8 @@
     },
     "branch-util": {
         "boards": [],
-        "build_type": "gardener",
+        "build_type": null,
+        "builder_class_name": "release_builders.CreateBranchBuilder",
         "chrome_sdk": true,
         "chrome_sdk_build_chrome": false,
         "description": "Used for creating/deleting branches (TPMs only)",
diff --git a/cbuildbot/constants.py b/cbuildbot/constants.py
index 7c29bad..f09722e 100644
--- a/cbuildbot/constants.py
+++ b/cbuildbot/constants.py
@@ -394,9 +394,6 @@
 # A builder that kicks off Pre-CQ builders that bless the purest CLs.
 PRE_CQ_LAUNCHER_TYPE = 'priest'
 
-# A builder that cuts and prunes branches.
-CREATE_BRANCH_TYPE = 'gardener'
-
 # Chrome PFQ type.  Incremental build type that builds and validates new
 # versions of Chrome.  Only valid if set with CHROME_REV.  See
 # VALID_CHROME_REVISIONS for more information.
@@ -432,7 +429,6 @@
     CHROME_PFQ_TYPE,
     PFQ_TYPE,
     PRE_CQ_LAUNCHER_TYPE,
-    CREATE_BRANCH_TYPE,
     PAYLOADS_TYPE,
     PROJECT_SDK_TYPE,
 )