Skip to content
Open
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
5 changes: 5 additions & 0 deletions src/taskgraph/transforms/cached_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def cache_task(config, tasks):
if task.get("worker", {}).get("chain-of-trust"):
digest_data.append(str(task["worker"]["chain-of-trust"]))

# The worker type can affect the environment the task runs in (e.g
# platform or architecture), so it should influence the cache digest.
if task.get("worker-type"):
digest_data.append(task["worker-type"])

add_optimization(
config,
task,
Expand Down
43 changes: 43 additions & 0 deletions test/test_transforms_cached_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ def assert_chain_of_trust_influences_digest(tasks):
assert digest_0 != digest_1


def assert_worker_type_influences_digest(tasks):
assert len(tasks) == 3
tasks = sorted(tasks, key=lambda t: t["label"]) # no-wt, wt-a, wt-b
digests = [t["attributes"]["cached_task"]["digest"] for t in tasks]
assert len(set(digests)) == 3


@pytest.mark.parametrize(
"tasks, kind_config, deps",
(
Expand Down Expand Up @@ -233,6 +240,42 @@ def assert_chain_of_trust_influences_digest(tasks):
{},
id="chain_of_trust_influences_digest",
),
pytest.param(
# tasks
[
{
"cache": {
"type": "cached-task.v2",
"name": "cache-foo",
"digest-data": ["abc"],
},
"label": "no-wt",
},
{
"cache": {
"type": "cached-task.v2",
"name": "cache-foo",
"digest-data": ["abc"],
},
"label": "wt-a",
"worker-type": "a",
},
{
"cache": {
"type": "cached-task.v2",
"name": "cache-foo",
"digest-data": ["abc"],
},
"label": "wt-b",
"worker-type": "b",
},
],
# kind config
{},
# kind deps
{},
id="worker_type_influences_digest",
),
),
)
def test_transforms(
Expand Down
Loading