Skip to content

Commit e5b343f

Browse files
committed
ci: add route to index docker-images by PR number
1 parent 2e30555 commit e5b343f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/taskgraph/transforms/docker_image.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,29 @@ def fill_template(config, tasks):
256256
}
257257

258258
yield taskdesc
259+
260+
261+
@transforms.add
262+
def add_pr_route(config, tasks):
263+
"""Taskgraph builds several docker-images that get used externally.
264+
265+
Indexing these images by pull request number, allows us to easily test them
266+
in external repos using the `indexed-image` image definition type.
267+
"""
268+
if not (pr_number := config.params.get("pull_request_number")):
269+
yield from tasks
270+
return
271+
272+
PR_ROUTE = "index.{trust-domain}.v2.{project}.pr.{pr-number}.latest.{product}.{task-name}"
273+
subs = {
274+
"trust-domain": config.graph_config["trust-domain"],
275+
"project": config.params["project"],
276+
"pr-number": pr_number,
277+
"product": "docker-image",
278+
}
279+
280+
for task in tasks:
281+
subs["task-name"] = task["attributes"]["image_name"]
282+
routes = task.setdefault("routes", [])
283+
routes.append(PR_ROUTE.format(**subs))
284+
yield task

taskcluster/test/params/main-repo-pull-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ moz_build_date: '20220421203159'
1717
optimize_target_tasks: true
1818
1919
project: taskgraph
20+
pull_request_number: 123
2021
pushdate: 0
2122
pushlog_id: '0'
2223
repository_type: git

0 commit comments

Comments
 (0)