From 947c01ea257a763a92b1438f1630f0288a490d52 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 24 Sep 2018 15:28:04 +0200 Subject: [PATCH] Add support for daily builds https://tools.taskcluster.net/hooks/project-servo/daily --- .taskcluster.yml | 8 +++++++- etc/ci/taskcluster/decision-task.py | 32 ++++++++++++++++++++++++++--- etc/ci/taskcluster/mock.py | 6 ++++-- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/.taskcluster.yml b/.taskcluster.yml index 7cd50c26675..5af791d6b8f 100644 --- a/.taskcluster.yml +++ b/.taskcluster.yml @@ -7,6 +7,10 @@ tasks: then: $if: 'event.ref in ["refs/heads/auto", "refs/heads/try"]' then: + + # NOTE: when updating this consider whether the daily hook needs similar changes: + # https://tools.taskcluster.net/hooks/project-servo/daily + taskGroupId: {$eval: as_slugid("decision_task")} taskId: {$eval: as_slugid("decision_task")} provisionerId: aws-provisioner-v1 @@ -14,7 +18,7 @@ tasks: created: {$fromNow: ''} deadline: {$fromNow: '1 day'} metadata: - name: "Servo: decision task" + name: "Servo: GitHub push decision task" description: "" owner: &task_owner ${event.pusher.name}@users.noreply.github.com source: &task_source ${event.compare} @@ -36,11 +40,13 @@ tasks: GIT_URL: ${event.repository.clone_url} GIT_REF: ${event.ref} GIT_SHA: ${event.after} + TASK_FOR: ${tasks_for} TASK_OWNER: *task_owner TASK_SOURCE: *task_source command: - /bin/bash - '--login' + - '-e' - '-c' - >- git init repo && diff --git a/etc/ci/taskcluster/decision-task.py b/etc/ci/taskcluster/decision-task.py index ede6baeb82e..de149db9fad 100644 --- a/etc/ci/taskcluster/decision-task.py +++ b/etc/ci/taskcluster/decision-task.py @@ -4,14 +4,28 @@ # 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/. - import os.path +import subprocess from decisionlib import DecisionTask def main(): - linux_tidy_unit() -# linux_wpt() + task_for = os.environ["TASK_FOR"] + + if task_for == "github-push": + linux_tidy_unit() + #linux_wpt() + + # https://tools.taskcluster.net/hooks/project-servo/daily + elif task_for == "daily": + # Unlike when reacting to a GitHub event, + # the commit hash is not known until we clone the repository. + os.environ["GIT_SHA"] = \ + subprocess.check_output(["git", "rev-parse", "HEAD"]).decode("utf8").strip() + with_rust_nightly() + + else: + raise ValueError("Unrecognized $TASK_FOR value: %r", task_for) build_artifacts_expiry = "1 week" @@ -45,6 +59,18 @@ def linux_tidy_unit(): ) +def with_rust_nightly(): + return decision.create_task( + task_name="Linux x86_64: with Rust Nightly", + script=""" + echo "nightly" > rust-toolchain + ./mach build --dev + ./mach test-unit + """, + **build_kwargs + ) + + def linux_wpt(): release_build_task = linux_release_build() total_chunks = 2 diff --git a/etc/ci/taskcluster/mock.py b/etc/ci/taskcluster/mock.py index dc0ba65b192..2060521a994 100755 --- a/etc/ci/taskcluster/mock.py +++ b/etc/ci/taskcluster/mock.py @@ -15,6 +15,7 @@ Run the decision task with fake Taskcluster APIs, to catch Python errors before import os import sys +import collections from unittest.mock import MagicMock @@ -30,7 +31,8 @@ class Index: raise TaskclusterRestFailure -Queue = stringDate = fromNow = slugId = os.environ = MagicMock() +Queue = stringDate = fromNow = slugId = MagicMock() +os.environ = collections.defaultdict(str, TASK_FOR="github-push") sys.modules["taskcluster"] = sys.modules[__name__] sys.dont_write_bytecode = True -exec(open("decision-task.py").read()) +exec(open(os.path.join(os.path.dirname(__file__), "decision-task.py")).read())