Skip to content

Instantly share code, notes, and snippets.

@rail
Created October 19, 2015 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rail/f6350161f707088b47eb to your computer and use it in GitHub Desktop.
Save rail/f6350161f707088b47eb to your computer and use it in GitHub Desktop.
diff --git a/testing/mozharness/mozharness/mozilla/taskcluster_helper.py b/testing/mozharness/mozharness/mozilla/taskcluster_helper.py
--- a/testing/mozharness/mozharness/mozilla/taskcluster_helper.py
+++ b/testing/mozharness/mozharness/mozilla/taskcluster_helper.py
@@ -72,43 +72,62 @@ class Taskcluster(LogMixin):
{
"workerGroup": self.buildbot,
"workerId": self.buildbot,
})
def get_task(self, task_id):
return self.taskcluster_queue.task(task_id)
- def create_artifact(self, task, filename):
+ @staticmethod
+ def get_mime_type(ext, default='application/octet-stream'):
mime_types = {
".asc": "text/plain",
".checksums": "text/plain",
".json": "application/json",
".log": "text/plain",
".tar.bz2": "application/x-gtar",
".txt": "text/plain",
".xpi": "application/x-xpinstall",
".zip": "application/zip",
}
- mime_type = mime_types.get(os.path.splitext(filename)[1], 'application/octet-stream')
+ return mime_types.get(ext, default)
+
+ def create_artifact(self, task, filename):
+ mime_type = self.get_mime_type(os.path.splitext(filename)[1])
content_length = os.path.getsize(filename)
-
- self.info("Uploading to S3: filename=%s mimetype=%s length=%s" % (filename, mime_type, content_length))
+ self.info("Uploading to S3: filename=%s mimetype=%s length=%s" % (
+ filename, mime_type, content_length))
expiration = datetime.utcnow() + timedelta(weeks=52)
artifact = self.taskcluster_queue.createArtifact(
task['status']['taskId'],
task['status']['runs'][-1]['runId'],
'public/build/%s' % os.path.basename(filename),
{
"storageType": "s3",
"expires": expiration,
"contentType": mime_type,
})
self.put_file(filename, artifact['putUrl'], mime_type)
+ return self.get_taskcluster_url(filename)
+
+ def create_reference_artifact(self, task, filename, url):
+ mime_type = self.get_mime_type(os.path.splitext(filename)[1])
+ expiration = datetime.utcnow() + timedelta(weeks=52)
+ self.taskcluster_queue.createArtifact(
+ task['status']['taskId'],
+ task['status']['runs'][-1]['runId'],
+ 'public/build/%s' % os.path.basename(filename),
+ {
+ "storageType": "reference",
+ "expires": expiration,
+ "contentType": mime_type,
+ "url": url,
+ })
def report_completed(self, task):
self.taskcluster_queue.reportCompleted(
task['status']['taskId'],
task['status']['runs'][-1]['runId'],
{
"success": True,
})
diff --git a/testing/mozharness/scripts/desktop_l10n.py b/testing/mozharness/scripts/desktop_l10n.py
--- a/testing/mozharness/scripts/desktop_l10n.py
+++ b/testing/mozharness/scripts/desktop_l10n.py
@@ -1006,19 +1006,20 @@ class DesktopSingleLocale(LocalesMixin,
task = tc.create_task(routes)
tc.claim_task(task)
for upload_file in files:
# Create an S3 artifact for each file that gets uploaded. We also
# check the uploaded file against the property conditions so that we
# can set the buildbot config with the correct URLs for package
# locations.
- tc.create_artifact(task, upload_file)
+ artifact_url = tc.create_artifact(task, upload_file)
if bbb_task:
- # Also attach the artifact to BBB task
- tc.create_artifact(bbb_task, upload_file)
+ # Also attach the artifact to BBB task as a reference
+ tc.create_reference_artifact(bbb_task, upload_file,
+ artifact_url)
tc.report_completed(task)
# main {{{
if __name__ == '__main__':
single_locale = DesktopSingleLocale()
single_locale.run_and_exit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment