Skip to content

Commit 93b28b0

Browse files
jfx2006ahal
authored andcommitted
Update verify_routes_notification_filters to align with Taskcluster > 37.5.0
PR #3662 introduced `on-defined`, `on-pending` and `on-running`, and deprecated `on-any` in favor of `on-transition` or `on-resolved`.
1 parent eefda88 commit 93b28b0

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed

src/taskgraph/util/verify.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import logging
77
import sys
8+
import warnings
89
from abc import ABC, abstractmethod
910
from dataclasses import dataclass, field
1011
from typing import Callable, Dict, List, Union
@@ -192,7 +193,17 @@ def verify_routes_notification_filters(
192193
if task is None:
193194
return
194195
route_prefix = "notify."
195-
valid_filters = ("on-any", "on-completed", "on-failed", "on-exception")
196+
valid_filters = (
197+
"on-any",
198+
"on-completed",
199+
"on-defined",
200+
"on-failed",
201+
"on-exception",
202+
"on-pending",
203+
"on-resolved",
204+
"on-running",
205+
"on-transition",
206+
)
196207
task_dict = task.task
197208
routes = task_dict.get("routes", [])
198209

@@ -204,6 +215,13 @@ def verify_routes_notification_filters(
204215
raise Exception(
205216
f"{task.label} has invalid notification filter ({route_filter})"
206217
)
218+
if route_filter == "on-any":
219+
warnings.warn(
220+
DeprecationWarning(
221+
f"notification filter '{route_filter}' is deprecated. Use "
222+
"'on-transition' or 'on-resolved'."
223+
)
224+
)
207225

208226

209227
@verifications.add("full_task_graph")

test/test_util_verify.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,54 @@ def make_task_treeherder(label, symbol, platform="linux/opt"):
163163
Exception,
164164
id="task_graph_symbol: too many collections",
165165
),
166+
pytest.param(
167+
"verify_routes_notification_filters",
168+
make_graph(
169+
make_task(
170+
"good1",
171+
task_def={
172+
"routes": [
173+
174+
]
175+
},
176+
),
177+
),
178+
None,
179+
id="routes_notfication_filter: valid"
180+
),
181+
pytest.param(
182+
"verify_routes_notification_filters",
183+
make_graph(
184+
make_task(
185+
"bad1",
186+
task_def={
187+
"routes": [
188+
189+
]
190+
},
191+
),
192+
),
193+
Exception,
194+
id="routes_notfication_filter: invalid"
195+
),
196+
pytest.param(
197+
"verify_routes_notification_filters",
198+
make_graph(
199+
make_task(
200+
"deprecated",
201+
task_def={
202+
"routes": [
203+
204+
]
205+
},
206+
),
207+
),
208+
DeprecationWarning,
209+
id="routes_notfication_filter: deprecated"
210+
),
166211
),
167212
)
213+
@pytest.mark.filterwarnings("error")
168214
def test_verification(run_verification, name, graph, exception):
169215
func = partial(run_verification, name, graph=graph)
170216
if exception:

0 commit comments

Comments
 (0)