Skip to content
Merged
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
2 changes: 1 addition & 1 deletion src/taskgraph/transforms/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def build_docker_worker_payload(config, task, task_def):
if "max-run-time" in worker:
payload["maxRunTime"] = worker["max-run-time"]

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

# run-task exits EXIT_PURGE_CACHES if there is a problem with caches.
# Automatically retry the tasks and purge caches if we see this exit
Expand Down
3 changes: 2 additions & 1 deletion src/taskgraph/util/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


import logging
import os
import re
import sys
import warnings
Expand Down Expand Up @@ -333,7 +334,7 @@ def verify_run_task_caches(task, taskgraph, scratch_pad, graph_config, parameter
command = payload.get("command") or [""]

main_command = command[0] if isinstance(command[0], str) else ""
run_task = main_command.endswith("run-task")
run_task = os.path.basename(main_command).startswith("run-task")

for cache in payload.get("cache", {}).get(
"task-reference", payload.get("cache", {})
Expand Down
30 changes: 30 additions & 0 deletions test/test_transforms_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,36 @@ def test_default_expires_after(run_transform, graph_config, expires_after, test_
assert task_dict["task"]["expires"] == {"relative-datestamp": "28 days"}


@pytest.mark.parametrize(
"command",
(
["run-task"],
["run-task-hg"],
["/usr/local/bin/run-task"],
["/usr/bin/run-task-hg"],
),
)
def test_run_task_exit_status(run_transform, make_transform_config, command):
task_def = {
"description": "fake description",
"name": "fake-task-name",
"worker-type": "t-linux",
"worker": {
"docker-image": "fake-image-name",
"max-run-time": 1800,
"command": command,
},
}

task_dict = run_transform(
task.transforms, task_def, config=make_transform_config()
)[0]
payload = task_dict["task"]["payload"]
# If run-task is properly detected, then the transform sets those onExitStatus
assert 72 in payload["onExitStatus"]["retry"]
assert 72 in payload["onExitStatus"]["purgeCaches"]


@pytest.mark.parametrize(
"test_task",
(
Expand Down
16 changes: 16 additions & 0 deletions test/test_util_verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,22 @@ def make_task_treeherder(label, symbol, platform="linux/opt"):
pytest.raises(Exception, match="cache name is not dep"),
id="using run-task without cache suffix",
),
pytest.param(
"verify_run_task_caches",
make_graph(
make_task(
"task1",
task_def={
"payload": {
"cache": {"test-domain-level-1-checkouts": {}},
"command": ["run-task-hg"],
}
},
)
),
pytest.raises(Exception, match="cache name is not dep"),
id="using run-task-hg without cache suffix",
),
),
)
@pytest.mark.filterwarnings("error")
Expand Down
Loading