Bug 1386519 - Make the index path for toolchain jobs vary depending on dependencies. r?dustin
The premise for simply using the dependencies task names is that if the
name of dependencies changes, or their number, that will impact the
index path, forcing a new build. If there is no such change, but one or
several of the dependencies themselves have changes, they will get a new
build, which will force a new build for the job that depends on them.
In that latter case, the index path will be the same as before the
changes, but that is already what's happening today.
--- a/taskcluster/taskgraph/transforms/job/toolchain.py
+++ b/taskcluster/taskgraph/transforms/job/toolchain.py
@@ -2,16 +2,18 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Support for running toolchain-building jobs via dedicated scripts
"""
from __future__ import absolute_import, print_function, unicode_literals
+import hashlib
+
from taskgraph.util.schema import Schema
from voluptuous import Optional, Required, Any
from taskgraph.transforms.job import run_job_using
from taskgraph.transforms.job.common import (
docker_worker_add_tc_vcs_cache,
docker_worker_add_gecko_vcs_env_vars,
docker_worker_add_public_artifacts,
@@ -52,20 +54,31 @@ toolchain_run_schema = Schema({
def add_optimizations(config, run, taskdesc):
files = list(run.get('resources', []))
# This file
files.append('taskcluster/taskgraph/transforms/job/toolchain.py')
# The script
files.append('taskcluster/scripts/misc/{}'.format(run['script']))
+ digest = hash_paths(GECKO, files)
+
+ # If the task has dependencies, we need those dependencies to influence
+ # the index path. So take the digest from the files above, add the list
+ # of its dependencies, and hash the aggregate.
+ # If the task has no dependencies, just use the digest from above.
+ deps = taskdesc['dependencies']
+ if deps:
+ data = [digest] + sorted(deps.values())
+ digest = hashlib.sha256('\n'.join(data)).hexdigest()
+
label = taskdesc['label']
subs = {
'name': label.replace('%s-' % config.kind, ''),
- 'digest': hash_paths(GECKO, files),
+ 'digest': digest,
}
optimizations = taskdesc.setdefault('optimizations', [])
# We'll try to find a cached version of the toolchain at levels above
# and including the current level, starting at the highest level.
for level in reversed(range(int(config.params['level']), 4)):
subs['level'] = level