# coding: utf8 # 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 http://mozilla.org/MPL/2.0/. import os.path from decisionlib import * def main(task_for, mock=False): if task_for == "github-push": if CONFIG.git_ref in ["refs/heads/auto", "refs/heads/try", "refs/heads/try-taskcluster"]: linux_tidy_unit() android_arm32() windows_dev() if mock: linux_wpt() # https://tools.taskcluster.net/hooks/project-servo/daily elif task_for == "daily": daily_tasks_setup() with_rust_nightly() android_arm32() else: raise ValueError("Unrecognized $TASK_FOR value: %r", task_for) ping_on_daily_task_failure = "SimonSapin, nox, emilio" build_artifacts_expire_in = "1 week" build_dependencies_artifacts_expire_in = "1 month" log_artifacts_expire_in = "1 year" build_env = { "RUST_BACKTRACE": "1", "RUSTFLAGS": "-Dwarnings", "CARGO_INCREMENTAL": "0", } linux_build_env = { "CCACHE": "sccache", "RUSTC_WRAPPER": "sccache", "SCCACHE_IDLE_TIMEOUT": "1200", "SHELL": "/bin/dash", # For SpiderMonkey’s build system } windows_build_env = {} windows_sparse_checkout = [ "/*", "!/tests/wpt/metadata", "!/tests/wpt/mozilla", "!/tests/wpt/webgl", "!/tests/wpt/web-platform-tests", "/tests/wpt/web-platform-tests/tools", ] def linux_tidy_unit(): return linux_build_task("Linux x86_64: tidy + dev build + unit tests").with_script(""" ./mach test-tidy --no-progress --all ./mach build --dev ./mach test-unit ./mach package --dev ./mach test-tidy --no-progress --self-test python2.7 ./etc/memory_reports_over_time.py --test python3 ./etc/taskcluster/mock.py ./etc/ci/lockfile_changed.sh ./etc/ci/check_no_panic.sh """).create() def with_rust_nightly(): return linux_build_task("Linux x86_64: with Rust Nightly").with_script(""" echo "nightly" > rust-toolchain ./mach build --dev ./mach test-unit """).create() def android_arm32(): return ( linux_build_task("Android ARMv7: build") # file: NDK parses $(file $SHELL) to tell x86_64 from x86 # wget: servo-media-gstreamer’s build script .with_script(""" apt-get install -y --no-install-recommends openjdk-8-jdk-headless file wget ./etc/ci/bootstrap-android-and-accept-licences.sh ./mach build --android --release """) .with_artifacts( "/repo/target/armv7-linux-androideabi/release/servoapp.apk", "/repo/target/armv7-linux-androideabi/release/servoview.aar", ) .find_or_create("build.android_armv7_release." + CONFIG.git_sha) ) def windows_dev(): return ( windows_build_task("Windows x86_64: dev build + unit tests") .with_python2() .with_rustup() .with_repacked_msi( url="https://gstreamer.freedesktop.org/data/pkg/windows/" + "1.14.3/gstreamer-1.0-devel-x86_64-1.14.3.msi", sha256="b13ea68c1365098c66871f0acab7fd3daa2f2795b5e893fcbb5cd7253f2c08fa", path="gst", ) .with_script( "set LIB=%HOMEDRIVE%%HOMEPATH%\\gst\\gstreamer\\1.0\\x86_64\\lib;%LIB%", "call mach.bat build --dev", "call mach.bat test-unit", ) .create() ) def linux_wpt(): release_build_task = linux_release_build() total_chunks = 2 for i in range(total_chunks): this_chunk = i + 1 wpt_chunk(release_build_task, total_chunks, this_chunk, extra=(this_chunk == 1)) def linux_release_build(): return ( linux_build_task("Linux x86_64: release build") .with_script(""" ./mach build --release --with-debug-assertions -p servo ./etc/ci/lockfile_changed.sh tar -czf /target.tar.gz \ target/release/servo \ target/release/build/osmesa-src-*/output \ target/release/build/osmesa-src-*/out/lib/gallium """) .with_artifacts("/target.tar.gz") .find_or_create("build.linux_x86-64_release." + CONFIG.git_sha) ) def wpt_chunk(release_build_task, total_chunks, this_chunk, extra): name = "Linux x86_64: WPT chunk %s / %s" % (this_chunk, total_chunks) script = """ ./mach test-wpt \ --release \ --processes 24 \ --total-chunks "$TOTAL_CHUNKS" \ --this-chunk "$THIS_CHUNK" \ --log-raw test-wpt.log \ --log-errorsummary wpt-errorsummary.log \ --always-succeed ./mach filter-intermittents\ wpt-errorsummary.log \ --log-intermittents intermittents.log \ --log-filteredsummary filtered-wpt-errorsummary.log \ --tracker-api default """ # FIXME: --reporter-api default # IndexError: list index out of range # File "/repo/python/servo/testing_commands.py", line 533, in filter_intermittents # pull_request = int(last_merge.split(' ')[4][1:]) if extra: name += " + extra" script += """ ./mach test-wpt-failure ./mach test-wpt --release --binary-arg=--multiprocess --processes 24 \ --log-raw test-wpt-mp.log \ --log-errorsummary wpt-mp-errorsummary.log \ eventsource """ return ( linux_run_task(name, release_build_task, script) .with_env(TOTAL_CHUNKS=total_chunks, THIS_CHUNK=this_chunk) .create() ) def linux_run_task(name, build_task, script): return ( linux_task(name) .with_dockerfile(dockerfile_path("run")) .with_early_script(""" ./etc/taskcluster/curl-artifact.sh ${BUILD_TASK_ID} target.tar.gz | tar -xz """) .with_env(BUILD_TASK_ID=build_task) .with_dependencies(build_task) .with_script(script) .with_index_and_artifacts_expire_in(log_artifacts_expire_in) .with_artifacts(*[ "/repo/" + word for word in script.split() if word.endswith(".log") ]) .with_max_run_time_minutes(60) ) def daily_tasks_setup(): # ':' is not accepted in an index namepspace: # https://docs.taskcluster.net/docs/reference/core/taskcluster-index/references/api now = SHARED.now.strftime("%Y-%m-%d_%H-%M-%S") index_path = "%s.daily.%s" % (CONFIG.index_prefix, now) # Index this task manually rather than with a route, # so that it is indexed even if it fails. SHARED.index_service.insertTask(index_path, { "taskId": CONFIG.decision_task_id, "rank": 0, "data": {}, "expires": SHARED.from_now_json(log_artifacts_expire_in), }) # Unlike when reacting to a GitHub event, # the commit hash is not known until we clone the repository. CONFIG.git_sha_is_current_head() # On failure, notify a few people on IRC # https://docs.taskcluster.net/docs/reference/core/taskcluster-notify/docs/usage notify_route = "notify.irc-channel.#servo.on-failed" CONFIG.routes_for_all_subtasks.append(notify_route) CONFIG.scopes_for_all_subtasks.append("queue:route:" + notify_route) CONFIG.task_name_template = "Servo daily: %s. On failure, ping: " + ping_on_daily_task_failure def dockerfile_path(name): return os.path.join(os.path.dirname(__file__), "docker", name + ".dockerfile") def linux_task(name): return DockerWorkerTask(name).with_worker_type("servo-docker-worker") def windows_task(name): return WindowsGenericWorkerTask(name).with_worker_type("servo-win2016") def linux_build_task(name): return ( linux_task(name) # https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/caches # FIMXE: move to servo-* cache names .with_scopes("docker-worker:cache:cargo-*") .with_caches(**{ "cargo-registry-cache": "/root/.cargo/registry", "cargo-git-cache": "/root/.cargo/git", "cargo-rustup": "/root/.rustup", "cargo-sccache": "/root/.cache/sccache", }) .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_repo() .with_index_and_artifacts_expire_in(build_artifacts_expire_in) ) def windows_build_task(name): return ( windows_task(name) .with_max_run_time_minutes(60) .with_env(**build_env, **windows_build_env) .with_repo(sparse_checkout=windows_sparse_checkout) ) CONFIG.task_name_template = "Servo: %s" CONFIG.index_prefix = "project.servo.servo" CONFIG.docker_images_expire_in = build_dependencies_artifacts_expire_in CONFIG.repacked_msi_files_expire_in = build_dependencies_artifacts_expire_in if __name__ == "__main__": main(task_for=os.environ["TASK_FOR"])