Skip to content

Commit 7fe73e7

Browse files
authored
actions: support non-indexed decision tasks (#447)
Usually we can look up the on-push decision task using the tc index, however that doesn't work for pull requests, which are generally not indexed, and if they were, wouldn't share the same namespace. In that case, assume the decision task id is the action task's group id.
1 parent a734511 commit 7fe73e7

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

src/taskgraph/actions/add_new_jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
)
4141
def add_new_jobs_action(parameters, graph_config, input, task_group_id, task_id):
4242
decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
43-
parameters, graph_config
43+
parameters, graph_config, task_group_id=task_group_id
4444
)
4545

4646
to_run = []

src/taskgraph/actions/rebuild_cached_tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def rebuild_cached_tasks_action(
1818
parameters, graph_config, input, task_group_id, task_id
1919
):
2020
decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
21-
parameters, graph_config
21+
parameters, graph_config, task_group_id=task_group_id
2222
)
2323
cached_tasks = [
2424
label

src/taskgraph/actions/retrigger.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def retrigger_decision_action(parameters, graph_config, input, task_group_id, ta
144144
)
145145
def retrigger_action(parameters, graph_config, input, task_group_id, task_id):
146146
decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
147-
parameters, graph_config
147+
parameters, graph_config, task_group_id=task_group_id
148148
)
149149

150150
task = taskcluster.get_task_definition(task_id)
@@ -201,7 +201,7 @@ def rerun_action(parameters, graph_config, input, task_group_id, task_id):
201201
task = taskcluster.get_task_definition(task_id)
202202
parameters = dict(parameters)
203203
decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
204-
parameters, graph_config
204+
parameters, graph_config, task_group_id=task_group_id
205205
)
206206
label = task["metadata"]["name"]
207207
if task_id not in label_to_taskid.values():
@@ -259,7 +259,7 @@ def _rerun_task(task_id, label):
259259
)
260260
def retrigger_multiple(parameters, graph_config, input, task_group_id, task_id):
261261
decision_task_id, full_task_graph, label_to_taskid = fetch_graph_and_labels(
262-
parameters, graph_config
262+
parameters, graph_config, task_group_id=task_group_id
263263
)
264264

265265
suffixes = []

src/taskgraph/actions/util.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@ def get_parameters(decision_task_id):
3232
return get_artifact(decision_task_id, "public/parameters.yml")
3333

3434

35-
def fetch_graph_and_labels(parameters, graph_config):
36-
decision_task_id = find_decision_task(parameters, graph_config)
35+
def fetch_graph_and_labels(parameters, graph_config, task_group_id=None):
36+
try:
37+
# Look up the decision_task id in the index
38+
decision_task_id = find_decision_task(parameters, graph_config)
39+
except KeyError:
40+
if not task_group_id:
41+
raise
42+
# Not found (e.g. from github-pull-request), fall back to the task group id.
43+
decision_task_id = task_group_id
3744

3845
# First grab the graph and labels generated during the initial decision task
3946
full_task_graph = get_artifact(decision_task_id, "public/full-task-graph.json")

0 commit comments

Comments
 (0)