Skip to content

Commit

Permalink
Taskcluster: Add dev build and unit tests on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSapin committed Nov 15, 2018
1 parent 79bd98b commit 1c7dbe1
Show file tree
Hide file tree
Showing 2 changed files with 121 additions and 5 deletions.
71 changes: 67 additions & 4 deletions etc/taskcluster/decision_task.py
Expand Up @@ -13,7 +13,8 @@ def main(task_for, mock=False):
if CONFIG.git_ref in ["refs/heads/auto", "refs/heads/try", "refs/heads/try-taskcluster"]:
linux_tidy_unit()
android_arm32()
windows_dev()
windows_unit()
macos_unit()
if mock:
windows_release()
linux_wpt()
Expand All @@ -40,12 +41,15 @@ def main(task_for, mock=False):
"RUSTFLAGS": "-Dwarnings",
"CARGO_INCREMENTAL": "0",
}
linux_build_env = {
unix_build_env = {
"CCACHE": "sccache",
"RUSTC_WRAPPER": "sccache",
"SCCACHE_IDLE_TIMEOUT": "1200",
}
linux_build_env = {
"SHELL": "/bin/dash", # For SpiderMonkey’s build system
}
macos_build_env = {}
windows_build_env = {
"LIB": "%HOMEDRIVE%%HOMEPATH%\\gst\\gstreamer\\1.0\\x86_64\\lib;%LIB%",
}
Expand Down Expand Up @@ -73,6 +77,15 @@ def linux_tidy_unit():
""").create()


def macos_unit():
macos_build_task("macOS x64: dev build + unit tests").with_script("""
./mach build --dev
./mach test-unit
./mach package --dev
./etc/ci/lockfile_changed.sh
""").create()


def with_rust_nightly():
return linux_build_task("Linux x64: with Rust Nightly").with_script("""
echo "nightly" > rust-toolchain
Expand Down Expand Up @@ -123,7 +136,7 @@ def android_x86():
)


def windows_dev():
def windows_unit():
return (
windows_build_task("Windows x64: dev build + unit tests")
.with_script(
Expand Down Expand Up @@ -268,6 +281,14 @@ def windows_task(name):
return WindowsGenericWorkerTask(name).with_worker_type("servo-win2016")


def macos_task(name):
return (
MacOsGenericWorkerTask(name)
.with_provisioner_id("proj-servo")
.with_worker_type("macos")
)


def linux_build_task(name):
return (
linux_task(name)
Expand All @@ -283,7 +304,7 @@ def linux_build_task(name):
.with_index_and_artifacts_expire_in(build_artifacts_expire_in)
.with_max_run_time_minutes(60)
.with_dockerfile(dockerfile_path("build"))
.with_env(**build_env, **linux_build_env)
.with_env(**build_env, **unix_build_env, **linux_build_env)
.with_repo()
.with_index_and_artifacts_expire_in(build_artifacts_expire_in)
)
Expand Down Expand Up @@ -325,6 +346,48 @@ def windows_build_task(name):
)


def macos_build_task(name):
return (
macos_task(name)
# Allow long runtime in case the cache expired for all those Homebrew dependencies
.with_max_run_time_minutes(60 * 2)
.with_env(**build_env, **unix_build_env, **macos_build_env)
.with_repo()
.with_python2()
.with_rustup()
.with_script("""
mkdir -p "$HOME/homebrew"
export PATH="$HOME/homebrew/bin:$PATH"
which homebrew || curl -L https://github.com/Homebrew/brew/tarball/master \
| tar xz --strip 1 -C "$HOME/homebrew"
time brew install automake autoconf@2.13 pkg-config cmake yasm llvm
time brew install gstreamer gst-plugins-base gst-plugins-good gst-plugins-bad \
gst-libav gst-rtsp-server \
--with-orc --with-libogg --with-opus --with-pango --with-theora --with-libvorbis
export OPENSSL_INCLUDE_DIR="$(brew --prefix openssl)/include"
export OPENSSL_LIB_DIR="$(brew --prefix openssl)/lib"
""")

.with_directory_mount(
"https://github.com/mozilla/sccache/releases/download/"
"0.2.7/sccache-0.2.7-x86_64-apple-darwin.tar.gz",
sha256="f86412abbbcce2d3f23e7d33305469198949f5cf807e6c3258c9e1885b4cb57f",
path="sccache",
)
# Early script in order to run with the initial $PWD
.with_early_script("""
export PATH="$PWD/sccache/sccache-0.2.7-x86_64-apple-darwin:$PATH"
""")
# sccache binaries requires OpenSSL 1.1 and are not compatible with 1.0.
# "Late" script in order to run after Homebrew is installed.
.with_script("""
time brew install openssl@1.1
export DYLD_LIBRARY_PATH="$HOME/homebrew/opt/openssl@1.1/lib"
""")
)


CONFIG.task_name_template = "Servo: %s"
CONFIG.index_prefix = "project.servo.servo"
CONFIG.docker_image_buil_worker_type = "servo-docker-worker"
Expand Down
55 changes: 54 additions & 1 deletion etc/taskcluster/decisionlib.py
Expand Up @@ -27,7 +27,7 @@
# Public API
__all__ = [
"CONFIG", "SHARED", "Task", "DockerWorkerTask",
"GenericWorkerTask", "WindowsGenericWorkerTask",
"GenericWorkerTask", "WindowsGenericWorkerTask", "MacOsGenericWorkerTask",
]


Expand Down Expand Up @@ -496,6 +496,59 @@ def with_python2(self):
.with_path_from_homedir("python2", "python2\\Scripts")


class MacOsGenericWorkerTask(GenericWorkerTask):
"""
Task definition for a `generic-worker` task running on macOS.
Scripts are interpreted with `bash`.
"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.scripts = []

with_script = chaining(append_to_attr, "scripts")
with_early_script = chaining(prepend_to_attr, "scripts")

def build_command(self):
# generic-worker accepts multiple commands, but unlike on Windows
# the current directory and environment variables
# are not preserved across commands on macOS.
# So concatenate scripts and use a single `bash` command instead.
return [
[
"/bin/bash", "--login", "-x", "-e", "-c",
deindent("\n".join(self.scripts))
]
]

def with_repo(self):
"""
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`,
and creates the clone in a `repo` directory in the task’s directory.
"""
return self \
.with_env(**git_env()) \
.with_early_script("""
git init repo
cd repo
git fetch --depth 1 "$GIT_URL" "$GIT_REF"
git reset --hard "$GIT_SHA"
""")

def with_python2(self):
return self.with_early_script("""
export PATH="$HOME/Library/Python/2.7/bin:$PATH"
python -m ensurepip --user
pip install --user virtualenv
""")

def with_rustup(self):
return self.with_early_script("""
export PATH="$HOME/.cargo/bin:$PATH"
which rustup || curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain none -y
""")


class DockerWorkerTask(Task):
"""
Expand Down

0 comments on commit 1c7dbe1

Please sign in to comment.