commit 0afa1d31ba7095183ba04844f1870c0545ae4138
parent e62372c880c9e8154a6e753d6685b49a3af10960
Author: Andrew Halberstadt <ahal@mozilla.com>
Date: Thu, 2 Oct 2025 15:28:49 +0000
Bug 1986773 - [decision] Add target_tasks filtering for Github projects, r=taskgraph-reviewers,bhearsum
This change:
1. Adds the "firefox" and "staging-firefox" projects
2. Adds filter_for_git_branch to the default filters (no-op on hg)
3. Implements a new filter_for_repo_type in the default filters
(defaults to ["hg"]). Until tasks start setting this attribute to
include "git", nothing will run on Github based graphs.
Differential Revision: https://phabricator.services.mozilla.com/D267065
Diffstat:
8 files changed, 130 insertions(+), 2 deletions(-)
diff --git a/taskcluster/docs/attributes.rst b/taskcluster/docs/attributes.rst
@@ -19,6 +19,15 @@ kind
A task's ``kind`` attribute gives the name of the kind that generated it, e.g.,
``build`` or ``spidermonkey``.
+run_on_repo_type
+================
+
+The types of repositories where this task should be in the target task set. Typically
+"hg" (the default), "git" or both.
+
+This attribute is temporary and will be used during the transition from hg.mozilla.org
+to Github.
+
run_on_projects
===============
diff --git a/taskcluster/gecko_taskgraph/decision.py b/taskcluster/gecko_taskgraph/decision.py
@@ -116,6 +116,10 @@ PER_PROJECT_PARAMETERS = {
"toolchains": {
"target_tasks_method": "mozilla_central_tasks",
},
+ # git projects
+ "staging-firefox": {
+ "target_tasks_method": "default",
+ },
# the default parameters are used for projects that do not match above.
"default": {
"target_tasks_method": "default",
diff --git a/taskcluster/gecko_taskgraph/target_tasks.py b/taskcluster/gecko_taskgraph/target_tasks.py
@@ -12,7 +12,7 @@ from datetime import datetime, timedelta
import requests
from redo import retry
from taskgraph import create
-from taskgraph.target_tasks import register_target_task
+from taskgraph.target_tasks import filter_for_git_branch, register_target_task
from taskgraph.util.attributes import attrmatch
from taskgraph.util.parameterization import resolve_timestamps
from taskgraph.util.taskcluster import (
@@ -28,6 +28,7 @@ from gecko_taskgraph.util.attributes import (
is_try,
match_run_on_hg_branches,
match_run_on_projects,
+ match_run_on_repo_type,
)
from gecko_taskgraph.util.constants import TEST_KINDS
from gecko_taskgraph.util.hg import find_hg_revision_push_info, get_hg_commit_message
@@ -100,6 +101,15 @@ def filter_out_cron(task, parameters):
return not task.attributes.get("cron")
+def filter_for_repo_type(task, parameters):
+ """Filter tasks by repository type.
+
+ This filter is temporarily in-place to facilitate the hg.mozilla.org ->
+ Github migration."""
+ run_on_repo_types = set(task.attributes.get("run_on_repo_type", ["hg"]))
+ return match_run_on_repo_type(parameters["repository_type"], run_on_repo_types)
+
+
def filter_for_project(task, parameters):
"""Filter tasks by project. Optionally enable nightlies."""
run_on_projects = set(task.attributes.get("run_on_projects", []))
@@ -250,8 +260,10 @@ def standard_filter(task, parameters):
filter_func(task, parameters)
for filter_func in (
filter_out_cron,
+ filter_for_repo_type,
filter_for_project,
filter_for_hg_branch,
+ filter_for_git_branch,
filter_tests_without_manifests,
)
)
diff --git a/taskcluster/gecko_taskgraph/test/test_target_tasks.py b/taskcluster/gecko_taskgraph/test/test_target_tasks.py
@@ -24,6 +24,7 @@ class TestTargetTasks(unittest.TestCase):
},
parameters={
"project": project,
+ "repository_type": "hg",
"hg_branch": "default",
},
)
@@ -37,6 +38,7 @@ class TestTargetTasks(unittest.TestCase):
attributes=attributes,
parameters={
"project": "mozilla-central",
+ "repository_type": "hg",
"hg_branch": hg_branch,
},
)
@@ -397,6 +399,76 @@ class TestTargetTasks(unittest.TestCase):
True,
id="filter_unsupported_artifact_builds_not_removed",
),
+ pytest.param(
+ "filter_for_repo_type",
+ {
+ "task": Task(kind="test", label="a", attributes={}, task={}),
+ "parameters": {
+ "repository_type": "hg",
+ },
+ },
+ True,
+ id="filter_for_repo_type_default_hg_not_removed",
+ ),
+ pytest.param(
+ "filter_for_repo_type",
+ {
+ "task": Task(kind="test", label="a", attributes={}, task={}),
+ "parameters": {
+ "repository_type": "git",
+ },
+ },
+ False,
+ id="filter_for_repo_type_default_git_removed",
+ ),
+ pytest.param(
+ "filter_for_repo_type",
+ {
+ "task": Task(
+ kind="test",
+ label="a",
+ attributes={"run_on_repo_type": ["hg"]},
+ task={},
+ ),
+ "parameters": {
+ "repository_type": "git",
+ },
+ },
+ False,
+ id="filter_for_repo_type_no_match_removed",
+ ),
+ pytest.param(
+ "filter_for_repo_type",
+ {
+ "task": Task(
+ kind="test",
+ label="a",
+ attributes={"run_on_repo_type": ["git"]},
+ task={},
+ ),
+ "parameters": {
+ "repository_type": "git",
+ },
+ },
+ True,
+ id="filter_for_repo_type_match_not_removed",
+ ),
+ pytest.param(
+ "filter_for_repo_type",
+ {
+ "task": Task(
+ kind="test",
+ label="a",
+ attributes={"run_on_repo_type": ["all"]},
+ task={},
+ ),
+ "parameters": {
+ "repository_type": "git",
+ },
+ },
+ True,
+ id="filter_for_repo_type_all_not_removed",
+ ),
),
)
def test_filters(name, params, expected):
diff --git a/taskcluster/gecko_taskgraph/test/test_util_attributes.py b/taskcluster/gecko_taskgraph/test/test_util_attributes.py
@@ -5,10 +5,14 @@
import unittest
+import pytest
from mozunit import main
from taskgraph.util.attributes import attrmatch
-from gecko_taskgraph.util.attributes import match_run_on_projects
+from gecko_taskgraph.util.attributes import (
+ match_run_on_projects,
+ match_run_on_repo_type,
+)
class Attrmatch(unittest.TestCase):
@@ -95,5 +99,19 @@ class MatchRunOnProjects(unittest.TestCase):
self.assertTrue(match_run_on_projects("birch", ["birch", "trunk"]))
+@pytest.mark.parametrize(
+ "repo_type,run_on_repo_types,expected",
+ (
+ ("hg", ["hg"], True),
+ ("hg", [], False),
+ ("hg", ["all"], True),
+ ("git", ["git", "hg"], True),
+ ("git", ["hg"], False),
+ ),
+)
+def test_match_run_on_repo_type(repo_type, run_on_repo_types, expected):
+ assert match_run_on_repo_type(repo_type, run_on_repo_types) == expected
+
+
if __name__ == "__main__":
main()
diff --git a/taskcluster/gecko_taskgraph/transforms/job/__init__.py b/taskcluster/gecko_taskgraph/transforms/job/__init__.py
@@ -56,6 +56,7 @@ job_description_schema = Schema(
Optional("extra"): task_description_schema["extra"],
Optional("treeherder"): task_description_schema["treeherder"],
Optional("index"): task_description_schema["index"],
+ Optional("run-on-repo-type"): task_description_schema["run-on-repo-type"],
Optional("run-on-projects"): task_description_schema["run-on-projects"],
Optional("shipping-phase"): task_description_schema["shipping-phase"],
Optional("shipping-product"): task_description_schema["shipping-product"],
diff --git a/taskcluster/gecko_taskgraph/transforms/task.py b/taskcluster/gecko_taskgraph/transforms/task.py
@@ -160,6 +160,10 @@ task_description_schema = Schema(
"build_date",
),
},
+ # The `run_on_repo_type` attribute, defaulting to "hg". This dictates
+ # the types of repositories on which this task should be included in
+ # the target task set. See the attributes documentation for details.
+ Optional("run-on-repo-type"): [str],
# The `run_on_projects` attribute, defaulting to "all". This dictates the
# projects on which this task should be included in the target task set.
# See the attributes documentation for details.
@@ -2344,6 +2348,7 @@ def build_task(config, tasks):
item_name=task["label"],
**{"build-platform": build_platform},
)
+ attributes["run_on_repo_type"] = task.get("run-on-repo-type", ["hg"])
attributes["run_on_projects"] = task.get("run-on-projects", ["all"])
attributes["always_target"] = task["always-target"]
# This logic is here since downstream tasks don't always match their
diff --git a/taskcluster/gecko_taskgraph/util/attributes.py b/taskcluster/gecko_taskgraph/util/attributes.py
@@ -5,6 +5,8 @@
import re
+from taskgraph.util.attributes import _match_run_on
+
INTEGRATION_PROJECTS = {
"autoland",
}
@@ -12,6 +14,7 @@ INTEGRATION_PROJECTS = {
TRUNK_PROJECTS = INTEGRATION_PROJECTS | {"mozilla-central", "comm-central"}
RELEASE_PROJECTS = {
+ "firefox", # https://github.com/mozilla-firefox/firefox
"mozilla-central",
"mozilla-beta",
"mozilla-release",
@@ -50,6 +53,7 @@ TEMPORARY_PROJECTS = set(
)
TRY_PROJECTS = {
+ "staging-firefox", # https://github.com/mozilla-releng/staging-firefox
"try",
"try-comm-central",
}
@@ -118,6 +122,9 @@ def match_run_on_hg_branches(hg_branch, run_on_hg_branches):
return False
+match_run_on_repo_type = _match_run_on
+
+
def copy_attributes_from_dependent_job(dep_job, denylist=()):
return {
attr: dep_job.attributes[attr]