Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Updates Fenix taskcluster tasks to support beta release #1893

Merged
merged 4 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
140 changes: 78 additions & 62 deletions .taskcluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,6 @@ tasks:
else: 1
in:
$let:
track:
$if: 'trust_level == 3'
then: 'nightly'
else: 'staging-nightly'

# TODO: revisit once bug 1533314 is done to possibly infer better priorities
tasks_priority: highest

Expand Down Expand Up @@ -128,78 +123,99 @@ tasks:
owner: ${user}@users.noreply.github.com
source: ${repository}/raw/${head_rev}/.taskcluster.yml
in:
$if: 'tasks_for in ["github-pull-request", "github-push"]'
then:
- $if: 'tasks_for == "github-pull-request" && event["action"] in ["opened", "reopened", "synchronize"]'
then:
$let:
pull_request_title: ${event.pull_request.title}
pull_request_number: ${event.pull_request.number}
pull_request_url: ${event.pull_request.html_url}
in:
$mergeDeep:
- {$eval: 'default_task_definition'}
- scopes:
- ${assume_scope_prefix}:pull-request
payload:
command:
- >-
git fetch ${repository} ${head_branch}
&& git config advice.detachedHead false
&& git checkout FETCH_HEAD
&& python automation/taskcluster/decision_task.py pull-request
env:
GITHUB_PULL_TITLE: ${pull_request_title}
extra:
treeherder:
symbol: D-PR
metadata:
name: 'Fenix - Decision task (Pull Request #${pull_request_number})'
description: 'Building and testing the Fenix - triggered by [#${pull_request_number}](${pull_request_url})'
- $if: 'tasks_for == "github-push" && head_branch[:10] != "refs/tags/"'
then:
- $if: 'tasks_for == "github-pull-request" && event["action"] in ["opened", "reopened", "synchronize"]'
then:
$let:
pull_request_title: ${event.pull_request.title}
pull_request_number: ${event.pull_request.number}
pull_request_url: ${event.pull_request.html_url}
in:
$mergeDeep:
- {$eval: 'default_task_definition'}
- scopes:
- ${assume_scope_prefix}:branch:${short_head_branch}
- ${assume_scope_prefix}:pull-request
payload:
command:
- >-
git fetch ${repository} ${head_branch}
&& git config advice.detachedHead false
&& git checkout FETCH_HEAD
&& python automation/taskcluster/decision_task.py push
&& python automation/taskcluster/decision_task.py pull-request
env:
GITHUB_PULL_TITLE: ${pull_request_title}
extra:
treeherder:
symbol: D
symbol: D-PR
metadata:
name: Fenix - Decision task
description: Schedules the build and test tasks for Fenix.
else:
- $if: 'tasks_for == "cron"'
then:
$mergeDeep:
- {$eval: 'default_task_definition'}
- scopes:
- $if: 'trust_level == 3'
then: assume:hook-id:project-mobile/fenix-nightly
else: assume:hook-id:project-mobile/fenix-nightly-staging
routes:
name: 'Fenix - Decision task (Pull Request #${pull_request_number})'
description: 'Building and testing the Fenix - triggered by [#${pull_request_number}](${pull_request_url})'
- $if: 'tasks_for == "github-push" && head_branch[:10] != "refs/tags/"'
then:
$mergeDeep:
- {$eval: 'default_task_definition'}
- scopes:
- ${assume_scope_prefix}:branch:${short_head_branch}
payload:
command:
- >-
git fetch ${repository} ${head_branch}
&& git config advice.detachedHead false
&& git checkout FETCH_HEAD
&& python automation/taskcluster/decision_task.py push
extra:
treeherder:
symbol: D
metadata:
name: Fenix - Decision task
description: Schedules the build and test tasks for Fenix.
- $if: 'tasks_for == "github-release"'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that right now, any github release is assumed to be beta.
As we get closer to the Fenix Preview release, I'll add a parse check to see if the tag has -beta.* on it

