Bug 1462791 - Remove GECKO_HEAD_REF and COMM_HEAD_REF; r?dustin, aki draft
authorGregory Szorc <gps@mozilla.com>
Mon, 23 Apr 2018 13:36:45 -0700
changeset 797289 402cb1856723852f56ed500e142860176a2ad418
parent 797288 ec52aa9c980c2b7aa4241727f5b72642d0e2af9c
child 797290 1e6485b9db18f8e5f6667cf8c4a46197669a1389
push id110444
push userbmo:gps@mozilla.com
push dateFri, 18 May 2018 20:22:48 +0000
reviewersdustin, aki
bugs1462791
milestone62.0a1
Bug 1462791 - Remove GECKO_HEAD_REF and COMM_HEAD_REF; r?dustin, aki `hg robustcheckout` supports checking out a specific revision hash or a symbolic revision name. These are defined by the environment variables GECKO_HEAD_REV and GECKO_HEAD_REF, respectively. In CI, we should *always* be using full revisions because they are non-ambiguous (a symbolic name can change over time whereas hashes can't). AFAICT we are not actually using symbolic names and GECKO_HEAD_REF anywhere. So this commit drops defining and consuming it. COMM_HEAD_REF was nuked as well because it is in the same boat. MozReview-Commit-ID: AfD9s3lA5Tr
.taskcluster.yml
taskcluster/scripts/run-task
taskcluster/scripts/tester/run-wizard
taskcluster/taskgraph/cron/util.py
taskcluster/taskgraph/transforms/job/common.py
taskcluster/taskgraph/transforms/marionette_harness.py
--- a/.taskcluster.yml
+++ b/.taskcluster.yml
@@ -92,17 +92,16 @@ tasks:
 
       payload:
         env:
           # checkout-gecko uses these to check out the source; the inputs
           # to `mach taskgraph decision` are all on the command line.
           $merge:
             - GECKO_BASE_REPOSITORY: 'https://hg.mozilla.org/mozilla-unified'
               GECKO_HEAD_REPOSITORY: '${repoUrl}'
-              GECKO_HEAD_REF: '${push.revision}'
               GECKO_HEAD_REV: '${push.revision}'
               GECKO_COMMIT_MSG: {$if: 'tasks_for != "action"', then: '${push.comment}'}
               HG_STORE_PATH: /builds/worker/checkouts/hg-store
               TASKCLUSTER_CACHES: /builds/worker/checkouts
             - $if: 'tasks_for == "action"'
               then:
                 ACTION_TASK_GROUP_ID: '${ownTaskId}'
                 ACTION_TASK_ID: {$json: {$eval: 'taskId'}}
--- a/taskcluster/scripts/run-task
+++ b/taskcluster/scripts/run-task
@@ -658,62 +658,60 @@ def main(args):
         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.
     if args.vcs_checkout:
+        if not os.environ.get('GECKO_HEAD_REV'):
+            print('GECKO_HEAD_REV not defined; set this variable to the full '
+                  'revision to use')
+            return 1
+
         base_repo = os.environ.get('GECKO_BASE_REPOSITORY')
         # 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'],
             args.vcs_checkout,
             os.environ['HG_STORE_PATH'],
             base_repo=base_repo,
             revision=os.environ.get('GECKO_HEAD_REV'),
-            branch=os.environ.get('GECKO_HEAD_REF'),
             sparse_profile=args.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
-
     if args.tools_checkout:
         vcs_checkout('https://hg.mozilla.org/build/tools',
                      args.tools_checkout,
                      os.environ['HG_STORE_PATH'],
                      # Always check out the latest commit on default branch.
                      # This is non-deterministic!
                      branch='default')
 
     # 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.
     if args.comm_checkout:
+        if not os.environ.get('COMM_HEAD_REV'):
+            print('COMM_HEAD_REV not defined; set this variable to the full '
+                  'revision to use')
+            return 1
+
         base_repo = os.environ.get('COMM_BASE_REPOSITORY')
 
         os.environ['COMM_HEAD_REV'] = vcs_checkout(
             os.environ['COMM_HEAD_REPOSITORY'],
             args.comm_checkout,
             os.environ['HG_STORE_PATH'],
             base_repo=base_repo,
-            revision=os.environ.get('COMM_HEAD_REV'),
-            branch=os.environ.get('COMM_HEAD_REF'))
-
-    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
+            revision=os.environ.get('COMM_HEAD_REV'))
 
     return run_and_prefix_output(b'task', task_args)
 
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv[1:]))
--- a/taskcluster/scripts/tester/run-wizard
+++ b/taskcluster/scripts/tester/run-wizard
@@ -89,19 +89,16 @@ def clone():
     dest = os.path.expanduser(os.path.join('~', 'gecko'))
 
     # Specify method to checkout a revision. This defaults to revisions as
     # SHA-1 strings, but also supports symbolic revisions like `tip` via the
     # branch flag.
     if os.environ.get('GECKO_HEAD_REV'):
         revision_flag = b'--revision'
         revision = os.environ['GECKO_HEAD_REV']
