From f13bf5c0f64189c3e56b54e97c84494fe07f1372 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Wed, 2 Aug 2017 20:17:52 +0900 Subject: [PATCH] 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. --- taskcluster/taskgraph/transforms/job/toolchain.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/taskcluster/taskgraph/transforms/job/toolchain.py b/taskcluster/taskgraph/transforms/job/toolchain.py index ab0d9d058620..742fee746302 100644 --- a/taskcluster/taskgraph/transforms/job/toolchain.py +++ b/taskcluster/taskgraph/transforms/job/toolchain.py @@ -7,6 +7,8 @@ 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 @@ -57,10 +59,21 @@ def add_optimizations(config, run, taskdesc): # 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', [])