diff --git a/automation/taskcluster/decision_task_nightly.py b/automation/taskcluster/decision_task_nightly.py index 6ba9cb4d5..ba3424206 100644 --- a/automation/taskcluster/decision_task_nightly.py +++ b/automation/taskcluster/decision_task_nightly.py @@ -100,6 +100,22 @@ def generate_push_task(signing_task_id, apks, commit, is_staging): ) +# For GeckoView, upload nightly (it has release config) by default, all Release builds have WV +def generate_upload_apk_nimbledroid_task(build_task_id): + checkout = 'git clone {} && cd reference-browser && git checkout {}'.format(GITHUB_HTTP_REPOSITORY, HEAD_REV) + return taskcluster.slugId(), BUILDER.craft_upload_apk_nimbledroid_task( + build_task_id, + name="(RB for Android) Upload Debug APK to Nimbledroid", + description="Upload APKs to Nimbledroid for performance measurement and tracking.", + command=(#'echo "--" > .adjust_token' + 'cd .. && ' + checkout + + ' && ./gradlew --no-daemon clean assembleDebug' + ' && python automation/taskcluster/upload_apk_nimbledroid.py'), + dependencies= [build_task_id], + scopes=["secrets:get:project/mobile/reference-browser/nimbledroid"], +) + + def populate_chain_of_trust_required_but_unused_files(): # These files are needed to keep chainOfTrust happy. However, they have no need for Reference Browser # at the moment. For more details, see: https://github.com/mozilla-releng/scriptworker/pull/209/files#r184180585 @@ -133,6 +149,12 @@ def nightly(apks, commit, date_string, is_staging): task_graph[push_task_id] = {} task_graph[push_task_id]['task'] = queue.task(push_task_id) + upload_nd_task_id, upload_nd_task = generate_upload_apk_nimbledroid_task(build_task_id) + lib.tasks.schedule_task(queue, upload_nd_task_id, upload_nd_task) + + task_graph[upload_nd_task_id] = {} + task_graph[upload_nd_task_id]['task'] = queue.task(upload_nd_task_id) + print(json.dumps(task_graph, indent=4, separators=(',', ': '))) with open('task-graph.json', 'w') as f: diff --git a/automation/taskcluster/lib/tasks.py b/automation/taskcluster/lib/tasks.py index cac87a048..98a8952da 100644 --- a/automation/taskcluster/lib/tasks.py +++ b/automation/taskcluster/lib/tasks.py @@ -106,6 +106,49 @@ def craft_push_task(self, signing_task_id, name, description, commit, is_staging }, ) + def craft_upload_apk_nimbledroid_task(self, build_task_id, name, description, command, dependencies, scopes): + created = datetime.datetime.now() + expires = taskcluster.fromNow('1 year') + deadline = taskcluster.fromNow('1 day') + + return { + "workerType": self.build_worker_type, + "taskGroupId": self.task_id, + "schedulerId": self.scheduler_id, + "expires": taskcluster.stringDate(expires), + "retries": 5, + "created": taskcluster.stringDate(created), + "tags": {}, + "priority": 'lowest', + "deadline": taskcluster.stringDate(deadline), + "dependencies": [self.task_id, build_task_id], + "routes": [], + "scopes": scopes, + "requires": 'all-completed', + "payload": { + "features": { + "taskclusterProxy": True + }, + "maxRunTime": 7200, + "image": "mozillamobile/android-components:1.15", + "command": [ + "/bin/bash", + "--login", + "-cx", + command + ], + "artifacts": {}, + "deadline": taskcluster.stringDate(deadline) + }, + "provisionerId": 'aws-provisioner-v1', + "metadata": { + "name": name, + "description": description, + "owner": self.owner, + "source": self.source + } + } + def craft_default_task_definition( self, worker_type, provisioner_id, dependencies, routes, scopes, name, description, payload, treeherder diff --git a/automation/taskcluster/upload_apk_nimbledroid.py b/automation/taskcluster/upload_apk_nimbledroid.py new file mode 100644 index 000000000..8c86b26dc --- /dev/null +++ b/automation/taskcluster/upload_apk_nimbledroid.py @@ -0,0 +1,53 @@ +# 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/. + +""" +This script talks to the taskcluster secrets service to obtain the +Nimbledroid account key and upload Klar and Focus apk to Nimbledroid for perf analysis. +""" + +import taskcluster +import requests +import json +import urllib2 +import os + +url = "https://nimbledroid.com/api/v2/apks" + +def uploadApk(apk,key): + headers = {"Accept":"*/*"} + payload = {'auto_scenarios':'false'} + response = requests.post(url, auth=(key, ''), headers=headers, files=apk, data=payload) + + if response.status_code != 201: + print('Status:', response.status_code, 'Headers:', response.headers, 'Error Response:',response.json()) + exit(1) + + # Print Response Details + print 'Response Status Code:', response.status_code + + print '' + print('Reponse Payload:') + print json.dumps(response.json(), indent=4) + + +def uploadGeckoViewExampleApk(key): + apk_url = 'https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.latest.mobile.android-api-16-opt/artifacts/public/build/geckoview_example.apk' + apk_data = urllib2.urlopen(apk_url).read() + with open('./geckoview_example_nd.apk', 'wb') as f: + f.write(apk_data) + uploadApk({'apk' : open('geckoview_example_nd.apk')},key) + + + +# Get JSON data from taskcluster secrets service +secrets = taskcluster.Secrets({'baseUrl': 'http://taskcluster/secrets/v1'}) +data = secrets.get('project/mobile/reference-browser/nimbledroid') + +rb_file_arm = {'apk': open('app/build/outputs/apk/geckoNightlyArm/debug/app-geckoNightly-arm-debug.apk')} + +# upload 32 bit apk +uploadApk(rb_file_arm, data['secret']['api_key']) +# also upload the latest geckoview example from: +uploadGeckoViewExampleApk(data['secret']['api_key'])