gecko-dev/taskcluster/taskgraph/transforms/use_fetches.py
Gregory Szorc 6026d2721c Bug 1467605 - Disable processing of fetch dependencies; r=glandium
90dca0906337 accidentally broke `mach artifact toolchain --from-build`
because that code is attempting to load toolchain tasks in isolation.
The new "use_fetches" transform added to toolchain tasks requires
that "fetch" tasks are already processed and their references are
available to toolchain tasks.

This commit adds a mechanism to effectively disable the "use_fetches"
transform when called by `mach artifact toolchain`. It is a hack. I
suspect future planned work around artifacts/fetches will necessitate
additional changes to the `mach artifact toolchain` code. But this
can be deferred to a later day: this commit unbusts `mach artifact
toolchain` and isn't super hacky, so it seems more reasonable than
backing out fetch tasks completely.

Differential Revision: https://phabricator.services.mozilla.com/D1588
2018-06-07 23:05:58 +00:00

60 lines
1.9 KiB
Python

# This Source Code Form is subject to the terms of the Mozilla Public
# 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/.
from __future__ import absolute_import, unicode_literals
from .base import (
TransformSequence,
)
transforms = TransformSequence()
def get_attribute(dict, key, attributes, attribute_name):
'''Get `attribute_name` from the given `attributes` dict, and if there
is a corresponding value, set `key` in `dict` to that value.'''
value = attributes.get(attribute_name)
if value:
dict[key] = value
@transforms.add
def use_fetches(config, jobs):
artifacts = {}
for task in config.kind_dependencies_tasks:
if task.kind != 'fetch':
continue
name = task.label.replace('%s-' % task.kind, '')
get_attribute(artifacts, name, task.attributes, 'fetch-artifact')
for job in jobs:
fetches = job.pop('fetches', [])
# Hack added for `mach artifact toolchain` to support reading toolchain
# kinds in isolation.
if config.params.get('ignore_fetches'):
fetches[:] = []
for fetch in fetches:
if fetch not in artifacts:
raise Exception('Missing fetch job for %s-%s: %s' % (
config.kind, job['name'], fetch))
if not artifacts[fetch].startswith('public/'):
raise Exception('non-public artifacts not supported')
if fetches:
job.setdefault('dependencies', {}).update(
('fetch-%s' % f, 'fetch-%s' % f)
for f in fetches)
env = job.setdefault('worker', {}).setdefault('env', {})
env['MOZ_FETCHES'] = {'task-reference': ' '.join(
'%s@<fetch-%s>' % (artifacts[f], f)
for f in fetches)}
yield job