Bug 1288567 - Inline create_context_tar; r?dustin
The function was only used once and was providing little to no value.
A test of this function has been removed. Tests for the lower-level
context creation function are sufficient.
MozReview-Commit-ID: D9EhmZQlqG5
--- a/taskcluster/taskgraph/task/docker_image.py
+++ b/taskcluster/taskgraph/task/docker_image.py
@@ -73,18 +73,23 @@ class DockerImageTask(base.Task):
image_artifact_path = \
"public/decision_task/image_contexts/{}/context.tar.gz".format(image_name)
if os.environ.get('TASK_ID'):
destination = os.path.join(
os.environ['HOME'],
"artifacts/decision_task/image_contexts/{}/context.tar.gz".format(image_name))
image_parameters['context_url'] = ARTIFACT_URL.format(
os.environ['TASK_ID'], image_artifact_path)
- context_hash = cls.create_context_tar(context_path, destination,
- image_name)
+
+ destination = os.path.abspath(destination)
+ if not os.path.exists(os.path.dirname(destination)):
+ os.makedirs(os.path.dirname(destination))
+
+ context_hash = create_context_tar(GECKO, context_path,
+ destination, image_name)
else:
# skip context generation since this isn't a decision task
# TODO: generate context tarballs using subdirectory clones in
# the image-building task so we don't have to worry about this.
image_parameters['context_url'] = 'file:///tmp/' + image_artifact_path
context_hash = generate_context_hash(GECKO, context_path, image_name)
image_parameters['context_hash'] = context_hash
@@ -129,28 +134,16 @@ class DockerImageTask(base.Task):
# HEAD success on the artifact is enough
return True, existing_task['taskId']
except urllib2.HTTPError:
pass
return False, None
@classmethod
- def create_context_tar(cls, context_dir, destination, image_name):
- """Creates a tar file of a particular context directory.
-
- Returns the SHA-256 hex digest of the created file.
- """
- destination = os.path.abspath(destination)
- if not os.path.exists(os.path.dirname(destination)):
- os.makedirs(os.path.dirname(destination))
-
- return create_context_tar(GECKO, context_dir, destination, image_name)
-
- @classmethod
def from_json(cls, task_dict):
# Generating index_paths for optimization
routes = task_dict['task']['routes']
index_paths = []
for route in routes:
index_path_regex = re.compile(INDEX_REGEX)
result = index_path_regex.search(route)
if result is None:
--- a/taskcluster/taskgraph/test/test_task_docker_image.py
+++ b/taskcluster/taskgraph/test/test_task_docker_image.py
@@ -1,16 +1,15 @@
# 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, print_function, unicode_literals
import unittest
-import tempfile
import os
from ..task import docker_image
from mozunit import main
KIND_PATH = os.path.join(docker_image.GECKO, 'taskcluster', 'ci', 'docker-image')
@@ -26,17 +25,11 @@ class TestDockerImageKind(unittest.TestC
index_paths=[])
def test_get_task_dependencies(self):
# this one's easy!
self.assertEqual(self.task.get_dependencies(None), [])
# TODO: optimize_task
- def test_create_context_tar(self):
- image_dir = os.path.join(docker_image.GECKO, 'testing', 'docker', 'image_builder')
- tarball = tempfile.mkstemp()[1]
- self.task.create_context_tar(image_dir, tarball, 'image_builder')
- self.failUnless(os.path.exists(tarball))
- os.unlink(tarball)
if __name__ == '__main__':
main()