in taskcluster/translations_taskgraph/transforms/cached_tasks.py [0:0]
def add_cache(config, jobs):
for job in jobs:
cache = job["attributes"]["cache"]
cache_type = cache["type"]
cache_resources = cache["resources"]
cache_parameters = cache.get("from-parameters", {})
digest_data = []
digest_data.extend(list(itertools.chain.from_iterable(job["worker"]["command"])))
if cache_resources:
for r in cache_resources:
digest_data.append(hash_path(r))
if cache_parameters:
for param, path in cache_parameters.items():
if isinstance(path, str):
value = deep_get(config.params, path)
digest_data.append(f"{param}:{value}")
else:
for choice in path:
value = deep_get(config.params, choice)
if value is not None:
digest_data.append(f"{param}:{value}")
break
job["cache"] = {
"type": cache_type,
# Upstream cached tasks use "/" as a separator for different parts
# of the digest. If we don't remove them, caches are busted for
# anything with a "/" in its label.
"name": job["label"].replace("/", "_"),
"digest-data": digest_data,
}
yield job