diff --git a/.gitignore b/.gitignore index 379998897bb..3313aea9d4b 100644 --- a/.gitignore +++ b/.gitignore @@ -55,7 +55,6 @@ infer-out/ # Screenshots fastlane/ -Screengrabfile # Adjust token file .adjust_token diff --git a/Screengrabfile b/Screengrabfile deleted file mode 100644 index 11611eeaaf8..00000000000 --- a/Screengrabfile +++ /dev/null @@ -1,29 +0,0 @@ -# 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 is the template for our Screengrabfile used in automation. -# tools/taskcluster/generate_screengrab_config.py will read this -# file and generate the final configuration that we use inside -# a taskcluster task. - -app_package_name 'org.mozilla.focus.debug' -use_tests_in_packages ['org.mozilla.focus.screenshots'] - -app_apk_path 'app/build/outputs/apk/focusArm/debug/app-focus-arm-debug.apk' -tests_apk_path 'app/build/outputs/apk/androidTest/focusArm/debug/app-focus-arm-debug-androidTest.apk' - -locales ['af', 'ace','am','an','anp','ar', 'ast', 'ay', 'az', 'bg', 'bn-BD', 'bn-IN', 'bo','bs','ca', - 'cak', 'co', 'cs', 'cy', 'da','de', 'dsb', 'el', 'eo', 'es-AR', 'es-CL', 'es-ES', 'es-MX', - 'eu','fa', 'fi','fr', 'fy-NL','ga-IE', 'gl','gu-IN','he', 'hi-IN','hr', 'hsb', 'hu', 'hus', - 'hy-AM', 'ia','id', 'it', 'ixl', 'ja', 'jv', 'ka', 'kab', 'kk', 'ko', 'kw', 'lo', 'lt', - 'meh','mix', 'mr', 'ms', 'my','nb-NO', 'ne-NP', 'nl', 'nn-NO','oc', 'pa-IN', 'pai', 'pl', - 'ppl', 'pt-BR', 'quc', 'quy', 'ro', 'ru', 'sk', 'sl', 'sn', 'sq', 'sr', 'su', 'sv-SE', 'ta', - 'te', 'th', 'tr','trs', 'tsz', 'tt', 'uk', 'ur', 'vi','wo','zam','zh-CN', 'zh-TW','en-CA'] - -# Clear all previous screenshots locally. Technically not needed in automation. -# But it's easier to debug this on a local device if there are no old screenshots -# hanging around. -clear_previous_screenshots true -reinstall_app true -exit_on_test_failure false diff --git a/Screengrabfile.template b/Screengrabfile.template deleted file mode 100644 index fff89b817c0..00000000000 --- a/Screengrabfile.template +++ /dev/null @@ -1,25 +0,0 @@ -# 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 is the template for our Screengrabfile used in automation. -# tools/taskcluster/generate_screengrab_config.py will read this -# file and generate the final configuration that we use inside -# a taskcluster task. - -use_tests_in_packages ['org.mozilla.focus.screenshots'] - -app_package_name 'org.mozilla.focus.debug' -use_tests_in_packages ['org.mozilla.focus.activity'] - -app_apk_path 'app/build/outputs/apk/app-focus-webview-debug.apk' -tests_apk_path 'app/build/outputs/apk/app-focus-webview-debug-androidTest.apk' - -# Clear all previous screenshots locally. Technically not needed in automation. -# But it's easier to debug this on a local device if there are no old screenshots -# hanging around. -clear_previous_screenshots true - -exit_on_test_failure false - -skip_open_summary true diff --git a/tools/taskcluster/accept-license.sh b/tools/taskcluster/accept-license.sh deleted file mode 100755 index dccd44485df..00000000000 --- a/tools/taskcluster/accept-license.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# 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/. - -# If a command fails, do not fail the script -set -ex - -# Accept SDK license -if [[ $(type -P "sdkmanager") ]]; then - yes | sdkmanager "platforms;android-29" "build-tools;28.0.3" -elif [[ $(type -P "android") ]]; then - (while sleep 3; do echo "y"; done) | android update sdk --no-ui --all --filter android-29 - (while sleep 3; do echo "y"; done) | android update sdk --no-ui --all --filter build-tools-28.0.3 -fi diff --git a/tools/taskcluster/execute-firebase-tests.sh b/tools/taskcluster/execute-firebase-tests.sh deleted file mode 100755 index f73025d2206..00000000000 --- a/tools/taskcluster/execute-firebase-tests.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env bash -# 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 uses the flank tool (https://github.com/TestArmada/flank) -# to shard UI test execution on Google Firebase so tests can run in parallel. -# -# NOTE: -# Google Firebase does not currently allow renaming nor grouping of test -# jobs. recommendation: look at test failure summary in taskcluster -# (not on Firebase dashboard) - - -# From now on disable exiting on error. If the tests fail we want to continue -# and try to download the artifacts. We will exit with the actual error code later. -set +e - -URL_FLANK_BIN="https://github.com/Flank/flank/releases/download/v21.08.1/flank.jar" -JAVA_BIN="/usr/bin/java" -WORKDIR="/opt/focus-android" -PATH_TOOLS="$WORKDIR/tools/taskcluster" -FLANK_BIN="$PATH_TOOLS/flank.jar" -FLANK_CONF="$PATH_TOOLS/flank.yml" - -echo "home: $HOME" -export GOOGLE_APPLICATION_CREDENTIALS="$WORKDIR/.firebase_token.json" - -rm -f TEST_TARGETS -rm -f $FLANK_BIN - -echo -echo "---------------------------------------" -echo "FLANK FILES" -echo "---------------------------------------" -echo "FLANK_CONF: $FLANK_CONF" -echo "FLANK_BIN: $FLANK_BIN" -echo - -curl --location --retry 5 --output $FLANK_BIN $URL_FLANK_BIN - -echo -echo "---------------------------------------" -echo "FLANK VERSION" -echo "---------------------------------------" -chmod +x $FLANK_BIN -$JAVA_BIN -jar $FLANK_BIN -v -echo -echo -echo "---------------------------------------" - -$JAVA_BIN -jar $FLANK_BIN android run --config=$FLANK_CONF -exitcode=$? - -cp -r "$WORKDIR/results" "$WORKDIR/test_artifacts" - -# Now exit the script with the exit code from the test run. (Only 0 if all test executions passed) -exit $exitcode diff --git a/tools/taskcluster/flank.yml b/tools/taskcluster/flank.yml deleted file mode 100644 index 5b4b1f3225a..00000000000 --- a/tools/taskcluster/flank.yml +++ /dev/null @@ -1,69 +0,0 @@ -# gcloud args match the official gcloud cli -# https://cloud.google.com/sdk/gcloud/reference/firebase/test/android/run -gcloud: - #results-bucket: focus_android_test_artifacts - #results-bucket: focus_android_test_reports - record-video: true - - # The maximum possible testing time is 30m on physical devices and 60m on virtual devices. - timeout: 30m - # will start test then close socket. no reports will be generated. - # to retrieve results later, use the "refresh" command - # reports will be generated from /results/matrix_ids.json - #async: true - # will start test then leave socket open. reports will be published - # to /results - # see: https://github.com/TestArmada/flank/issues/339 - async: false - - # results-history-name - # by default, set to app name - # declare results-history-name to create a separate dropdown menu in Firebase - # see: https://github.com/TestArmada/flank/issues/341 - #results-history-name: tmp_parallel - - # The number of times a test execution should be re-attempted if one or more failures occur. - # The maximum number of reruns allowed is 10. Default is 0, which implies no reruns. - num-flaky-test-attempts: 1 - - # test and app are the only required args - app: /opt/focus-android/app/build/outputs/apk/focus/debug/app-focus-x86-debug.apk - test: /opt/focus-android/app/build/outputs/apk/androidTest/focus/debug/app-focus-debug-androidTest.apk - auto-google-login: true - use-orchestrator: true - environment-variables: - clearPackageData: true - directories-to-pull: - - /sdcard/screenshots - performance-metrics: true - - test-targets: - - package org.mozilla.focus.activity - - package org.mozilla.focus.privacy - - package org.mozilla.focus.screenshots - - device: - - model: Pixel2 - version: 28 - -flank: - project: moz-fx-mobile-firebase-testlab - - # test shards - the amount of groups to split the test suite into - # set to -1 to use one shard per test. - max-test-shards: -1 - ### Output Style flag - ## Output style of execution status. May be one of [verbose, multi, single, compact]. - ## For runs with only one test execution the default value is 'verbose', in other cases - ## 'multi' is used as the default. The output style 'multi' is not displayed correctly on consoles - ## which don't support ansi codes, to avoid corrupted output use single or verbose. - ## The output style `compact` is used to produce less detailed output, it prints just Args, test and matrix count, weblinks, cost, and result reports. - output-style: compact - # repeat tests - the amount of times to run the tests. - # 1 runs the tests once. 10 runs all the tests 10x - num-test-runs: 1 - # always run - these tests are inserted at the beginning of every shard - # useful if you need to grant permissions or login before other tests run - #test-targets-always-run: - #- class com.example.app.ExampleUiTest#testPasses - # - class org.mozilla.klar.activty.SwitchContextTest#testPasses diff --git a/tools/taskcluster/generate_screengrab_config.py b/tools/taskcluster/generate_screengrab_config.py deleted file mode 100644 index 9e69b0782cb..00000000000 --- a/tools/taskcluster/generate_screengrab_config.py +++ /dev/null @@ -1,34 +0,0 @@ -# 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 will read the Screengrabfile.template from the project -root directory and created the final Screengrabfile by injecting -the locales passed to this script. -""" - -import os -import sys - -# Read template -template_path = os.path.join(os.path.dirname(__file__), '../../Screengrabfile.template') -with open(template_path) as template_file: - template = template_file.read() - -# Read locales from arguments -locales = sys.argv[1:] - -# Generate list for config file in format: locales ['a', 'b', 'c'] -locales_config = 'locales [' + ', '.join(map(lambda x: "'%s'" % x, locales[:])) + ']' - -# Write configuration -config_path = os.path.join(os.path.dirname(__file__), '../../Screengrabfile') -with open(config_path, 'w') as config_file: - config_file = open(config_path, 'w') - config_file.write(template) - config_file.write("\n") - config_file.write(locales_config) - config_file.write("\n") - -print("Wrote Screengrabfile file (%s): %s" % (", ".join(locales), config_path)) diff --git a/tools/taskcluster/get-adjust-token.py b/tools/taskcluster/get-adjust-token.py deleted file mode 100644 index 0b6a17a8f8f..00000000000 --- a/tools/taskcluster/get-adjust-token.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 -Adjust token and write it to the .adjust_token file in the root -directory. -""" - -import os -import taskcluster - -# Get JSON data from taskcluster secrets service -secrets = taskcluster.Secrets({'baseUrl': 'http://taskcluster/secrets/v1'}) -data = secrets.get('project/mobile/focus-android/tokens') - -token_file_path = os.path.join(os.path.dirname(__file__), '../../.adjust_token') -with open(token_file_path, 'w') as token_file: - token_file.write(data['secret']['adjustToken']) - -print("Imported adjust token from secrets service") diff --git a/tools/taskcluster/get-google-firebase-token.py b/tools/taskcluster/get-google-firebase-token.py deleted file mode 100644 index e9a914c1f2b..00000000000 --- a/tools/taskcluster/get-google-firebase-token.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 -Google Firebase service account token and write it to the .firebase_token -file in the root directory. -""" - -import base64 -import os -import taskcluster - -# Get JSON data from taskcluster secrets service -secrets = taskcluster.Secrets({'baseUrl': 'http://taskcluster/secrets/v1'}) -data = secrets.get('project/focus/firebase') - -with open(os.path.join(os.path.dirname(__file__), '../../.firebase_token.json'), 'w') as file: - file.write(base64.b64decode(data['secret']['keyFile'])) - -print("Imported google firebase token from secrets service") diff --git a/tools/taskcluster/get-mls-token.py b/tools/taskcluster/get-mls-token.py deleted file mode 100644 index 6f6f29f4e64..00000000000 --- a/tools/taskcluster/get-mls-token.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 -Adjust token and write it to the .adjust_token file in the root -directory. -""" - -import os -import taskcluster - -# Get JSON data from taskcluster secrets service -secrets = taskcluster.Secrets({'baseUrl': 'http://taskcluster/secrets/v1'}) -data = secrets.get('project/mobile/focus-android/tokens') - -token_file_path = os.path.join(os.path.dirname(__file__), '../../.mls_token') -with open(token_file_path, 'w') as token_file: - token_file.write(data['secret']['mls']) - -print("Imported MLS token from secrets service") diff --git a/tools/taskcluster/get-nimbus-url.py b/tools/taskcluster/get-nimbus-url.py deleted file mode 100644 index 408ee9e2fa4..00000000000 --- a/tools/taskcluster/get-nimbus-url.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 -Nimbus endpoint and write it to the .nimbus file in the root -directory. -""" - -import os -import taskcluster - -# Get JSON data from taskcluster secrets service -secrets = taskcluster.Secrets({'baseUrl': 'http://taskcluster/secrets/v1'}) -data = secrets.get('project/mobile/focus-android/tokens') - -token_file_path = os.path.join(os.path.dirname(__file__), '../../.nimbus') -with open(token_file_path, 'w') as token_file: - token_file.write(data['secret']['nimbus']) - -print("Imported Nimbus endpoint from secrets service") diff --git a/tools/taskcluster/get-sentry-token.py b/tools/taskcluster/get-sentry-token.py deleted file mode 100644 index 65e4163c42b..00000000000 --- a/tools/taskcluster/get-sentry-token.py +++ /dev/null @@ -1,22 +0,0 @@ -# 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 -Sentry token and write it to the .sentry_token file in the root -directory. -""" - -import os -import taskcluster - -# Get JSON data from taskcluster secrets service -secrets = taskcluster.Secrets({'baseUrl': 'http://taskcluster/secrets/v1'}) -data = secrets.get('project/mobile/focus-android/tokens') - -token_file_path = os.path.join(os.path.dirname(__file__), '../../.sentry_token') -with open(token_file_path, 'w') as token_file: - token_file.write(data['secret']['sentryToken']) - -print("Imported sentry token from secrets service") diff --git a/tools/taskcluster/google-firebase-testlab-login.sh b/tools/taskcluster/google-firebase-testlab-login.sh deleted file mode 100755 index 123122f4a28..00000000000 --- a/tools/taskcluster/google-firebase-testlab-login.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# 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 imports the latest strings, creates a commit, pushes -# it to the bot's repository and creates a pull request. - -# If a command fails then do not proceed and fail this script too. -set -ex - -# download the login JSON token info from taskcluster -python tools/taskcluster/get-google-firebase-token.py - -# this is where the Google Testcloud project ID is set -/opt/google-cloud-sdk/bin/gcloud config set project moz-fx-mobile-firebase-testlab - - # this is where the service account login happens with the saved JSON from above -/opt/google-cloud-sdk/bin/gcloud auth activate-service-account --key-file .firebase_token.json \ No newline at end of file diff --git a/tools/taskcluster/lib/__init__.py b/tools/taskcluster/lib/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/tools/taskcluster/lib/tasks.py b/tools/taskcluster/lib/tasks.py deleted file mode 100644 index 641f611492e..00000000000 --- a/tools/taskcluster/lib/tasks.py +++ /dev/null @@ -1,153 +0,0 @@ -# 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/. - -import datetime -import json -import os -import taskcluster - - -class TaskBuilder(object): - def __init__(self, task_id, repo_url, branch, commit, owner, source, scheduler_id): - self.task_id = task_id - self.repo_url = repo_url - self.branch = branch - self.commit = commit - self.owner = owner - self.source = source - self.scheduler_id = scheduler_id - - def build_task(self, name, description, command, dependencies = [], artifacts = {}, scopes = [], routes = [], features = {}): - created = datetime.datetime.now() - expires = taskcluster.fromNow('1 year') - deadline = taskcluster.fromNow('1 day') - - features = features.copy() - features.update({ - "taskclusterProxy": True - }) - - return { - "workerType": "b-linux", - "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 ] + dependencies, - "routes": routes, - "scopes": scopes, - "requires": "all-completed", - "payload": { - "features": features, - "maxRunTime": 7200, - "image": "mozillamobile/focus-android:1.7", - "command": [ - "/bin/bash", - "--login", - "-c", - command - ], - "env": {}, - "artifacts": artifacts, - "deadline": taskcluster.stringDate(deadline) - }, - "provisionerId": "mobile-3", - "metadata": { - "name": name, - "description": description, - "owner": self.owner, - "source": self.source - } - } - - - def build_signing_task(self, build_task_id, name, description, signing_format, apks=[], scopes=[], routes=[]): - created = datetime.datetime.now() - expires = taskcluster.fromNow('1 year') - deadline = taskcluster.fromNow('1 day') - - return { - "workerType": 'mobile-3-signing', - "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": routes, - "scopes": scopes, - "requires": "all-completed", - "payload": { - "maxRunTime": 3600, - "upstreamArtifacts": [ - { - "paths": apks, - "formats": [signing_format], - "taskId": build_task_id, - "taskType": "build" - } - ] - }, - "provisionerId": "scriptworker-k8s", - "metadata": { - "name": name, - "description": description, - "owner": self.owner, - "source": self.source - } - } - - def build_push_task(self, signing_task_id, name, description, apks=[], scopes=[], channel='internal', commit=False): - created = datetime.datetime.now() - expires = taskcluster.fromNow('1 year') - deadline = taskcluster.fromNow('1 day') - - return { - "workerType": 'mobile-3-pushapk', - "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, signing_task_id], - "routes": [], - "scopes": scopes, - "requires": "all-completed", - "payload": { - "commit": commit, - "channel": channel, - "upstreamArtifacts": [ - { - "paths": apks, - "taskId": signing_task_id, - "taskType": "signing" - } - ] - }, - "provisionerId": "scriptworker-k8s", - "metadata": { - "name": name, - "description": description, - "owner": "skaspari@mozilla.com", - "source": "https://github.com/mozilla-mobile/focus-android/tree/main/tools/taskcluster" - } - } - -def schedule_task(queue, taskId, task): - print "TASK", taskId - print json.dumps(task, indent=4, separators=(',', ': ')) - - result = queue.createTask(taskId, task) - print "RESULT", taskId - print json.dumps(result) diff --git a/tools/taskcluster/release.py b/tools/taskcluster/release.py deleted file mode 100644 index 11017a8f8d2..00000000000 --- a/tools/taskcluster/release.py +++ /dev/null @@ -1,177 +0,0 @@ -# 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 is executed on taskcluster whenever we want to release builds -to Google Play. It will schedule the taskcluster tasks for building, -signing and uploading a release. -""" - -import argparse -import json -import os -import taskcluster -import lib.tasks - -TASK_ID = os.environ.get('TASK_ID') -SCHEDULER_ID = os.environ.get('SCHEDULER_ID') -HEAD_REV = os.environ.get('MOBILE_HEAD_REV') - -BUILDER = lib.tasks.TaskBuilder( - task_id=TASK_ID, - repo_url=os.environ.get('MOBILE_HEAD_REPOSITORY'), - branch=os.environ.get('MOBILE_HEAD_BRANCH'), - commit=HEAD_REV, - owner="skaspari@mozilla.com", - source='https://github.com/mozilla-mobile/focus-android/raw/{}/.taskcluster.yml'.format(HEAD_REV), - scheduler_id=SCHEDULER_ID, -) - -def generate_build_task(apks, tag): - artifacts = {} - for apk in apks: - artifact = { - "type": 'file', - "path": apk, - "expires": taskcluster.stringDate(taskcluster.fromNow('1 year')) - } - artifacts["public/%s" % os.path.basename(apk)] = artifact - - checkout = "git fetch origin && git reset --hard origin/main" if tag is None else "git fetch origin && git checkout %s" % (tag) - - assemble_task = 'assembleNightly' - - if tag: - # Non-tagged (nightly) builds should contain all languages - checkout = checkout + ' && python tools/l10n/filter-release-translations.py' - assemble_task = 'assembleRelease' - - - return taskcluster.slugId(), BUILDER.build_task( - name="(Focus for Android) Build task", - description="Build Focus/Klar from source code.", - command=(checkout + - ' && python tools/taskcluster/get-adjust-token.py' - ' && python tools/taskcluster/get-sentry-token.py' - ' && python tools/taskcluster/get-mls-token.py' - ' && python tools/taskcluster/get-nimbus-url.py' - ' && ./gradlew --no-daemon clean test ' + assemble_task), - features = { - "chainOfTrust": True - }, - artifacts = artifacts, - scopes=[ - "secrets:get:project/mobile/focus-android/tokens" - ]) - -def generate_signing_task(build_task_id, apks, tag): - artifacts = [] - for apk in apks: - artifacts.append("public/" + os.path.basename(apk)) - - routes = [] - - signing_format = 'autograph_focus' - - scopes = [ - "project:mobile:focus:releng:signing:cert:release-signing", - "project:mobile:focus:releng:signing:format:{}".format(signing_format), - ] - - if tag: - index = "index.project.mobile.focus.release.latest" - routes.append(index) - scopes.append("queue:route:" + index) - else: - index = "index.project.mobile.focus.nightly.latest" - routes.append(index) - scopes.append("queue:route:" + index) - - return taskcluster.slugId(), BUILDER.build_signing_task( - build_task_id, - name="(Focus for Android) Signing task", - description="Sign release builds of Focus/Klar", - signing_format=signing_format, - apks=artifacts, - scopes=scopes, - routes=routes - ) - -def generate_push_task(signing_task_id, apks, channel, commit): - artifacts = [] - for apk in apks: - artifacts.append("public/" + os.path.basename(apk)) - - print artifacts - - return taskcluster.slugId(), BUILDER.build_push_task( - signing_task_id, - name="(Focus for Android) Push task", - description="Upload signed release builds of Focus/Klar to Google Play", - apks=artifacts, - scopes=[ - "project:mobile:focus:releng:googleplay:product:focus" - ], - channel = channel, - commit = commit - ) - -def populate_chain_of_trust_required_but_unused_files(): - # Thoses files are needed to keep chainOfTrust happy. However, they have no need for Firefox - # Focus, at the moment. For more details, see: - # https://github.com/mozilla-releng/scriptworker/pull/209/files#r184180585 - - for file_names in ('actions.json', 'parameters.yml'): - with open(file_names, 'w') as f: - json.dump({}, f) # Yaml is a super-set of JSON. - - -def release(apks, channel, commit, tag): - queue = taskcluster.Queue({ 'baseUrl': 'http://taskcluster/queue/v1' }) - - task_graph = {} - - build_task_id, build_task = generate_build_task(apks, tag) - lib.tasks.schedule_task(queue, build_task_id, build_task) - - task_graph[build_task_id] = {} - task_graph[build_task_id]["task"] = queue.task(build_task_id) - - sign_task_id, sign_task = generate_signing_task(build_task_id, apks, tag) - lib.tasks.schedule_task(queue, sign_task_id, sign_task) - - task_graph[sign_task_id] = {} - task_graph[sign_task_id]["task"] = queue.task(sign_task_id) - - push_task_id, push_task = generate_push_task(sign_task_id, apks, channel, commit) - lib.tasks.schedule_task(queue, push_task_id, push_task) - - task_graph[push_task_id] = {} - task_graph[push_task_id]["task"] = queue.task(push_task_id) - - print json.dumps(task_graph, indent=4, separators=(',', ': ')) - - task_graph_path = "task-graph.json" - with open(task_graph_path, 'w') as f: - json.dump(task_graph, f) - - populate_chain_of_trust_required_but_unused_files() - - - -if __name__ == "__main__": - parser = argparse.ArgumentParser( - description='Create a release pipeline (build, sign, publish) on taskcluster.') - - parser.add_argument('--channel', dest="channel", action="store", choices=['release', 'nightly', 'beta'], help="", required=True) - parser.add_argument('--commit', dest="commit", action="store_true", help="commit the google play transaction") - parser.add_argument('--tag', dest="tag", action="store", help="git tag to build from") - parser.add_argument('--apk', dest="apks", metavar="path", action="append", help="Path to APKs to sign and upload", required=True) - parser.add_argument('--output', dest="output", metavar="path", action="store", help="Path to the build output", required=True) - - result = parser.parse_args() - - apks = map(lambda x: result.output + '/' + x, result.apks) - - release(apks, result.channel, result.commit, result.tag) diff --git a/tools/taskcluster/schedule-main-build.py b/tools/taskcluster/schedule-main-build.py deleted file mode 100644 index 93a77d60c0d..00000000000 --- a/tools/taskcluster/schedule-main-build.py +++ /dev/null @@ -1,155 +0,0 @@ -# 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 will be executed whenever a change is pushed to the -main branch. It will schedule multiple child tasks that build -the app, run tests and execute code quality tools: -""" - -import datetime -import taskcluster -import os - -from lib.tasks import schedule_task - - -TASK_ID = os.environ.get('TASK_ID') -REPO_URL = os.environ.get('MOBILE_HEAD_REPOSITORY') -BRANCH = os.environ.get('MOBILE_HEAD_BRANCH') -COMMIT = os.environ.get('MOBILE_HEAD_REV') -OWNER = "skaspari@mozilla.com" -SOURCE = "https://github.com/mozilla-mobile/focus-android/tree/main/tools/taskcluster" - - -def generate_build_task(): - return taskcluster.slugId(), generate_task( - name="(Focus for Android) Build", - description="Build Focus/Klar for Android from source code.", - command=('echo "--" > .adjust_token' - ' && ./gradlew --no-daemon clean assemble')) - - -def generate_unit_test_task(buildTaskId): - return taskcluster.slugId(), generate_task( - name="(Focus for Android) Unit tests", - description="Run unit tests for Focus/Klar for Android.", - command='echo "--" > .adjust_token && ./gradlew --no-daemon clean test', - dependencies=[buildTaskId]) - - -def generate_code_quality_task(buildTaskId): - return taskcluster.slugId(), generate_task( - name="(Focus for Android) Code quality", - description="Run code quality tools on Focus/Klar for Android code base.", - command='echo "--" > .adjust_token && ./gradlew --no-daemon clean detekt ktlint lint', - dependencies=[buildTaskId]) - - -def generate_compare_locales_task(): - return taskcluster.slugId(), generate_task( - name="(Focus for Android) String validation", - description="Check Focus/Klar for Android for errors in en-US and l10n.", - command=('pip install "compare-locales>=5.0.2,<6.0"' - ' && mkdir -p /opt/focus-android/test_artifacts' - ' && compare-locales --validate l10n.toml .' - ' && compare-locales --json=/opt/focus-android/test_artifacts/data.json l10n.toml .'), - artifacts={ - "public": { - "type": "directory", - "path": "/opt/focus-android/test_artifacts", - "expires": taskcluster.stringDate(taskcluster.fromNow('1 week')) - } - }) - - -def generate_ui_test_task(dependencies): - task_name = "(Focus for Android) UI tests" - task_description = "Run UI tests for Focus for Android." - build_dir = "assembleFocusDebug" - build_dir_test = "assembleFocusDebugAndroidTest" - - return taskcluster.slugId(), generate_task( - name=task_name, - description=task_description, - command=('echo "--" > .adjust_token' - ' && ./gradlew --no-daemon clean ' + build_dir + ' ' + build_dir_test + ' ' - ' && ./tools/taskcluster/google-firebase-testlab-login.sh' - ' && ./tools/taskcluster/execute-firebase-tests.sh'), - dependencies=dependencies, - scopes=['secrets:get:project/focus/firebase'], - routes=['notify.irc-channel.#android-ci.on-any'], - artifacts={ - "public": { - "type": "directory", - "path": "/opt/focus-android/test_artifacts", - "expires": taskcluster.stringDate(taskcluster.fromNow('1 week')) - } - }) - - -def generate_task(name, description, command, dependencies=[], artifacts={}, scopes=[], routes=[]): - created = datetime.datetime.now() - expires = taskcluster.fromNow('1 month') - deadline = taskcluster.fromNow('1 day') - - return { - "workerType": "b-linux", - "taskGroupId": TASK_ID, - "expires": taskcluster.stringDate(expires), - "retries": 5, - "created": taskcluster.stringDate(created), - "tags": {}, - "priority": "lowest", - "schedulerId": "taskcluster-github", - "deadline": taskcluster.stringDate(deadline), - "dependencies": [TASK_ID] + dependencies, - "routes": routes, - "scopes": scopes, - "requires": "all-completed", - "payload": { - "features": { - "taskclusterProxy": True - }, - "maxRunTime": 7200, - "image": "mozillamobile/focus-android:1.7", - "command": [ - "/bin/bash", - "--login", - "-c", - "git fetch %s %s && git config advice.detachedHead false && git checkout %s && %s" % (REPO_URL, BRANCH, COMMIT, command) - ], - "artifacts": artifacts, - "deadline": taskcluster.stringDate(deadline) - }, - "provisionerId": "mobile-3", - "metadata": { - "name": name, - "description": description, - "owner": OWNER, - "source": SOURCE - } - } - - -if __name__ == "__main__": - - queue = taskcluster.Queue({'baseUrl': 'http://taskcluster/queue/v1'}) - - buildTaskId, buildTask = generate_build_task() - schedule_task(queue, buildTaskId, buildTask) - - unitTestTaskId, unitTestTask = generate_unit_test_task(buildTaskId) - schedule_task(queue, unitTestTaskId, unitTestTask) - - codeQualityTaskId, codeQualityTask = generate_code_quality_task(buildTaskId) - schedule_task(queue, codeQualityTaskId, codeQualityTask) - - clTaskId, clTask = generate_compare_locales_task() - schedule_task(queue, clTaskId, clTask) - - uiTestTaskId, uiTestTask = generate_ui_test_task([buildTaskId]) - schedule_task(queue, uiTestTaskId, uiTestTask) - - diff --git a/tools/taskcluster/schedule-nightly-graph.py b/tools/taskcluster/schedule-nightly-graph.py deleted file mode 100644 index 7daae2f5e77..00000000000 --- a/tools/taskcluster/schedule-nightly-graph.py +++ /dev/null @@ -1,84 +0,0 @@ -# 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 datetime -import jsone -import pipes -import yaml -import os -import slugid -import taskcluster - -from git import Repo -from lib.tasks import schedule_task - -ROOT = os.path.join(os.path.dirname(__file__), '../..') - - -def calculate_branch_and_head_rev(root): - repo = Repo(root) - branch = repo.head.reference - return str(branch), str(branch.commit) - - -def make_decision_task(params): - """Generate a basic decision task, based on the root .taskcluster.yml""" - with open(os.path.join(ROOT, '.taskcluster.yml'), 'rb') as f: - taskcluster_yml = yaml.safe_load(f) - - slugids = {} - - def as_slugid(name): - if name not in slugids: - slugids[name] = slugid.nice() - return slugids[name] - - # provide a similar JSON-e context to what taskcluster-github provides - context = { - 'tasks_for': 'cron', - 'cron': { - 'task_id': params['cron_task_id'], - }, - 'now': datetime.datetime.utcnow().isoformat()[:23] + 'Z', - 'as_slugid': as_slugid, - 'event': { - 'repository': { - 'clone_url': params['repository_url'], - }, - 'release': { - 'tag_name': params['head_rev'], - 'target_commitish': params['branch'], - }, - 'sender': { - 'login': 'TaskclusterHook' - }, - }, - } - - rendered = jsone.render(taskcluster_yml, context) - if len(rendered['tasks']) != 1: - raise Exception("Expected .taskcluster.yml to only produce one cron task") - task = rendered['tasks'][0] - - task_id = task.pop('taskId') - return (task_id, task) - - -if __name__ == "__main__": - queue = taskcluster.Queue({ 'baseUrl': 'http://taskcluster/queue/v1' }) - - branch, head_rev = calculate_branch_and_head_rev(ROOT) - - params = { - 'repository_url': 'https://github.com/mozilla-mobile/focus-android', - 'head_rev': head_rev, - 'branch': branch, - 'cron_task_id': os.environ.get('CRON_TASK_ID', '') - } - decisionTaskId, decisionTask = make_decision_task(params) - schedule_task(queue, decisionTaskId, decisionTask) - print('All scheduled!')