Upload to doc.servo.org when merging to master

This commit is contained in:
Simon Sapin 2018-12-07 19:13:16 +01:00
parent a35d16a09c
commit eb21ceaf98
4 changed files with 52 additions and 11 deletions

View file

@ -10,9 +10,11 @@ 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"]:
CONFIG.treeherder_repo_name = "servo-" + CONFIG.git_ref.split("/")[-1]
assert CONFIG.git_ref.startswith("refs/heads/")
branch = CONFIG.git_ref[len("refs/heads/"):]
CONFIG.treeherder_repository_names = ["servo-" + branch]
if branch in ["auto", "try", "try-taskcluster"]:
linux_tidy_unit_docs()
android_arm32_dev()
android_arm32_release()
@ -28,6 +30,11 @@ def main(task_for, mock=False):
linux_build_task("Indexed by task definition").find_or_create()
android_x86_wpt()
if branch == "master":
# Also show these tasks in https://treeherder.mozilla.org/#/jobs?repo=servo-auto
CONFIG.treeherder_repository_names.append("servo-auto")
upload_docs()
# https://tools.taskcluster.net/hooks/project-servo/daily
elif task_for == "daily":
daily_tasks_setup()
@ -100,6 +107,31 @@ def linux_tidy_unit_docs():
)
def upload_docs():
docs_build_task_id = Task.find("docs." + CONFIG.git_sha)
return (
linux_task("Upload docs to GitHub Pages")
.with_treeherder("Linux x64", "DocUpload")
.with_dockerfile(dockerfile_path("base"))
.with_curl_artifact_script(docs_build_task_id, "docs.bundle")
.with_features("taskclusterProxy")
.with_scopes("secrets:get:project/servo/doc.servo.org")
.with_env(PY="""if 1:
import urllib, json
url = "http://taskcluster/secrets/v1/secret/project/servo/doc.servo.org"
token = json.load(urllib.urlopen(url))["secret"]["token"]
open("/root/.git-credentials", "w").write("https://git:%s@github.com/" % token)
""")
.with_script("""
python -c "$PY"
git init --bare
git config credential.helper store
git fetch --quiet docs.bundle
git push --force https://github.com/servo/doc.servo.org FETCH_HEAD:gh-pages
""")
.create()
)
def macos_unit():
return (
macos_build_task("Dev build + unit tests")

View file

@ -43,7 +43,7 @@ class Config:
self.docker_image_buil_worker_type = None
self.docker_images_expire_in = "1 month"
self.repacked_msi_files_expire_in = "1 month"
self.treeherder_repo_name = None
self.treeherder_repository_names = []
# Set by docker-worker:
# https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/environment
@ -156,9 +156,9 @@ class Task:
"symbol": symbol,
})
if CONFIG.treeherder_repo_name:
for repo in CONFIG.treeherder_repository_names:
assert CONFIG.git_sha
suffix = ".v2._/%s.%s" % (CONFIG.treeherder_repo_name, CONFIG.git_sha)
suffix = ".v2._/%s.%s" % (repo, CONFIG.git_sha)
self.with_routes(
"tc-treeherder" + suffix,
"tc-treeherder-staging" + suffix,
@ -223,6 +223,11 @@ class Task:
print("Scheduled %s" % self.name)
return task_id
@staticmethod
def find(index_path):
full_index_path = "%s.%s" % (CONFIG.index_prefix, index_path)
return SHARED.index_service.findTask(full_index_path)["taskId"]
def find_or_create(self, index_path=None):
"""
Try to find a task in the Index and return its ID.
@ -240,18 +245,17 @@ class Task:
worker_type = self.worker_type
index_by = json.dumps([worker_type, self.build_worker_payload()]).encode("utf-8")
index_path = "by-task-definition." + hashlib.sha256(index_by).hexdigest()
index_path = "%s.%s" % (CONFIG.index_prefix, index_path)
task_id = SHARED.found_or_created_indexed_tasks.get(index_path)
if task_id is not None:
return task_id
try:
task_id = SHARED.index_service.findTask(index_path)["taskId"]
task_id = Task.find(index_path)
except taskcluster.TaskclusterRestFailure as e:
if e.status_code != 404: # pragma: no cover
raise
self.routes.append("index." + index_path)
self.routes.append("index.%s.%s" % (CONFIG.index_prefix, index_path))
task_id = self.create()
SHARED.found_or_created_indexed_tasks[index_path] = task_id

View file

@ -31,7 +31,9 @@ class TaskclusterRestFailure(Exception):
class Index:
__init__ = insertTask = lambda *_, **__: None
def findTask(self, _):
def findTask(self, path):
if ".docs." in path:
return {"taskId": ""}
raise TaskclusterRestFailure
@ -50,5 +52,9 @@ decision_task.main("github-push", mock=True)
print("\n# Push with hot caches:")
decision_task.main("github-push", mock=True)
print("\n# Push to master:")
decision_task.CONFIG.git_ref = "refs/heads/master"
decision_task.main("github-push", mock=True)
print("\n# Daily:")
decision_task.main("daily", mock=True)