Bug 1512188 - Collect environment variables into VCS options; r=tomprince
☠☠ backed out by f3fead0d1dc7 ☠ ☠
authorGregory Szorc <gps@mozilla.com>
Tue, 11 Dec 2018 19:50:54 +0000
changeset 450120 6bd036a5166d0a9680db181642a06f3829f502dd
parent 450119 3bcedff402fa8b507da241b122c9e8d7d4f6796e
child 450121 838f49d718a7688dc914c8fca4384de6add1e75b
push id35190
push userccoroiu@mozilla.com
push dateWed, 12 Dec 2018 05:10:47 +0000
treeherdermozilla-central@5bcbe5232a26 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstomprince
bugs1512188
milestone66.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1512188 - Collect environment variables into VCS options; r=tomprince This makes behavior consistent across all VCS checkouts. I'm still not a fan of using environment variables here. But at least this gets us 1 step closer to being able to plug alternate logic in without having to update use of environment variables outside a single function. Differential Revision: https://phabricator.services.mozilla.com/D13816
taskcluster/scripts/run-task
--- a/taskcluster/scripts/run-task
+++ b/taskcluster/scripts/run-task
@@ -503,29 +503,40 @@ def add_vcs_arguments(parser, project, n
 
     parser.add_argument('--%s-checkout' % project,
                         help='Directory where %s checkout should be created' %
                              name)
     parser.add_argument('--%s-sparse-profile' % project,
                         help='Path to sparse profile for %s checkout' % name)
 
 
-def collect_vcs_options(args, project):
+def collect_vcs_options(args, project, env_prefix=None):
     checkout = getattr(args, '%s_checkout' % project)
     sparse_profile = getattr(args, '%s_sparse_profile' % project)
 
     if not checkout:
         return None
 
+    env_prefix = env_prefix or project.upper()
+
+    base_repo = os.environ.get('%s_BASE_REPOSITORY' % env_prefix)
+    head_repo = os.environ.get('%s_HEAD_REPOSITORY' % env_prefix)
+    revision = os.environ.get('%s_HEAD_REV' % env_prefix)
+    branch = os.environ.get('%s_HEAD_REF' % env_prefix)
+
     checkout = os.path.expanduser(checkout)
 
     return {
         'project': project,
         'checkout': checkout,
         'sparse-profile': sparse_profile,
+        'base-repo': base_repo,
+        'head-repo': head_repo,
+        'revision': revision,
+        'branch': branch,
     }
 
 
 def main(args):
     print_line(b'setup', b'run-task started in %s\n' % os.getcwd().encode('utf-8'))
     running_as_root = IS_POSIX and os.getuid() == 0
 
     # Arguments up to '--' are ours. After are for the main task
@@ -702,34 +713,34 @@ def main(args):
         os.umask(0o22)
         os.setresgid(gid, gid, gid)
         os.setresuid(uid, uid, uid)
 
     # Checkout the repository, setting the GECKO_HEAD_REV to the current
     # revision hash. Revision hashes have priority over symbolic revisions. We
     # disallow running tasks with symbolic revisions unless they have been
     # resolved by a checkout.
-    firefox_checkout = collect_vcs_options(args, 'firefox')
+    firefox_checkout = collect_vcs_options(args, 'firefox', env_prefix='GECKO')
 
     if firefox_checkout:
-        base_repo = os.environ.get('GECKO_BASE_REPOSITORY')
+        base_repo = firefox_checkout['base-repo']
         # Some callers set the base repository to mozilla-central for historical
         # reasons. Switch to mozilla-unified because robustcheckout works best
         # with it.
         if base_repo == 'https://hg.mozilla.org/mozilla-central':
             base_repo = 'https://hg.mozilla.org/mozilla-unified'
 
         os.environ['GECKO_HEAD_REV'] = vcs_checkout(
-            os.environ['GECKO_HEAD_REPOSITORY'],
+            firefox_checkout['head-repo'],
             firefox_checkout['checkout'],
             os.environ['HG_STORE_PATH'],
             fetch_hgfingerprint=args.fetch_hgfingerprint,
             base_repo=base_repo,
-            revision=os.environ.get('GECKO_HEAD_REV'),
-            branch=os.environ.get('GECKO_HEAD_REF'),
+            revision=firefox_checkout['revision'],
+            branch=firefox_checkout['branch'],
             sparse_profile=firefox_checkout['sparse-profile'])
 
     elif not os.environ.get('GECKO_HEAD_REV') and \
             os.environ.get('GECKO_HEAD_REF'):
         print('task should be defined in terms of non-symbolic revision')
         return 1
 
     tools_checkout = collect_vcs_options(args, 'tools')
@@ -745,26 +756,24 @@ def main(args):
                      sparse_profile=tools_checkout['sparse-profile'])
 
     # Checkout the repository, setting the COMM_HEAD_REV to the current
     # revision hash. Revision hashes have priority over symbolic revisions. We
     # disallow running tasks with symbolic revisions unless they have been
     # resolved by a checkout.
     comm_checkout = collect_vcs_options(args, 'comm')
     if comm_checkout:
-        base_repo = os.environ.get('COMM_BASE_REPOSITORY')
-
         os.environ['COMM_HEAD_REV'] = vcs_checkout(
-            os.environ['COMM_HEAD_REPOSITORY'],
+            comm_checkout['head-repo'],
             comm_checkout['checkout'],
             os.environ['HG_STORE_PATH'],
             fetch_hgfingerprint=args.fetch_hgfingerprint,
-            base_repo=base_repo,
-            revision=os.environ.get('COMM_HEAD_REV'),
-            branch=os.environ.get('COMM_HEAD_REF'),
+            base_repo=comm_checkout['base-repo'],
+            revision=comm_checkout['revision'],
+            branch=comm_checkout['branch'],
             sparse_profile=comm_checkout['sparse-profile'])
 
     elif not os.environ.get('COMM_HEAD_REV') and \
             os.environ.get('COMM_HEAD_REF'):
         print('task should be defined in terms of non-symbolic revision')
         return 1
 
     try: