Skip to content
Draft
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
6 changes: 6 additions & 0 deletions taskcluster/docs/kinds.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ unit tests, source-code analysis, or measurement work. While source-test tasks r
a source checkout, it is still possible for them to depend on a build artifact, though
often they do not.

## try-status

Find the try push of a pull request's branch and generate one task per task of
that push, each reporting the outcome of the task it monitors on the pull
request.

## code-review

Publish issues found by source-test tasks on Phabricator.
Expand Down
12 changes: 11 additions & 1 deletion taskcluster/gecko_taskgraph/target_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,17 @@ def filter(task):

return False

return [l for l in filtered_for_project if filter(full_task_graph[l])]
selected = [l for l in filtered_for_project if filter(full_task_graph[l])]

level = int(parameters["level"])
# Make sure to always schedule, but on PR only
selected += [
label
for label, task in full_task_graph.tasks.items()
if task.kind == "try-status" and label not in selected and level < 3
]

return selected


@register_target_task("graphics_tasks")
Expand Down
38 changes: 38 additions & 0 deletions taskcluster/gecko_taskgraph/transforms/try_status.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# 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/.
"""
Hand the branch of the current push to the try status generator.

The generator looks that branch up in the try repository at runtime, so the only
thing it needs from the decision task is where this push came from, and the right
to put the report tasks it creates on this push.
"""

from taskgraph.transforms.base import TransformSequence

from gecko_taskgraph.transforms.task import (
TREEHERDER_ROUTE_ROOT,
get_branch_rev,
get_treeherder_project,
)

transforms = TransformSequence()


@transforms.add
def add_push_coordinates(config, jobs):
# The decision task only holds the route of the push it is running for, so
# the scope has to name that one route rather than the whole namespace. Built
# the same way as the route itself, in gecko_taskgraph.transforms.task.
route = f"{TREEHERDER_ROUTE_ROOT}.v2.{get_treeherder_project(config)}.{get_branch_rev(config)}"

for job in jobs:
env = job.setdefault("worker", {}).setdefault("env", {})
env["TRY_STATUS_HEAD_REF"] = config.params["head_ref"] or ""
# The commit the try push has to sit on for it to be this pull request.
env["TRY_STATUS_HEAD_REV"] = config.params["head_rev"]
env["TRY_STATUS_TRUST_DOMAIN"] = config.graph_config["trust-domain"]

job.setdefault("scopes", []).append(f"queue:route:{route}")
yield job
67 changes: 67 additions & 0 deletions taskcluster/kinds/try-status/kind.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# 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/.
---
loader: taskgraph.loader.transform:loader

transforms:
- gecko_taskgraph.transforms.try_status:transforms
- gecko_taskgraph.transforms.job:transforms
- gecko_taskgraph.transforms.task:transforms

tasks:
gen:
label: try-status-gen
description: >-
Find the try push of this branch and generate one task per task of
that push, to report its outcome on this pull request

# Selected by name in target_tasks_enterprise_firefox_with_tests, since
# it reports on the try push of the branch rather than on the graph it
# belongs to and so has no business going through the project filter.
run-on-projects: []

# `code-review` earns the `checks` route in
# gecko_taskgraph.transforms.task, which is what puts a task on the pull
# request. It applies to this task so that a branch with no try push is
# reported, and the generated tasks carry the same route.
attributes:
code-review: true

worker-type: t-linux-arm64-docker
worker:
docker-image: {in-tree: debian12-base}
# Long enough to wait for the try decision task to run.
max-run-time: 3600
taskcluster-proxy: true
env:
TRY_STATUS_TRY_REMOTE: https://github.com/mozilla/enterprise-firefox-try
TRY_STATUS_TRY_PROJECT: enterprise-firefox-try
TRY_STATUS_TREEHERDER_URL: https://treeherder.mozilla.org
TRY_STATUS_REPORT_SCRIPT: taskcluster/scripts/try-status-report.py
artifacts:
- name: public/try-status
path: /builds/worker/artifacts
type: directory

# Creating the report tasks, in this task group, with the routes that
# surface them on the pull request. No secret is involved: nothing here
# authenticates to GitHub, Taskcluster reports on its own tasks. The
# treeherder route is added by the transform, which is where the exact
# route of this push is known.
scopes:
- queue:create-task:highest:enterprise-t/t-linux-arm64-docker
- queue:scheduler-id:enterprise-level-{level}
- queue:route:checks

treeherder:
kind: other
symbol: try-status
tier: 1
platform: gecko-decision/opt

run:
using: run-task
checkout: true
cwd: '{checkout}'
command: python3 taskcluster/scripts/try-status-gen.py
Loading