Skip to content
Permalink
Browse files

Decision taks: add artifacts of the repository’s contents

  • Loading branch information
SimonSapin committed Nov 21, 2019
1 parent a11dc70 commit 55a8158d17bb593c74ca771c3ca2d52d6cafafaa
Showing with 30 additions and 1 deletion.
  1. +5 −0 .taskcluster.yml
  2. +5 −0 etc/taskcluster/decision_task.py
  3. +18 −0 etc/taskcluster/decisionlib.py
  4. +2 −1 etc/taskcluster/mock.py
@@ -27,6 +27,11 @@ tasks:
sha256:7471a998e4462638c8d3e2cf0b4a99c9a5c8ca9f2ec0ae01cc069473b35cde10"
features:
taskclusterProxy: true
artifacts:
public/repo.bundle:
type: file
path: /repo.bundle
expires: {$fromNow: '1 day'}
env:
GIT_URL: ${event.repository.clone_url}
TASK_FOR: ${tasks_for}
@@ -10,6 +10,11 @@


def main(task_for):
with decisionlib.make_repo_bundle():
tasks(task_for)


def tasks(task_for):
if CONFIG.git_ref.startswith("refs/heads/"):
branch = CONFIG.git_ref[len("refs/heads/"):]
CONFIG.treeherder_repository_name = "servo-" + (
@@ -14,6 +14,7 @@
"""

import base64
import contextlib
import datetime
import hashlib
import json
@@ -28,6 +29,7 @@
__all__ = [
"CONFIG", "SHARED", "Task", "DockerWorkerTask",
"GenericWorkerTask", "WindowsGenericWorkerTask", "MacOsGenericWorkerTask",
"make_repo_bundle",
]


@@ -842,3 +844,19 @@ def deindent(string):

def url_basename(url):
return url.rpartition("/")[-1]


@contextlib.contextmanager
def make_repo_bundle():
subprocess.check_call(["git", "config", "user.name", "Decision task"])
subprocess.check_call(["git", "config", "user.email", "nobody@mozilla.com"])
tree = subprocess.check_output(["git", "show", CONFIG.git_sha, "--pretty=%T", "--no-patch"])
message = "Shallow version of commit " + CONFIG.git_sha
commit = subprocess.check_output(["git", "commit-tree", tree.strip(), "-m", message])
subprocess.check_call(["git", "update-ref", "refs/heads/shallow", commit.strip()])
subprocess.check_call(["git", "show-ref"])
with subprocess.Popen(["git", "bundle", "create", "../repo.bundle", "refs/heads/shallow"]) as p:
yield
exit_code = p.wait()
if exit_code:
sys.exit(exit_code)
@@ -39,7 +39,7 @@ def findTask(self, path):
stringDate = str
slugId = b"<new id>".lower
Queue = fromNow = MagicMock()
sys.exit = Queue = fromNow = MagicMock()
sys.modules["taskcluster"] = sys.modules[__name__]
sys.dont_write_bytecode = True
os.environ.update(**{k: k for k in "TASK_ID TASK_OWNER TASK_SOURCE GIT_URL GIT_SHA".split()})
@@ -48,6 +48,7 @@ def findTask(self, path):
os.environ["TASKCLUSTER_PROXY_URL"] = "http://taskcluster"
os.environ["NEW_AMI_WORKER_TYPE"] = "-"
import decision_task
decision_task.decisionlib.subprocess = MagicMock()
print("\n# Push:")
decision_task.main("github-push")

0 comments on commit 55a8158

Please sign in to comment.
You can’t perform that action at this time.