From 0dad48f54f6fdbb105175f7ad37e28ba4802e455 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Sat, 16 Nov 2019 15:46:22 +0100 Subject: [PATCH] macOS CI: use a cache of github.com/servo/servo Relies on https://github.com/servo/taskcluster-config/pull/6 --- etc/taskcluster/decision_task.py | 19 +++++++++++++------ etc/taskcluster/decisionlib.py | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/etc/taskcluster/decision_task.py b/etc/taskcluster/decision_task.py index 43f8efb35a6..4adedd4505d 100644 --- a/etc/taskcluster/decision_task.py +++ b/etc/taskcluster/decision_task.py @@ -595,7 +595,7 @@ def update_wpt(): "etc/taskcluster/macos/Brewfile-gstreamer", ]) # Pushing the new changes to the git remote requires a full repo clone. - .with_repo(shallow=False) + .with_repo(shallow=False, alternate_object_dir="/var/cache/servo.git/objects") .with_curl_artifact_script(build_task, "target.tar.gz") .with_script(""" export PKG_CONFIG_PATH="$(brew --prefix libffi)/lib/pkgconfig/" @@ -631,19 +631,26 @@ def macos_wpt(): def macos_run_task(name): task = macos_task(name).with_python2() return with_homebrew(task, ["etc/taskcluster/macos/Brewfile-gstreamer"]) - wpt_chunks("macOS x64", macos_run_task, build_task, repo_dir="repo", - total_chunks=6, processes=4) + wpt_chunks( + "macOS x64", + macos_run_task, + build_task, + repo_dir="repo", + repo_kwargs=dict(alternate_object_dir="/var/cache/servo.git/objects"), + total_chunks=6, + processes=4, + ) def wpt_chunks(platform, make_chunk_task, build_task, total_chunks, processes, - repo_dir, chunks="all"): + repo_dir, chunks="all", repo_kwargs={}): if chunks == "all": chunks = [n + 1 for n in range(total_chunks)] for this_chunk in chunks: task = ( make_chunk_task("WPT chunk %s / %s" % (this_chunk, total_chunks)) .with_treeherder(platform, "WPT-%s" % this_chunk) - .with_repo() + .with_repo(**repo_kwargs) .with_curl_artifact_script(build_task, "target.tar.gz") .with_script("tar -xzf target.tar.gz") .with_index_and_artifacts_expire_in(log_artifacts_expire_in) @@ -887,7 +894,7 @@ def macos_build_task(name): # https://github.com/servo/servo/issues/24735 .with_max_run_time_minutes(60 * 2) .with_env(**build_env, **unix_build_env, **macos_build_env) - .with_repo() + .with_repo(alternate_object_dir="/var/cache/servo.git/objects") .with_python2() .with_rustup() # Since macOS workers are long-lived and ~/.rustup kept across tasks: diff --git a/etc/taskcluster/decisionlib.py b/etc/taskcluster/decisionlib.py index 5df33970cd4..488ae989f5c 100644 --- a/etc/taskcluster/decisionlib.py +++ b/etc/taskcluster/decisionlib.py @@ -579,7 +579,7 @@ class UnixTaskMixin(Task): super().__init__(*args, **kwargs) self.curl_scripts_count = 0 - def with_repo(self, shallow=True): + def with_repo(self, shallow=True, alternate_object_dir=None): """ Make a shallow clone the git repository at the start of the task. This uses `CONFIG.git_url`, `CONFIG.git_ref`, and `CONFIG.git_sha` @@ -592,14 +592,25 @@ class UnixTaskMixin(Task): `git` and `ca-certificate` need to be installed in the Docker image. """ + # Not using $GIT_ALTERNATE_OBJECT_DIRECTORIES since it causes + # "object not found - no match for id" errors when Cargo fetches git dependencies + if alternate_object_dir: + self.with_env(ALTERNATE_OBJDIR=alternate_object_dir) return self \ .with_env(**git_env()) \ .with_early_script(""" git init repo cd repo + {alternate} time git fetch --no-tags {depth} "$GIT_URL" "$GIT_REF" time git reset --hard "$GIT_SHA" - """.format(depth="--depth 30" if shallow else "")) + """.format( + depth="--depth 30" if shallow else "", + alternate=( + """echo "$ALTERNATE_OBJDIR" > .git/objects/info/alternates""" + if alternate_object_dir else "" + ) + )) def with_curl_script(self, url, file_path): self.curl_scripts_count += 1