then:
$mergeDeep:
- {$eval: 'default_task_definition'}
- scopes:
- ${assume_scope_prefix}:release
payload:
command:
- >-
git fetch ${repository} refs/tags/${head_rev}
&& git config advice.detachedHead false
&& git checkout FETCH_HEAD
&& python automation/taskcluster/decision_task.py beta ${event.release.tag_name}
extra:
treeherder:
symbol: beta-D
metadata:
name: Fenix Beta Decision Task
description: Building and releasing Fenix to the beta channel - triggered by release ${event.release.tag_name}
- $if: 'tasks_for == "cron"'
then:
$mergeDeep:
- {$eval: 'default_task_definition'}
- scopes:
- $if: 'trust_level == 3'
then: assume:hook-id:project-mobile/fenix-nightly
else: assume:hook-id:project-mobile/fenix-nightly-staging
routes:
$if: 'trust_level == 3'
then:
- notify.email.fenix-eng-notifications@mozilla.com.on-failed
payload:
payload:
$let:
staging_flag:
$if: 'trust_level == 3'
then: ''
else: '--staging'
in:
command:
- >-
git fetch ${repository} ${head_branch}
&& git config advice.detachedHead false
&& git checkout FETCH_HEAD
&& python automation/taskcluster/decision_task.py \
release \
--nightly \
--track ${track}
extra:
cron: {$json: {$eval: 'cron'}}
treeherder:
symbol: N
metadata:
name: Fenix Nightly Decision Task
description: Decision task scheduled by cron task [${cron.task_id}](https://tools.taskcluster.net/tasks/${cron.task_id})
&& python automation/taskcluster/decision_task.py nightly ${staging_flag}
extra:
cron: {$json: {$eval: 'cron'}}
treeherder:
symbol: nightly-D
metadata:
name: Fenix Nightly Decision Task
description: Decision task scheduled by cron task [${cron.task_id}](https://tools.taskcluster.net/tasks/${cron.task_id})
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ git push <remote> --no-verify

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/
file, You can obtain one at http://mozilla.org/MPL/2.0/
34 changes: 28 additions & 6 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ apply plugin: 'androidx.navigation.safeargs.kotlin'

apply plugin: 'org.mozilla.appservices'

import com.android.build.gradle.internal.tasks.AppPreBuildTask

appservices {
defaultConfig {
megazord = 'fenix'
Expand All @@ -25,8 +27,8 @@ android {
applicationId "org.mozilla.fenix"
minSdkVersion Config.minSdkVersion
targetSdkVersion Config.targetSdkVersion
versionCode Config.versionCode
versionName Config.versionName + Config.generateVersionSuffix()
versionCode 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: do we still want to keep versionCode 1. My understanding was that very first APK has already been uploaded to Google Play.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that the first APK has already been uploaded to Google Play.
Config.versionCode used to just be 1, so I'm just inlining that value to the one place it's used (here) so it's more obvious at-a-glance.

Note that this is overridden separately here for release builds :)

versionName Config.generateDebugVersionName()
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
testInstrumentationRunnerArguments clearPackageData: 'true'
manifestPlaceholders.isRaptorEnabled = "false"
Expand Down Expand Up @@ -57,6 +59,7 @@ android {
resValue "bool", "IS_NOT_RELEASED", "false"
}
beta releaseTemplate >> {
applicationIdSuffix ".beta"
mitchhentges marked this conversation as resolved.
Show resolved Hide resolved
buildConfigField "boolean", "IS_RELEASED", "true"
resValue "bool", "IS_NOT_RELEASED", "false"
}
Expand Down Expand Up @@ -129,10 +132,11 @@ android.applicationVariants.all { variant ->

def buildType = variant.buildType.name
def versionCode = null
def isReleased = variant.buildType.buildConfigFields['IS_RELEASED']?.value ?: false

buildConfigField 'Boolean', 'COLLECTIONS_ENABLED', (buildType != "release").toString()

if (buildType == "nightly") {
if (isReleased) {
versionCode = generatedVersionCode

// The Google Play Store does not allow multiple APKs for the same app that all have the
Expand All @@ -150,7 +154,25 @@ android.applicationVariants.all { variant ->
}// else variant.flavorName.contains("Arm")) use generated version code

variant.outputs.all {
setVersionCodeOverride(versionCode)
versionCodeOverride = versionCode
versionNameOverride = Config.releaseVersionName(project)
}

// If this is a release build, validate that "versionName" is set
tasks.withType(AppPreBuildTask) { prebuildTask ->
// You can't add a closure to a variant, so we need to look for an early variant-specific type
// of task (AppPreBuildTask is the first) and filter to make sure we're looking at the task for
// this variant that we're currently configuring
if (prebuildTask.variantName != variant.name) {
return
}

// Append to the task so the first thing it does is run our validation
prebuildTask.doFirst {
if (!project.hasProperty('versionName')) {
throw new RuntimeException("Release builds require the 'versionName' property, e.g.: './gradlew -PversionName=<...> assembleNightly'")
mitchhentges marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
}

Expand Down Expand Up @@ -197,7 +219,7 @@ android.applicationVariants.all { variant ->

print("Adjust token: ")

if (variant.buildType.buildConfigFields['IS_RELEASED']?.value) {
if (isReleased) {
try {
def token = new File("${rootDir}/.adjust_token").text.trim()
buildConfigField 'String', 'ADJUST_TOKEN', '"' + token + '"'
Expand Down Expand Up @@ -390,4 +412,4 @@ task printGeckoviewVersions {

// Normally this should use the same version as the glean dependency. But since we are currently using AC snapshots we
// can't reference a git tag with a specific version here. So we are just using "master" and hoping for the best.
apply from: 'https://github.com/mozilla-mobile/android-components/raw/master/components/service/glean/scripts/sdk_generator.gradle'
apply from: 'https://github.com/mozilla-mobile/android-components/raw/master/components/service/glean/scripts/sdk_generator.gradle'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: EOL

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that should be addressed? I think that *nix prefers there to be an EOL at EOF, but Windows doesn't care. See this point.

Mildly-relevant side-note: some of my tools automatically add a line to EOF, and I don't want to hunt them down and disable 'em :P
Are you ok with leaving this in?

33 changes: 21 additions & 12 deletions automation/taskcluster/decision_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
from __future__ import print_function

import argparse
import datetime
import os
import re

import taskcluster

from lib.gradle import get_build_variants, get_geckoview_versions
Expand Down Expand Up @@ -94,8 +97,7 @@ def pr_or_push(is_push):
return (build_tasks, signing_tasks, other_tasks)


def nightly(track):
is_staging = track == 'staging-nightly'
def release(track, is_staging, version_name):
architectures = ['x86', 'arm', 'aarch64']
apk_paths = ["public/target.{}.apk".format(arch) for arch in architectures]

Expand All @@ -104,19 +106,21 @@ def nightly(track):
push_tasks = {}

build_task_id = taskcluster.slugId()
build_tasks[build_task_id] = BUILDER.craft_assemble_nightly_task(architectures, is_staging)
build_tasks[build_task_id] = BUILDER.craft_assemble_release_task(architectures, track, is_staging, version_name)

signing_task_id = taskcluster.slugId()
signing_tasks[signing_task_id] = BUILDER.craft_nightly_signing_task(
signing_tasks[signing_task_id] = BUILDER.craft_release_signing_task(
build_task_id,
apk_paths=apk_paths,
track=track,
is_staging=is_staging,
)

push_task_id = taskcluster.slugId()
push_tasks[push_task_id] = BUILDER.craft_push_task(
signing_task_id,
apks=apk_paths,
track=track,
is_staging=is_staging,
)

Expand All @@ -132,24 +136,29 @@ def nightly(track):

subparsers.add_parser('pull-request')
subparsers.add_parser('push')
release_parser = subparsers.add_parser('release')

release_parser.add_argument('--nightly', action="store_true", default=False)
release_parser.add_argument(
'--track', action="store", choices=['nightly', 'staging-nightly'], required=True
)
nightly_parser = subparsers.add_parser('nightly')
nightly_parser.add_argument('--staging', action='store_true')

result = parser.parse_args()
release_parser = subparsers.add_parser('beta')
release_parser.add_argument('tag')
mitchhentges marked this conversation as resolved.
Show resolved Hide resolved

result = parser.parse_args()
command = result.command
taskcluster_queue = taskcluster.Queue({'baseUrl': 'http://taskcluster/queue/v1'})

if command == 'pull-request':
ordered_groups_of_tasks = pr_or_push(False)
elif command == 'push':
ordered_groups_of_tasks = pr_or_push(True)
elif command == 'release':
ordered_groups_of_tasks = nightly(result.track)
elif command == 'nightly':
formatted_date = datetime.datetime.now().strftime('%y%V')
ordered_groups_of_tasks = release('nightly', result.staging, '1.0.{}'.format(formatted_date))
elif command == 'beta':
semver = re.compile(r'^\d+\.\d+\.\d+-beta\.\d+$')
if not semver.match(result.tag):
raise ValueError('Github tag must be in beta semver format, e.g.: "1.0.0-beta.0')
ordered_groups_of_tasks = release('beta', False, result.tag)
else:
raise Exception('Unsupported command "{}"'.format(command))

Expand Down
Loading