Bug 1384210 - Add comm-central checkout support to taskcluster's run-task; r?dustin draft
authorTom Prince <mozilla@hocat.ca>
Tue, 25 Jul 2017 10:17:03 -0600
changeset 615320 fc6a9b92f7b62c47265e6d3c91a7bcb8840d7192
parent 615176 32d9d1e81cc607320a36391845917f645f7a7f72
child 639137 0b9a7589e029245a199cfb7178ad79fa27e27bb0
push id70311
push userbmo:mozilla@hocat.ca
push dateTue, 25 Jul 2017 19:44:22 +0000
reviewersdustin
bugs1384210
milestone56.0a1
Bug 1384210 - Add comm-central checkout support to taskcluster's run-task; r?dustin MozReview-Commit-ID: LxjYLdzmNO3
taskcluster/docker/recipes/run-task
--- a/taskcluster/docker/recipes/run-task
+++ b/taskcluster/docker/recipes/run-task
@@ -172,16 +172,18 @@ def main(args):
     # dropped. This is often necessary for caches/volumes, since they default
     # to root:root ownership.
     parser.add_argument('--chown', action='append',
                         help='Directory to chown to --user:--group')
     parser.add_argument('--chown-recursive', action='append',
                         help='Directory to recursively chown to --user:--group')
     parser.add_argument('--vcs-checkout',
                         help='Directory where Gecko checkout should be created')
+    parser.add_argument('--comm-checkout',
+                        help='Directory where Comm checkout should be created')
     parser.add_argument('--tools-checkout',
                         help='Directory where build/tools checkout should be created')
     parser.add_argument('--fetch-hgfingerprint', action='store_true',
                         help='Fetch the latest hgfingerprint from the secrets store, '
                         'using the taskclsuerProxy')
 
     args = parser.parse_args(our_args)
 
@@ -340,16 +342,36 @@ def main(args):
     if args.tools_checkout:
         vcs_checkout(b'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=b'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:
+        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
+
     return run_and_prefix_output(b'task', task_args)
 
 
 if __name__ == '__main__':
     # Unbuffer stdio.
     sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
     sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)