Bug 1372697 - Export MOZ_BUILD_CHANNEL to build tasks; r?glandium draft
authorGregory Szorc <gps@mozilla.com>
Tue, 18 Jul 2017 17:49:43 -0700
changeset 610954 a763b77f455072094165d97a2601c20e7c700f75
parent 610649 dece50457378ac4934afe9fb3c2a8054e8894588
child 610955 8fff22819b8b2e776544ce98f12ead3784cf6753
push id69066
push userbmo:gps@mozilla.com
push dateWed, 19 Jul 2017 00:57:27 +0000
reviewersglandium
bugs1372697
milestone56.0a1
Bug 1372697 - Export MOZ_BUILD_CHANNEL to build tasks; r?glandium Currently, there are a number of places that vary what is built by the repository being built. This behavior is sub-optimal because it makes it difficult to trigger a build configuration outside of a well-defined repository. This commit starts the process of abstracting away these repo-specific differences by introducing a new environment variable: MOZ_BUILD_CHANNEL. This variable defines the channel configuration that we want to build. Right now the variable is populated from the source repository ("project" in taskgraph parlance). But in the future we can change how it is set. The important thing is that the build system can react to the presence of the variable to take conditional actions based on the active channel configuration. The utility of this will be demonstrated in subsequent commits. MozReview-Commit-ID: L9jJQcPCXL8
taskcluster/taskgraph/transforms/build.py
--- a/taskcluster/taskgraph/transforms/build.py
+++ b/taskcluster/taskgraph/transforms/build.py
@@ -4,16 +4,17 @@
 """
 Apply some defaults and minor modifications to the jobs defined in the build
 kind.
 """
 
 from __future__ import absolute_import, print_function, unicode_literals
 
 from taskgraph.transforms.base import TransformSequence
+from taskgraph.util.attributes import TRUNK_PROJECTS
 from taskgraph.util.workertypes import worker_type_implementation
 
 transforms = TransformSequence()
 
 
 @transforms.add
 def set_defaults(config, jobs):
     """Set defaults, including those that differ per worker implementation"""
@@ -47,8 +48,43 @@ def set_env(config, jobs):
     for job in jobs:
         env = config.config['args'].env
         if env:
             job_env = {}
             if 'worker' in job:
                 job_env = job['worker']['env']
             job_env.update(dict(x.split('=') for x in env))
         yield job
+
+
+@transforms.add
+def set_channel_env(config, jobs):
+    """Export the release channel name from the repo triggering this build.
+
+    This is used by the build system to tailor behavior to specific release
+    configurations.
+    """
+    project = config.params['project']
+
+    for job in jobs:
+        if project == 'try' or project in TRUNK_PROJECTS:
+            channel = 'nightly'
+        elif project == 'mozilla-beta':
+            channel = 'beta'
+        elif project == 'mozilla-release':
+            channel = 'release'
+        elif 'esr' in project:
+            # For all intents and purposes ESR uses a release channel
+            # configuration.
+            channel = 'release'
+        # Jamun is currently testing release machinery. Remove once done.
+        elif project == 'jamun':
+            channel = 'release'
+
+        # For everything else, assume a Nightly channel configuration.
+        # This is the most reasonable choice given the purposes of
+        # twigs, etc.
+        else:
+            channel = 'nightly'
+
+        job['worker']['env']['MOZ_BUILD_CHANNEL'] = channel
+
+        yield job