Auto merge of #24662 - servo:tc-urls, r=jdm

Run a decision task on both TC deployments
This commit is contained in:
bors-servo 2019-11-05 18:56:49 -05:00 committed by GitHub
commit 748f10dfc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 25 additions and 27 deletions

View file

@ -22,7 +22,8 @@ tasks:
payload:
maxRunTime: {$eval: '20 * 60'}
# https://github.com/servo/taskcluster-bootstrap-docker-images#decision-task
image: "servobrowser/taskcluster-bootstrap:decision-task@sha256:28045b7ec0485ef363f8cb14f194008b47e9ede99f2ea40a1e945e921fce976e"
image: "servobrowser/taskcluster-bootstrap:decision-task@\
sha256:7471a998e4462638c8d3e2cf0b4a99c9a5c8ca9f2ec0ae01cc069473b35cde10"
features:
taskclusterProxy: true
env:
@ -47,18 +48,7 @@ tasks:
$if: "event.ref[:11] == 'refs/heads/'"
then: "${event.ref[11:]}"
in:
$if: >-
(
taskcluster_root_url == 'https://community-tc.services.mozilla.com' &&
branch == 'try-communitytc'
) || (
taskcluster_root_url == 'https://taskcluster.net' &&
branch != 'try-communitytc' &&
(
branch in ['auto', 'try', 'master'] ||
branch[:4] == 'try-'
)
)
$if: "branch in ['auto', 'try', 'master'] || branch[:4] == 'try-'"
then:
$mergeDeep:
- {$eval: "task_common"}

View file

@ -100,7 +100,7 @@ function unsafe_open_pull_request() {
git checkout "${BRANCH_NAME}" || return 0
if [[ -z "${WPT_SYNC_TOKEN+set}" && "${TASKCLUSTER_PROXY_URL+set}" == "set" ]]; then
SECRET_RESPONSE=$(curl ${TASKCLUSTER_PROXY_URL}/secrets/v1/secret/project/servo/wpt-sync)
SECRET_RESPONSE=$(curl ${TASKCLUSTER_PROXY_URL}/api/secrets/v1/secret/project/servo/wpt-sync)
WPT_SYNC_TOKEN=`echo "${SECRET_RESPONSE}" | jq --raw-output '.secret.token'`
fi

View file

@ -24,6 +24,10 @@ def main(task_for):
magicleap_nightly = lambda: None
if task_for == "github-push":
if not CONFIG.legacy_tc_deployment: # pragma: no cover
# Do nothing (other than the decision task itsef) on community-tc by default for now
return
# FIXME https://github.com/servo/servo/issues/22187
# In-emulator testing is disabled for now. (Instead we only compile.)
# This local variable shadows the module-level function of the same name.
@ -238,7 +242,8 @@ def upload_docs():
.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"
root_url = os.environ["TASKCLUSTER_PROXY_URL"]
url = root_url + "/api/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)
""")

View file

@ -57,8 +57,8 @@ class Config:
self.git_ref = os.environ.get("GIT_REF")
self.git_sha = os.environ.get("GIT_SHA")
root_url = os.environ.get("TASKCLUSTER_ROOT_URL")
self.legacy_tc_deployment = root_url == "https://taskcluster.net"
self.tc_root_url = os.environ.get("TASKCLUSTER_ROOT_URL")
self.legacy_tc_deployment = self.tc_root_url == "https://taskcluster.net"
if self.legacy_tc_deployment:
self.default_provisioner_id = "aws-provisioner-v1"
@ -99,10 +99,9 @@ class Shared:
self.now = datetime.datetime.utcnow()
self.found_or_created_indexed_tasks = {}
# taskclusterProxy URLs:
# https://docs.taskcluster.net/docs/reference/workers/docker-worker/docs/features
self.queue_service = taskcluster.Queue(options={"baseUrl": "http://taskcluster/queue/v1/"})
self.index_service = taskcluster.Index(options={"baseUrl": "http://taskcluster/index/v1/"})
options = {"rootUrl": os.environ["TASKCLUSTER_PROXY_URL"]}
self.queue_service = taskcluster.Queue(options)
self.index_service = taskcluster.Index(options)
def from_now_json(self, offset):
"""
@ -256,7 +255,7 @@ class Task:
extra=self.extra,
)
task_id = taskcluster.slugId().decode("utf8")
task_id = taskcluster.slugId()
SHARED.queue_service.createTask(task_id, queue_payload)
print("Scheduled %s: %s" % (task_id, self.name))
return task_id
@ -483,7 +482,7 @@ class WindowsGenericWorkerTask(GenericWorkerTask):
git += """
git fetch {depth} %GIT_URL% %GIT_REF%
git reset --hard %GIT_SHA%
""".format(depth="--depth 1" if shallow else "")
""".format(depth="--depth 100" if shallow else "")
return self \
.with_git() \
.with_script(git) \
@ -605,7 +604,7 @@ class UnixTaskMixin(Task):
cd repo
git fetch {depth} "$GIT_URL" "$GIT_REF"
git reset --hard "$GIT_SHA"
""".format(depth="--depth 1" if shallow else ""))
""".format(depth="--depth 100" if shallow else ""))
def with_curl_script(self, url, file_path):
self.curl_scripts_count += 1
@ -621,11 +620,14 @@ class UnixTaskMixin(Task):
""".format(n=n))
def with_curl_artifact_script(self, task_id, artifact_name, out_directory=""):
if CONFIG.legacy_tc_deployment:
queue_service = "https://queue.taskcluster.net"
else: # pragma: no cover
queue_service = CONFIG.tc_root_url + "/api/queue"
return self \
.with_dependencies(task_id) \
.with_curl_script(
"https://queue.taskcluster.net/v1/task/%s/artifacts/public/%s"
% (task_id, artifact_name),
queue_service + "/v1/task/%s/artifacts/public/%s" % (task_id, artifact_name),
os.path.join(out_directory, url_basename(artifact_name)),
)

View file

@ -45,6 +45,7 @@ sys.dont_write_bytecode = True
os.environ.update(**{k: k for k in "TASK_ID TASK_OWNER TASK_SOURCE GIT_URL GIT_SHA".split()})
os.environ["GIT_REF"] = "refs/heads/auto"
os.environ["TASKCLUSTER_ROOT_URL"] = "https://taskcluster.net"
os.environ["TASKCLUSTER_PROXY_URL"] = "http://taskcluster"
import decision_task
print("\n# Push:")

View file

@ -591,7 +591,7 @@ class PackageCommands(CommandBase):
def get_taskcluster_secret(name):
url = (
os.environ.get("TASKCLUSTER_PROXY_URL", "http://taskcluster") +
"/secrets/v1/secret/project/servo/" +
"/api/secrets/v1/secret/project/servo/" +
name
)
return json.load(urllib.request.urlopen(url))["secret"]