2019-03-27 11:06:59 +00:00
|
|
|
# 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/.
|
|
|
|
|
|
|
|
"""
|
|
|
|
Decision task for nightly releases.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
import argparse
|
2019-05-06 17:09:29 +00:00
|
|
|
import datetime
|
2019-03-27 11:06:59 +00:00
|
|
|
import os
|
2019-05-06 17:09:29 +00:00
|
|
|
import re
|
|
|
|
|
2019-03-27 11:06:59 +00:00
|
|
|
import taskcluster
|
|
|
|
|
2019-08-21 15:32:01 +00:00
|
|
|
from lib.gradle import get_variant
|
2019-04-23 12:21:21 +00:00
|
|
|
from lib.tasks import (
|
|
|
|
fetch_mozharness_task_id,
|
|
|
|
schedule_task_graph,
|
|
|
|
TaskBuilder,
|
|
|
|
)
|
2019-03-28 17:05:51 +00:00
|
|
|
from lib.chain_of_trust import (
|
2019-03-27 11:06:59 +00:00
|
|
|
populate_chain_of_trust_task_graph,
|
|
|
|
populate_chain_of_trust_required_but_unused_files
|
|
|
|
)
|
|
|
|
|
|
|
|
REPO_URL = os.environ.get('MOBILE_HEAD_REPOSITORY')
|
|
|
|
COMMIT = os.environ.get('MOBILE_HEAD_REV')
|
|
|
|
PR_TITLE = os.environ.get('GITHUB_PULL_TITLE', '')
|
2019-04-23 12:21:21 +00:00
|
|
|
SHORT_HEAD_BRANCH = os.environ.get('SHORT_HEAD_BRANCH')
|
2019-03-27 11:06:59 +00:00
|
|
|
|
|
|
|
# If we see this text inside a pull request title then we will not execute any tasks for this PR.
|
|
|
|
SKIP_TASKS_TRIGGER = '[ci skip]'
|
|
|
|
|
|
|
|
|
|
|
|
BUILDER = TaskBuilder(
|
|
|
|
task_id=os.environ.get('TASK_ID'),
|
2019-03-28 10:44:23 +00:00
|
|
|
repo_url=REPO_URL,
|
2019-04-02 13:27:29 +00:00
|
|
|
git_ref=os.environ.get('MOBILE_HEAD_BRANCH'),
|
2019-04-23 12:21:21 +00:00
|
|
|
short_head_branch=SHORT_HEAD_BRANCH,
|
2019-03-27 11:06:59 +00:00
|
|
|
commit=COMMIT,
|
|
|
|
owner="fenix-eng-notifications@mozilla.com",
|
|
|
|
source='{}/raw/{}/.taskcluster.yml'.format(REPO_URL, COMMIT),
|
|
|
|
scheduler_id=os.environ.get('SCHEDULER_ID', 'taskcluster-github'),
|
|
|
|
tasks_priority=os.environ.get('TASKS_PRIORITY'),
|
2019-03-28 10:44:23 +00:00
|
|
|
date_string=os.environ.get('BUILD_DATE'),
|
2019-07-05 20:28:21 +00:00
|
|
|
trust_level=int(os.environ.get('TRUST_LEVEL')),
|
2019-03-27 11:06:59 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
2019-07-26 15:08:01 +00:00
|
|
|
def pr():
|
|
|
|
if SKIP_TASKS_TRIGGER in PR_TITLE:
|
2019-03-27 14:23:03 +00:00
|
|
|
print("Pull request title contains", SKIP_TASKS_TRIGGER)
|
|
|
|
print("Exit")
|
2019-03-28 17:03:38 +00:00
|
|
|
return {}
|
2019-03-27 14:23:03 +00:00
|
|
|
|
|
|
|
build_tasks = {}
|
2019-04-05 14:21:51 +00:00
|
|
|
signing_tasks = {}
|
2019-03-27 14:23:03 +00:00
|
|
|
other_tasks = {}
|
|
|
|
|
2019-08-21 15:32:01 +00:00
|
|
|
variant = get_variant('debug', 'geckoNightly')
|
|
|
|
assemble_task_id = taskcluster.slugId()
|
|
|
|
build_tasks[assemble_task_id] = BUILDER.craft_assemble_pr_task(variant)
|
|
|
|
build_tasks[taskcluster.slugId()] = BUILDER.craft_test_pr_task(variant)
|
2019-03-27 14:23:03 +00:00
|
|
|
|
|
|
|
for craft_function in (
|
|
|
|
BUILDER.craft_detekt_task,
|
|
|
|
BUILDER.craft_ktlint_task,
|
|
|
|
BUILDER.craft_lint_task,
|
|
|
|
BUILDER.craft_compare_locales_task,
|
|
|
|
):
|
|
|
|
other_tasks[taskcluster.slugId()] = craft_function()
|
|
|
|
|
2019-07-26 15:08:01 +00:00
|
|
|
return (build_tasks, signing_tasks, other_tasks)
|
|
|
|
|
|
|
|
|
|
|
|
def push():
|
|
|
|
all_tasks = pr()
|
|
|
|
other_tasks = all_tasks[-1]
|
2019-08-21 15:32:01 +00:00
|
|
|
other_tasks[taskcluster.slugId()] = BUILDER.craft_ui_tests_task()
|
2019-07-26 15:08:01 +00:00
|
|
|
|
|
|
|
if SHORT_HEAD_BRANCH == 'master':
|
2019-05-27 15:31:06 +00:00
|
|
|
other_tasks[taskcluster.slugId()] = BUILDER.craft_dependencies_task()
|
|
|
|
|
2019-08-21 15:32:01 +00:00
|
|
|
return all_tasks
|
2019-05-27 15:31:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
def raptor(is_staging):
|
|
|
|
build_tasks = {}
|
|
|
|
signing_tasks = {}
|
|
|
|
other_tasks = {}
|
|
|
|
|
2019-07-19 14:28:40 +00:00
|
|
|
mozharness_task_id = fetch_mozharness_task_id()
|
2019-05-27 15:31:06 +00:00
|
|
|
gecko_revision = taskcluster.Queue().task(mozharness_task_id)['payload']['env']['GECKO_HEAD_REV']
|
|
|
|
|
2019-08-21 15:32:01 +00:00
|
|
|
variant = get_variant('forPerformanceTest', 'geckoNightly')
|
|
|
|
assemble_task_id = taskcluster.slugId()
|
|
|
|
build_tasks[assemble_task_id] = BUILDER.craft_assemble_raptor_task(variant)
|
|
|
|
signing_task_id = taskcluster.slugId()
|
|
|
|
signing_tasks[signing_task_id] = BUILDER.craft_raptor_signing_task(assemble_task_id, variant, is_staging)
|
2019-05-27 15:31:06 +00:00
|
|
|
|
2019-08-21 15:32:01 +00:00
|
|
|
for abi in ('aarch64', 'arm'):
|
2019-05-27 15:31:06 +00:00
|
|
|
all_raptor_craft_functions = [
|
|
|
|
BUILDER.craft_raptor_tp6m_cold_task(for_suite=i)
|
2019-08-21 15:32:01 +00:00
|
|
|
for i in range(1, 28)
|
|
|
|
] + [
|
|
|
|
BUILDER.craft_raptor_youtube_playback_task,
|
|
|
|
]
|
2019-05-27 15:31:06 +00:00
|
|
|
for craft_function in all_raptor_craft_functions:
|
2019-08-21 15:32:01 +00:00
|
|
|
args = (signing_task_id, mozharness_task_id, abi, gecko_revision)
|
2019-05-27 15:31:06 +00:00
|
|
|
other_tasks[taskcluster.slugId()] = craft_function(*args)
|
|
|
|
|
2019-04-05 14:21:51 +00:00
|
|
|
return (build_tasks, signing_tasks, other_tasks)
|
2019-03-27 14:23:03 +00:00
|
|
|
|
|
|
|
|
2019-08-21 15:32:01 +00:00
|
|
|
def release(channel, engine, is_staging, version_name):
|
|
|
|
variant = get_variant('fenix' + channel.capitalize(), engine)
|
|
|
|
taskcluster_apk_paths = variant.upstream_artifacts()
|
2019-03-27 11:06:59 +00:00
|
|
|
|
|
|
|
build_tasks = {}
|
|
|
|
signing_tasks = {}
|
|
|
|
push_tasks = {}
|
|
|
|
|
|
|
|
build_task_id = taskcluster.slugId()
|
2019-08-21 15:32:01 +00:00
|
|
|
build_tasks[build_task_id] = BUILDER.craft_assemble_release_task(variant, is_staging, version_name)
|
2019-03-27 11:06:59 +00:00
|
|
|
|
|
|
|
signing_task_id = taskcluster.slugId()
|
2019-05-06 17:09:29 +00:00
|
|
|
signing_tasks[signing_task_id] = BUILDER.craft_release_signing_task(
|
2019-03-27 11:06:59 +00:00
|
|
|
build_task_id,
|
2019-08-21 15:32:01 +00:00
|
|
|
taskcluster_apk_paths,
|
2019-06-06 13:30:41 +00:00
|
|
|
channel=channel,
|
2019-03-27 11:06:59 +00:00
|
|
|
is_staging=is_staging,
|
|
|
|
)
|
|
|
|
|
|
|
|
push_task_id = taskcluster.slugId()
|
|
|
|
push_tasks[push_task_id] = BUILDER.craft_push_task(
|
|
|
|
signing_task_id,
|
2019-08-21 15:32:01 +00:00
|
|
|
taskcluster_apk_paths,
|
2019-06-06 13:30:41 +00:00
|
|
|
channel=channel,
|
2019-07-02 18:34:04 +00:00
|
|
|
# TODO until org.mozilla.fenix.nightly is made public, put it on the internally-testable track
|
|
|
|
override_google_play_track=None if channel != "nightly" else "internal",
|
|
|
|
is_staging=is_staging,
|
|
|
|
)
|
|
|
|
|
|
|
|
return (build_tasks, signing_tasks, push_tasks)
|
|
|
|
|
|
|
|
|
|
|
|
def nightly_to_production_app(is_staging, version_name):
|
|
|
|
# Since the Fenix nightly was launched, we've pushed it to the production app "org.mozilla.fenix" on the
|
|
|
|
# "nightly" track. We're moving towards having each channel be published to its own app, but we need to
|
|
|
|
# keep updating this "backwards-compatible" nightly for a while yet
|
2019-08-21 15:32:01 +00:00
|
|
|
variant = get_variant('fenixNightlyLegacy', 'geckoNightly')
|
|
|
|
taskcluster_apk_paths = variant.upstream_artifacts()
|
2019-07-02 18:34:04 +00:00
|
|
|
|
|
|
|
build_tasks = {}
|
|
|
|
signing_tasks = {}
|
|
|
|
push_tasks = {}
|
2019-08-02 18:57:46 +00:00
|
|
|
other_tasks = {}
|
2019-07-02 18:34:04 +00:00
|
|
|
|
|
|
|
build_task_id = taskcluster.slugId()
|
2019-08-21 15:32:01 +00:00
|
|
|
build_tasks[build_task_id] = BUILDER.craft_assemble_release_task(variant, is_staging, version_name)
|
2019-07-02 18:34:04 +00:00
|
|
|
|
|
|
|
signing_task_id = taskcluster.slugId()
|
|
|
|
signing_tasks[signing_task_id] = BUILDER.craft_release_signing_task(
|
|
|
|
build_task_id,
|
2019-08-21 15:32:01 +00:00
|
|
|
taskcluster_apk_paths,
|
2019-07-02 18:34:04 +00:00
|
|
|
channel='production', # Since we're publishing to the "production" app, we need to sign for production
|
|
|
|
index_channel='nightly',
|
|
|
|
is_staging=is_staging,
|
|
|
|
)
|
|
|
|
|
|
|
|
push_task_id = taskcluster.slugId()
|
|
|
|
push_tasks[push_task_id] = BUILDER.craft_push_task(
|
|
|
|
signing_task_id,
|
2019-08-21 15:32:01 +00:00
|
|
|
taskcluster_apk_paths,
|
2019-07-02 18:34:04 +00:00
|
|
|
channel='production', # We're publishing to the "production" app on the "nightly" track
|
|
|
|
override_google_play_track='nightly',
|
2019-04-05 14:21:51 +00:00
|
|
|
is_staging=is_staging,
|
2019-03-27 11:06:59 +00:00
|
|
|
)
|
|
|
|
|
2019-08-21 15:32:01 +00:00
|
|
|
if not is_staging:
|
|
|
|
nimbledroid_task_id = taskcluster.slugId()
|
|
|
|
other_tasks[nimbledroid_task_id] = BUILDER.craft_upload_apk_nimbledroid_task(
|
|
|
|
build_task_id
|
|
|
|
)
|
2019-08-02 18:57:46 +00:00
|
|
|
|
|
|
|
return (build_tasks, signing_tasks, push_tasks, other_tasks)
|
2019-03-27 11:06:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
description='Creates and submit a graph of tasks on Taskcluster.'
|
|
|
|
)
|
|
|
|
|
|
|
|
subparsers = parser.add_subparsers(dest='command')
|
|
|
|
|
2019-04-05 14:21:51 +00:00
|
|
|
subparsers.add_parser('pull-request')
|
|
|
|
subparsers.add_parser('push')
|
2019-03-27 11:06:59 +00:00
|
|
|
|
2019-05-27 15:31:06 +00:00
|
|
|
raptor_parser = subparsers.add_parser('raptor')
|
|
|
|
raptor_parser.add_argument('--staging', action='store_true')
|
|
|
|
|
2019-05-06 17:09:29 +00:00
|
|
|
nightly_parser = subparsers.add_parser('nightly')
|
|
|
|
nightly_parser.add_argument('--staging', action='store_true')
|
2019-03-27 11:06:59 +00:00
|
|
|
|
2019-06-10 15:55:21 +00:00
|
|
|
release_parser = subparsers.add_parser('github-release')
|
2019-05-06 17:09:29 +00:00
|
|
|
release_parser.add_argument('tag')
|
2019-07-10 17:32:33 +00:00
|
|
|
release_parser.add_argument('--staging', action='store_true')
|
2019-03-27 11:06:59 +00:00
|
|
|
|
2019-05-06 17:09:29 +00:00
|
|
|
result = parser.parse_args()
|
2019-03-27 11:06:59 +00:00
|
|
|
command = result.command
|
|
|
|
|
2019-08-21 15:32:01 +00:00
|
|
|
if command == 'pull-request':
|
2019-07-26 15:08:01 +00:00
|
|
|
ordered_groups_of_tasks = pr()
|
2019-08-21 15:32:01 +00:00
|
|
|
elif command == 'push':
|
2019-07-26 15:08:01 +00:00
|
|
|
ordered_groups_of_tasks = push()
|
2019-05-27 15:31:06 +00:00
|
|
|
elif command == 'raptor':
|
|
|
|
ordered_groups_of_tasks = raptor(result.staging)
|
2019-05-06 17:09:29 +00:00
|
|
|
elif command == 'nightly':
|
2019-06-28 23:55:34 +00:00
|
|
|
nightly_version = datetime.datetime.now().strftime('Nightly %y%m%d %H:%M')
|
2019-08-21 15:32:01 +00:00
|
|
|
ordered_groups_of_tasks = release('nightly', 'geckoNightly', result.staging, nightly_version) \
|
2019-07-02 18:34:04 +00:00
|
|
|
+ nightly_to_production_app(result.staging, nightly_version)
|
2019-06-10 15:55:21 +00:00
|
|
|
elif command == 'github-release':
|
2019-06-05 12:09:57 +00:00
|
|
|
version = result.tag[1:] # remove prefixed "v"
|
2019-06-10 15:55:21 +00:00
|
|
|
beta_semver = re.compile(r'^v\d+\.\d+\.\d+-beta\.\d+$')
|
|
|
|
production_semver = re.compile(r'^v\d+\.\d+\.\d+(-rc\.\d+)?$')
|
|
|
|
if beta_semver.match(result.tag):
|
2019-08-21 15:32:01 +00:00
|
|
|
ordered_groups_of_tasks = release('beta', 'geckoBeta', result.staging, version)
|
2019-06-10 15:55:21 +00:00
|
|
|
elif production_semver.match(result.tag):
|
2019-08-21 15:32:01 +00:00
|
|
|
ordered_groups_of_tasks = release('production', 'geckoBeta', result.staging, version)
|
2019-06-10 15:55:21 +00:00
|
|
|
else:
|
|
|
|
raise ValueError('Github tag must be in semver format and prefixed with a "v", '
|
|
|
|
'e.g.: "v1.0.0-beta.0" (beta), "v1.0.0-rc.0" (production) or "v1.0.0" (production)')
|
2019-03-27 11:06:59 +00:00
|
|
|
else:
|
|
|
|
raise Exception('Unsupported command "{}"'.format(command))
|
|
|
|
|
|
|
|
full_task_graph = schedule_task_graph(ordered_groups_of_tasks)
|
|
|
|
|
|
|
|
populate_chain_of_trust_task_graph(full_task_graph)
|
|
|
|
populate_chain_of_trust_required_but_unused_files()
|