Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions taskcluster/kinds/docker-image/kind.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ loader: taskgraph.loader.transform:loader
transforms:
- taskgraph.transforms.docker_image:transforms
- taskgraph.transforms.cached_tasks:transforms
- self_taskgraph.transforms.add_pr_route
- taskgraph.transforms.task:transforms

# make a task for each docker-image we might want. For the moment, since we
Expand Down
23 changes: 23 additions & 0 deletions taskcluster/self_taskgraph/custom_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@
# 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

from voluptuous import All, Any, Range, Required

from taskgraph.parameters import extend_parameters_schema


def get_defaults(repo_root):
return {
"pull_request_number": None,
}


extend_parameters_schema(
{
Required("pull_request_number"): Any(All(int, Range(min=1)), None),
},
defaults_fn=get_defaults,
)


def decision_parameters(graph_config, parameters):
if parameters["tasks_for"] == "github-release":
parameters["target_tasks_method"] = "release"

pr_number = os.environ.get("TASKGRAPH_PULL_REQUEST_NUMBER", None)
parameters["pull_request_number"] = None if pr_number is None else int(pr_number)
31 changes: 31 additions & 0 deletions taskcluster/self_taskgraph/transforms/add_pr_route.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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/.

from taskgraph.transforms.base import TransformSequence

transforms = TransformSequence()


@transforms.add
def add_pr_route(config, tasks):
"""Adds pull request index routes when applicable."""
if not (pr_number := config.params.get("pull_request_number")):
yield from tasks
return

PR_ROUTE = (
"index.{trust-domain}.v2.{project}-pr.{pr-number}.latest.{kind}.{task-name}"
)
subs = {
"trust-domain": config.graph_config["trust-domain"],
"project": config.params["project"],
"pr-number": pr_number,
"kind": config.kind,
}

for task in tasks:
subs["task-name"] = task.get("name") or task["label"][len(config.kind) + 1 :]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the label guaranteed to start with the kind's name?

Copy link
Collaborator Author

@ahal ahal Oct 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, but it is for docker-image tasks :p.. Since the transform is self_taskgraph specific, I don't really care about making it solve all possible cases (if we were adding this in the core module, then we'd have to be smarter about it).

routes = task.setdefault("routes", [])
routes.append(PR_ROUTE.format(**subs))
yield task
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ moz_build_date: '20220421203159'
optimize_target_tasks: true
owner: [email protected]
project: taskgraph
pull_request_number: 123
pushdate: 0
pushlog_id: '0'
repository_type: git
Expand Down
1 change: 1 addition & 0 deletions taskcluster/test/params/main-repo-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ moz_build_date: '20220421203159'
optimize_target_tasks: true
owner: [email protected]
project: taskgraph
pull_request_number: 123
pushdate: 0
pushlog_id: '0'
repository_type: git
Expand Down
Loading