Skip to content

Commit 45280db

Browse files
committed
Fix run-task/fetch-content mounts definition
Fixes a regression from #666, which: - used taskId instead of task-id in the task description - failed to add sha256 to the schema
1 parent e34fb71 commit 45280db

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

src/taskgraph/transforms/run/run_task.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def generic_worker_run_task(config, task, taskdesc):
179179
worker["mounts"].append(
180180
{
181181
"content": {
182-
"taskId": {"task-reference": "<decision>"},
182+
"task-id": {"task-reference": "<decision>"},
183183
"artifact": "public/run-task",
184184
"sha256": run_task_sha256,
185185
},
@@ -190,7 +190,7 @@ def generic_worker_run_task(config, task, taskdesc):
190190
worker["mounts"].append(
191191
{
192192
"content": {
193-
"taskId": {"task-reference": "<decision>"},
193+
"task-id": {"task-reference": "<decision>"},
194194
"artifact": "public/fetch-content",
195195
"sha256": fetch_content_sha256,
196196
},

src/taskgraph/transforms/task.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,8 @@ def build_docker_worker_payload(config, task, task_def):
622622
# URL that supplies the content in response to an unauthenticated
623623
# GET request.
624624
Optional("url"): str,
625+
# SHA256 checksum of the content body
626+
Optional("sha256"): str,
625627
},
626628
# *** Either file or directory must be specified. ***
627629
# If mounting a cache or read-only directory, the filesystem location of

test/test_transforms_run_run_task.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010
from taskgraph.transforms.run import make_task_description
11-
from taskgraph.transforms.task import payload_builders
11+
from taskgraph.transforms.task import payload_builders, set_defaults
1212
from taskgraph.util.caches import CACHES
1313
from taskgraph.util.schema import Schema, validate_schema
1414
from taskgraph.util.templates import merge
@@ -70,6 +70,7 @@ def assert_docker_worker(task):
7070
"-cx",
7171
"echo hello world",
7272
],
73+
"docker-image": {"in-tree": "image"},
7374
"env": {
7475
"CI_BASE_REPOSITORY": "http://hg.example.com",
7576
"CI_HEAD_REF": "default",
@@ -87,6 +88,13 @@ def assert_docker_worker(task):
8788
},
8889
"worker-type": "t-linux",
8990
}
91+
taskdesc = next(set_defaults({}, [task]))
92+
taskdesc["worker"]["max-run-time"] = 0
93+
validate_schema(
94+
payload_builders[taskdesc["worker"]["implementation"]].schema,
95+
taskdesc["worker"],
96+
"validation error",
97+
)
9098

9199

92100
def assert_generic_worker(task):
@@ -123,7 +131,7 @@ def assert_generic_worker(task):
123131
"content": {
124132
"artifact": "public/run-task",
125133
"sha256": "581ca6876fac84fa2dd8e8c2c18677d790890e9675229fd34c912c937ae19fae",
126-
"taskId": {"task-reference": "<decision>"},
134+
"task-id": {"task-reference": "<decision>"},
127135
},
128136
"file": "./run-task",
129137
},
@@ -132,6 +140,13 @@ def assert_generic_worker(task):
132140
},
133141
"worker-type": "b-win2012",
134142
}
143+
taskdesc = next(set_defaults({}, [task]))
144+
taskdesc["worker"]["max-run-time"] = 0
145+
validate_schema(
146+
payload_builders[taskdesc["worker"]["implementation"]].schema,
147+
taskdesc["worker"],
148+
"validation error",
149+
)
135150

136151

137152
def assert_exec_with(task):
@@ -177,7 +192,7 @@ def assert_run_task_command_generic_worker(task):
177192
"task",
178193
(
179194
pytest.param(
180-
{"worker": {"os": "linux"}},
195+
{"worker": {"os": "linux", "docker-image": {"in-tree": "image"}}},
181196
id="docker_worker",
182197
),
183198
pytest.param(

0 commit comments

Comments
 (0)