tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 9f13ca7bbe08a964b1097c35f6d5bf6fdddfddb0
parent a07014cd6dd043d34e457ebb8f93ff9fcf61be3a
Author: Andrew Halberstadt <ahal@mozilla.com>
Date:   Fri,  3 Oct 2025 17:37:39 +0000

Bug 1986773 - [ci] Support upstream 'run-task' in job transforms, r=taskgraph-reviewers,bhearsum

The Gecko version of `run-task` is specific to Mercurial. Now that we're
going to start running Gecko CI against Github repos, they will be using
the upstream version of `run-task`. This version of `run-task` expects a
`REPOSITORIES` env to be set.

This patch makes the `job` transforms match the upstream `run` ones a
bit more closely, which involves defining `taskgraph.repositories` in
config.yml.

Additionally this sets a few extra env variables that the `run`
transforms were setting, just for additional parity.

Differential Revision: https://phabricator.services.mozilla.com/D267265

Diffstat:
Mtaskcluster/config.yml | 3+++
Mtaskcluster/gecko_taskgraph/config.py | 13++++++++++++-
Mtaskcluster/gecko_taskgraph/transforms/job/common.py | 26++++++++++++++++++++++----
Mtaskcluster/gecko_taskgraph/transforms/job/mozharness_test.py | 2+-
Mtaskcluster/gecko_taskgraph/transforms/job/run_task.py | 13+++++++++++--
5 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/taskcluster/config.yml b/taskcluster/config.yml @@ -524,6 +524,9 @@ task-priority: taskgraph: register: gecko_taskgraph:register + repositories: + gecko: + name: 'Mozilla Firefox' workers: aliases: diff --git a/taskcluster/gecko_taskgraph/config.py b/taskcluster/gecko_taskgraph/config.py @@ -3,7 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. from taskgraph.util.schema import Schema, optionally_keyed_by -from voluptuous import Any, Optional, Required +from voluptuous import All, Any, Extra, Optional, Required from voluptuous.validators import Length graph_config_schema = Schema( @@ -113,6 +113,17 @@ graph_config_schema = Schema( Optional("run"): { Optional("use-caches"): Any(bool, [str]), }, + Required("repositories"): All( + { + str: { + Required("name"): str, + Optional("project-regex"): str, + Optional("ssh-secret-name"): str, + Extra: str, + } + }, + Length(min=1), + ), }, Required("expiration-policy"): optionally_keyed_by("project", {str: str}), } diff --git a/taskcluster/gecko_taskgraph/transforms/job/common.py b/taskcluster/gecko_taskgraph/transforms/job/common.py @@ -8,6 +8,7 @@ consistency. """ from taskgraph.transforms.run.common import CACHES, add_cache +from taskgraph.util import json from taskgraph.util.keyed_by import evaluate_keyed_by from taskgraph.util.taskcluster import get_artifact_prefix @@ -58,7 +59,7 @@ def get_cache_name(config, job): return cache_name -def support_vcs_checkout(config, job, taskdesc): +def support_vcs_checkout(config, job, taskdesc, repo_configs): """Update a job/task with parameters to enable a VCS checkout. This can only be used with ``run-task`` tasks, as the cache name is @@ -94,12 +95,29 @@ def support_vcs_checkout(config, job, taskdesc): env = taskdesc["worker"].setdefault("env", {}) env.update( { - "GECKO_BASE_REPOSITORY": config.params["base_repository"], - "GECKO_HEAD_REPOSITORY": config.params["head_repository"], - "GECKO_HEAD_REV": config.params["head_rev"], "HG_STORE_PATH": hgstore, + "REPOSITORIES": json.dumps( + {repo.prefix: repo.name for repo in repo_configs.values()} + ), } ) + for repo_config in repo_configs.values(): + env.update( + { + f"{repo_config.prefix.upper()}_{key}": value + for key, value in { + "BASE_REPOSITORY": repo_config.base_repository, + "HEAD_REPOSITORY": repo_config.head_repository, + "HEAD_REV": repo_config.head_rev, + "HEAD_REF": repo_config.head_ref, + "REPOSITORY_TYPE": repo_config.type, + "SSH_SECRET_NAME": repo_config.ssh_secret_name, + }.items() + if value is not None + } + ) + if repo_config.ssh_secret_name: + taskdesc["scopes"].append(f"secrets:get:{repo_config.ssh_secret_name}") gecko_path = env.setdefault("GECKO_PATH", geckodir) diff --git a/taskcluster/gecko_taskgraph/transforms/job/mozharness_test.py b/taskcluster/gecko_taskgraph/transforms/job/mozharness_test.py @@ -190,7 +190,7 @@ def mozharness_test_on_docker(config, job, taskdesc): if not test["checkout"]: # Support vcs checkouts regardless of whether the task runs from # source or not in case it is needed on an interactive loaner. - support_vcs_checkout(config, job, taskdesc) + support_vcs_checkout(config, job, taskdesc, config.repo_configs) # If we have a source checkout, run mozharness from it instead of # downloading a zip file with the same content. diff --git a/taskcluster/gecko_taskgraph/transforms/job/run_task.py b/taskcluster/gecko_taskgraph/transforms/job/run_task.py @@ -5,7 +5,7 @@ Support for running jobs that are invoked via the `run-task` script. """ - +import dataclasses import os from mozbuild.util import memoize @@ -63,7 +63,16 @@ def common_setup(config, job, taskdesc, command): run = job["run"] run_cwd = run.get("cwd") if run["checkout"]: - gecko_path = support_vcs_checkout(config, job, taskdesc) + repo_configs = config.repo_configs + if len(repo_configs) > 1 and run["checkout"] is True: + raise Exception("Must explicitly specify checkouts with multiple repos.") + elif run["checkout"] is not True: + repo_configs = { + repo: dataclasses.replace(repo_configs[repo], **config) + for (repo, config) in run["checkout"].items() + } + + gecko_path = support_vcs_checkout(config, job, taskdesc, repo_configs) command.append(f"--gecko-checkout={gecko_path}") if run_cwd: