Skip to content

Commit a61d51d

Browse files
committed
Fix run-task detection in the task transform
1 parent 07b8681 commit a61d51d

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/taskgraph/transforms/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def build_docker_worker_payload(config, task, task_def):
649649
if "max-run-time" in worker:
650650
payload["maxRunTime"] = worker["max-run-time"]
651651

652-
run_task = payload.get("command", [""])[0].endswith("run-task")
652+
run_task = os.path.basename(payload.get("command", [""])[0]).startswith("run-task")
653653

654654
# run-task exits EXIT_PURGE_CACHES if there is a problem with caches.
655655
# Automatically retry the tasks and purge caches if we see this exit

test/test_transforms_task.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,36 @@ def test_default_expires_after(run_transform, graph_config, expires_after, test_
871871
assert task_dict["task"]["expires"] == {"relative-datestamp": "28 days"}
872872

873873

874+
@pytest.mark.parametrize(
875+
"command",
876+
(
877+
["run-task"],
878+
["run-task-hg"],
879+
["/usr/local/bin/run-task"],
880+
["/usr/bin/run-task-hg"],
881+
),
882+
)
883+
def test_run_task_exit_status(run_transform, make_transform_config, command):
884+
task_def = {
885+
"description": "fake description",
886+
"name": "fake-task-name",
887+
"worker-type": "t-linux",
888+
"worker": {
889+
"docker-image": "fake-image-name",
890+
"max-run-time": 1800,
891+
"command": command,
892+
},
893+
}
894+
895+
task_dict = run_transform(
896+
task.transforms, task_def, config=make_transform_config()
897+
)[0]
898+
payload = task_dict["task"]["payload"]
899+
# If run-task is properly detected, then the transform sets those onExitStatus
900+
assert 72 in payload["onExitStatus"]["retry"]
901+
assert 72 in payload["onExitStatus"]["purgeCaches"]
902+
903+
874904
@pytest.mark.parametrize(
875905
"test_task",
876906
(

0 commit comments

Comments
 (0)