From bc366d01a8b470f2051052fbea883bb4d7ee3b43 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sat, 5 Jan 2019 01:15:29 +0100 Subject: [PATCH] Add a script to run `.taskcluster.yml` expansion offline MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit That file’s logic is getting kinda complex --- etc/taskcluster/decisionlib.py | 1 + etc/taskcluster/simulate_github_events.py | 72 +++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 etc/taskcluster/simulate_github_events.py diff --git a/etc/taskcluster/decisionlib.py b/etc/taskcluster/decisionlib.py index 7d9021c5db2..806ef40589a 100644 --- a/etc/taskcluster/decisionlib.py +++ b/etc/taskcluster/decisionlib.py @@ -265,6 +265,7 @@ class Task: except taskcluster.TaskclusterRestFailure as e: if e.status_code != 404: # pragma: no cover raise + # FIXME: skip for untrusted tasks that don’t have the scope to do this? self.routes.append("index.%s.%s" % (CONFIG.index_prefix, index_path)) task_id = self.create() diff --git a/etc/taskcluster/simulate_github_events.py b/etc/taskcluster/simulate_github_events.py new file mode 100755 index 00000000000..95faa5b34ae --- /dev/null +++ b/etc/taskcluster/simulate_github_events.py @@ -0,0 +1,72 @@ +#!/bin/bash + +# 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 https://mozilla.org/MPL/2.0/. + +''''set -e +cd "$(dirname $0)" +exec ../../python/_virtualenv/bin/python "$(basename $0)" +''' + +try: + import jsone +except ImportError: + import sys + sys.exit("pip install git+https://github.com/taskcluster/json-e") + +import yaml +import json + +template = yaml.load(open("../../.taskcluster.yml").read().decode("utf8")) +repo = dict( + repository=dict( + clone_url="https://github.com/servo/servo.git", + ), +) +contexts = [ + dict( + tasks_for="github-release", + event=repo, + ), + dict( + tasks_for="github-pull-request", + event=dict( + action="comment", + **repo + ), + ), + dict( + tasks_for="github-push", + event=dict( + ref="refs/heads/master", + compare="https://github.com/servo/servo/compare/1753cda...de09c8f", + after="de09c8fb6ef87dec5932d5fab4adcb421d291a54", + pusher=dict( + name="bors-servo", + ), + **repo + ), + ), + dict( + tasks_for="github-pull-request", + event=dict( + action="synchronize", + pull_request=dict( + number=22583, + url="https://github.com/servo/servo/pull/22583", + head=dict( + sha="51a422c9ef47420eb69c802643b7686bdb498652", + ), + merge_commit_sha="876fcf7a5fe971a9ac0a4ce117906c552c08c095", + ), + sender=dict( + login="jdm", + ), + **repo + ), + ), +] +for context in contexts: + print(context["tasks_for"]) + print(json.dumps(jsone.render(template, context), indent=2))