-    elif os.environ.get('GECKO_HEAD_REF'):
-        revision_flag = b'--branch'
-        revision = os.environ['GECKO_HEAD_REF']
     else:
         print('revision is not specified for checkout')
         return 1
 
     # TODO Bug 1301382 - pin hg.mozilla.org fingerprint.
     call([
         b'/usr/bin/hg', b'robustcheckout',
         b'--sharebase', os.environ['HG_STORE_PATH'],
--- a/taskcluster/taskgraph/cron/util.py
+++ b/taskcluster/taskgraph/cron/util.py
@@ -37,11 +37,11 @@ def match_utc(params, sched):
         # don't accept other values.
         return False
 
     return True
 
 
 def calculate_head_rev(root):
     # we assume that run-task has correctly checked out the revision indicated by
-    # GECKO_HEAD_REF, so all that remains is to see what the current revision is.
-    # Mercurial refers to that as `.`.
+    # GECKO_HEAD_REV, so all that remains is to see what the current revision
+    # is. Mercurial refers to that as `.`.
     return subprocess.check_output(['hg', 'log', '-r', '.', '-T', '{node}'], cwd=root)
--- a/taskcluster/taskgraph/transforms/job/common.py
+++ b/taskcluster/taskgraph/transforms/job/common.py
@@ -57,25 +57,23 @@ def generic_worker_add_artifacts(config,
     add_artifacts(config, job, taskdesc, path=get_artifact_prefix(taskdesc))
 
 
 def docker_worker_add_gecko_vcs_env_vars(config, job, taskdesc):
     """Add the GECKO_BASE_* and GECKO_HEAD_* env vars to the worker."""
     env = taskdesc['worker'].setdefault('env', {})
     env.update({
         'GECKO_BASE_REPOSITORY': config.params['base_repository'],
-        'GECKO_HEAD_REF': config.params['head_rev'],
         'GECKO_HEAD_REPOSITORY': config.params['head_repository'],
         'GECKO_HEAD_REV': config.params['head_rev'],
     })
 
     if 'comm_base_repository' in config.params:
         taskdesc['worker']['env'].update({
             'COMM_BASE_REPOSITORY': config.params['comm_base_repository'],
-            'COMM_HEAD_REF': config.params['comm_head_rev'],
             'COMM_HEAD_REPOSITORY': config.params['comm_head_repository'],
             'COMM_HEAD_REV': config.params['comm_head_rev'],
         })
 
 
 def support_vcs_checkout(config, job, taskdesc, sparse=False):
     """Update a job/task with parameters to enable a VCS checkout.
 
--- a/taskcluster/taskgraph/transforms/marionette_harness.py
+++ b/taskcluster/taskgraph/transforms/marionette_harness.py
@@ -15,16 +15,15 @@ transforms = TransformSequence()
 @transforms.add
 def setup_task(config, tasks):
     for task in tasks:
         del task['name']
         task['label'] = 'marionette-harness'
         env = task['worker'].setdefault('env', {})
         env.update({
             'GECKO_BASE_REPOSITORY': config.params['base_repository'],
-            'GECKO_HEAD_REF': config.params['head_rev'],
             'GECKO_HEAD_REPOSITORY': config.params['head_repository'],
             'GECKO_HEAD_REV': config.params['head_rev'],
             'MOZ_BUILD_DATE': config.params['moz_build_date'],
             'MOZ_SCM_LEVEL': config.params['level'],
         })
 
         yield task