Bug 1247168 - Add a script to perform a checkout then run a command; r=dustin
authorGregory Szorc <gps@mozilla.com>
Thu, 21 Jul 2016 14:57:37 -0700
changeset 331581 423fef62913f01b290bc71b059f3f2c22551e389
parent 331580 cab3a2a82ac02633e14c31e4bc62d35f16ac15b6
child 331582 b4c3e613fee80fdec958f103d7b8deb62346b547
push id9858
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 14:37:10 +0000
treeherdermozilla-aurora@203106ef6cb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Bug 1247168 - Add a script to perform a checkout then run a command; r=dustin The script will be used as the main command in task YAML files. It changes ownership of caches. Then switches to the "worker" user. Then performs a Gecko checkout. Then executes whatever command was requested via its arguments. The script has been added to the shared recipes directory so it can eventually be used by other Docker images. This means if we e.g. want to add Git support, we only need to update one file in the tree. MozReview-Commit-ID: Fuy1VrdSGYn
--- a/testing/docker/lint/Dockerfile
+++ b/testing/docker/lint/Dockerfile
@@ -8,16 +8,20 @@ RUN mkdir /build
 # %include testing/docker/decision/tooltool.py
 ADD topsrcdir/testing/docker/decision/tooltool.py /build/tooltool.py
 # %include testing/docker/recipes/install-mercurial.sh
 ADD topsrcdir/testing/docker/recipes/install-mercurial.sh /build/install-mercurial.sh
 ADD system-setup.sh /tmp/system-setup.sh
 RUN bash /tmp/system-setup.sh
+# %include testing/docker/recipes/checkout-gecko-and-run
+ADD topsrcdir/testing/docker/recipes/checkout-gecko-and-run /home/worker/bin/checkout-gecko-and-run
+RUN chown -R worker:worker /home/worker/bin && chmod 755 /home/worker/bin/*
 # Set variable normally configured at login, by the shells parent process, these
 # are taken from GNU su manual
 ENV           HOME          /home/worker
 ENV           SHELL         /bin/bash
 ENV           USER          worker
 ENV           LOGNAME       worker
 ENV           HOSTNAME      taskcluster-worker
 ENV           LANG          en_US.UTF-8
new file mode 100755
--- /dev/null
+++ b/testing/docker/recipes/checkout-gecko-and-run
@@ -0,0 +1,37 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+set -ex
+# The script starts executing as root. We need to change ownership
+# of the caches because they are initially owned by root:root. There
+# may not be a cache mount/directory on some instances. So create the
+# directory if missing.
+if [ $(id -u) = 0 ]; then
+    mkdir -p /home/worker/workspace
+    chown worker:worker /home/worker/hg-shared /home/worker/workspace
+    exec sudo -E -u worker ${0} "${@}"
+# We set the base repository to mozilla-central so tc-vcs doesn't get
+# confused. Switch to mozilla-unified because robustcheckout works best
+# with it.
+if [ "${GECKO_BASE_REPOSITORY}" = "https://hg.mozilla.org/mozilla-central" ]; then
+    GECKO_BASE_REPOSITORY=https://hg.mozilla.org/mozilla-unified
+/usr/bin/hg robustcheckout \
+    --sharebase /home/worker/hg-shared \
+    --purge \
+    --upstream ${GECKO_BASE_REPOSITORY} \
+    --revision ${GECKO_HEAD_REV} \
+    ${DEST}
+exec "${@}"