From 1dadb3eea114329cf70ae29531b5451ba82cfc4a Mon Sep 17 00:00:00 2001 From: Gregory Szorc Date: Fri, 29 Jul 2016 20:53:21 -0700 Subject: [PATCH] Bug 1290620 - Implement a run-task wrapper script; r=dustin Before, we simply executed scripts inside Docker containers. This frequently resulted in a wall of text with command output. It was difficult to discern things like the time spent performing certain actions. Before, individual tasks had to drop permissions from the default root user themselves. Dropping permissions isn't exactly a trivial thing to do and a number of tasks didn't do it or did it wrong. Before, we had a "checkout-gecko-and-run" script that kinda/sorta did common activities for us. But it was written as a shell script and doing advanced things was difficult. This commit can be treated as a rewrite of "checkout-gecko-and-run" as a Python script. But it also does a bit more. It prefixes output with timestamps so we know how long operations took. It features more robust argument parsing, so we can add new features more easily. To prove the new wrapper script works, the lint image and all tasks using it have been converted to use it. MozReview-Commit-ID: 5d95u5Xebtq --HG-- extra : rebase_source : 3a1d84782b01d7743e846bd0c04d7867813dd8a3 --- .../ci/legacy/tasks/tests/eslint-gecko.yml | 5 +- .../legacy/tasks/tests/mozharness-gecko.yml | 5 +- .../ci/legacy/tasks/tests/mozlint-flake8.yml | 5 +- .../ci/legacy/tasks/tests/taskgraph-tests.yml | 5 +- testing/docker/lint/Dockerfile | 4 +- testing/docker/recipes/install-mercurial.sh | 3 + testing/docker/recipes/run-task | 168 ++++++++++++++++++ 7 files changed, 185 insertions(+), 10 deletions(-) create mode 100755 testing/docker/recipes/run-task diff --git a/taskcluster/ci/legacy/tasks/tests/eslint-gecko.yml b/taskcluster/ci/legacy/tasks/tests/eslint-gecko.yml index df70df678326..0726020d2b2d 100644 --- a/taskcluster/ci/legacy/tasks/tests/eslint-gecko.yml +++ b/taskcluster/ci/legacy/tasks/tests/eslint-gecko.yml @@ -20,8 +20,9 @@ task: task-reference: "" command: - - /home/worker/bin/checkout-gecko-and-run - - /home/worker/checkouts/gecko + - /home/worker/bin/run-task + - '--vcs-checkout=/home/worker/checkouts/gecko' + - '--' - bash - -cx - > diff --git a/taskcluster/ci/legacy/tasks/tests/mozharness-gecko.yml b/taskcluster/ci/legacy/tasks/tests/mozharness-gecko.yml index cb05566b8edb..b6a74cc56dc5 100644 --- a/taskcluster/ci/legacy/tasks/tests/mozharness-gecko.yml +++ b/taskcluster/ci/legacy/tasks/tests/mozharness-gecko.yml @@ -26,8 +26,9 @@ task: level-{{level}}-{{project}}-dotcache: '/home/worker/.cache' command: - - /home/worker/bin/checkout-gecko-and-run - - /home/worker/checkouts/gecko + - /home/worker/bin/run-task + - '--vcs-checkout=/home/worker/checkouts/gecko' + - '--' - bash - -cx - > diff --git a/taskcluster/ci/legacy/tasks/tests/mozlint-flake8.yml b/taskcluster/ci/legacy/tasks/tests/mozlint-flake8.yml index 05b00a3f6a3c..1b7cce17db9e 100644 --- a/taskcluster/ci/legacy/tasks/tests/mozlint-flake8.yml +++ b/taskcluster/ci/legacy/tasks/tests/mozlint-flake8.yml @@ -18,8 +18,9 @@ task: taskId: task-reference: "" command: - - /home/worker/bin/checkout-gecko-and-run - - /home/worker/checkouts/gecko + - /home/worker/bin/run-task + - '--vcs-checkout=/home/worker/checkouts/gecko' + - '--' - bash - -cx - > diff --git a/taskcluster/ci/legacy/tasks/tests/taskgraph-tests.yml b/taskcluster/ci/legacy/tasks/tests/taskgraph-tests.yml index 6a2ab63a9914..a78e4f11450d 100644 --- a/taskcluster/ci/legacy/tasks/tests/taskgraph-tests.yml +++ b/taskcluster/ci/legacy/tasks/tests/taskgraph-tests.yml @@ -18,8 +18,9 @@ task: taskId: task-reference: "" command: - - /home/worker/bin/checkout-gecko-and-run - - /home/worker/checkouts/gecko + - /home/worker/bin/run-task + - '--vcs-checkout=/home/worker/checkouts/gecko' + - '--' - bash - -cx - > diff --git a/testing/docker/lint/Dockerfile b/testing/docker/lint/Dockerfile index 26d64ee9d162..4a8bae631b9f 100644 --- a/testing/docker/lint/Dockerfile +++ b/testing/docker/lint/Dockerfile @@ -13,8 +13,8 @@ ADD topsrcdir/testing/docker/recipes/install-mercurial.sh /build/install-mercuri 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 +# %include testing/docker/recipes/run-task +ADD topsrcdir/testing/docker/recipes/run-task /home/worker/bin/run-task 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 diff --git a/testing/docker/recipes/install-mercurial.sh b/testing/docker/recipes/install-mercurial.sh index bc1ea620266c..c15d63088efd 100644 --- a/testing/docker/recipes/install-mercurial.sh +++ b/testing/docker/recipes/install-mercurial.sh @@ -45,9 +45,12 @@ mkdir -p /etc/mercurial cat >/etc/mercurial/hgrc <