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

Commit

Permalink
Moves release flavour to build type
Browse files Browse the repository at this point in the history
  • Loading branch information
Mitchell Hentges committed Apr 17, 2019
1 parent 8e59585 commit 637eb20
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 133 deletions.
82 changes: 28 additions & 54 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,34 +32,41 @@ android {
manifestPlaceholders.isRaptorEnabled = "false"
}

def releaseTemplate = {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
matchingFallbacks = ['release']
}

buildTypes {
release {
shrinkResources true
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
releaseRaptor {
initWith release
manifestPlaceholders.isRaptorEnabled = "true"
matchingFallbacks = ['release']
}
debug {
shrinkResources false
minifyEnabled false
applicationIdSuffix ".debug"
manifestPlaceholders.isRaptorEnabled = "true"
}
// "releaseRaptor" is only used for performance testing, and isn't a real "release" type
releaseRaptor releaseTemplate >> { // the ">>" concatenates the releaseRaptor-specific options with the template
manifestPlaceholders.isRaptorEnabled = "true"
}
nightly releaseTemplate
beta releaseTemplate
}

variantFilter { // There's a "release" build type that exists by default that we don't use
if (buildType.name == 'release') {
setIgnore true
}
}

testOptions {
execution 'ANDROIDX_TEST_ORCHESTRATOR'
}

flavorDimensions "abi", "channel"
flavorDimensions "abi"

productFlavors {
// Processor architectures (abi dimension)

arm {
dimension "abi"
ndk {
Expand All @@ -78,41 +85,6 @@ android {
abiFilter "arm64-v8a"
}
}

// Product channels (channel dimension)

// "Greenfield" is our clean version of Fenix without any of the "Fennec transition" code.
greenfield {
dimension "channel"
}
firefoxNightly {
dimension "channel"

// Aurora was a channel between nightly builds and beta versions. Aurora builds were published on Google
// Play. When the Aurora channel was shutdown in April 2017 the decision was made to instead ship Nightly
// builds to Google Play using the existing application id. Previously Nightly builds were not available
// on Google Play. Since then our Nightly package name is "fennec_aurora" instead of "fennec_nightly".
applicationId "org.mozilla.fennec_aurora"
}
firefoxBeta {
dimension "channel"

applicationId "org.mozilla.firefox_beta"
}
firefoxRelease {
dimension "channel"

applicationId "org.mozilla.firefox"
}
}

variantFilter { variant ->
def flavors = variant.flavors*.name.toString().toLowerCase()

if (!flavors.contains("greenfield")) {
// For now everything that isn't a "greenfield" build isn't used. So let's ignore those variants.
setIgnore(true)
}
}

compileOptions {
Expand Down Expand Up @@ -148,9 +120,10 @@ android.applicationVariants.all { variant ->
// -------------------------------------------------------------------------------------------------

def buildType = variant.buildType.name
def versionCode = null

if (buildType == "release") {
def versionCode = generatedVersionCode
if (buildType == "nightly") {
versionCode = generatedVersionCode

// The Google Play Store does not allow multiple APKs for the same app that all have the
// same version code. Therefore we need to have different version codes for our ARM and x86
Expand All @@ -166,15 +139,16 @@ android.applicationVariants.all { variant ->
versionCode = versionCode + 1
}// else variant.flavorName.contains("Arm")) use generated version code

variant.outputs.all { output ->
variant.outputs.all {
setVersionCodeOverride(versionCode)
}
}

println("----------------------------------------------")
println("Build type: " + buildType)
println("Variant name: " + variant.name)
println("Build type: " + variant.buildType.name)
println("Flavor: " + variant.flavorName)
println("Version code: " + variant.mergedFlavor.versionCode)
println("Version code: " + (versionCode ?: variant.mergedFlavor.versionCode))

// -------------------------------------------------------------------------------------------------
// BuildConfig: Set variables for Sentry, Crash Reporting, and Telemetry
Expand Down Expand Up @@ -357,7 +331,7 @@ dependencies {
}

androidTestImplementation Deps.espresso_idling_resources

androidTestImplementation Deps.tools_test_runner
androidTestImplementation Deps.tools_test_rules
androidTestUtil Deps.orchestrator
Expand Down
11 changes: 0 additions & 11 deletions app/src/firefoxBeta/AndroidManifest.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/firefoxNightly/AndroidManifest.xml

This file was deleted.

11 changes: 0 additions & 11 deletions app/src/firefoxRelease/AndroidManifest.xml

This file was deleted.

4 changes: 2 additions & 2 deletions automation/taskcluster/decision_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def pr_or_push(is_master_push):
build_tasks[assemble_task_id] = BUILDER.craft_assemble_task(variant)
build_tasks[taskcluster.slugId()] = BUILDER.craft_test_task(variant)

arch, build_type, _ = _get_architecture_and_build_type_and_product_from_variant(variant)
arch, build_type = _get_architecture_and_build_type_and_product_from_variant(variant)
# autophone only supports arm and aarch64, so only sign/perftest those builds
if (
build_type == 'releaseRaptor' and
Expand Down Expand Up @@ -88,7 +88,7 @@ def nightly(track):
push_tasks = {}

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

signing_task_id = taskcluster.slugId()
signing_tasks[signing_task_id] = BUILDER.craft_nightly_signing_task(
Expand Down
60 changes: 17 additions & 43 deletions automation/taskcluster/lib/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ def __init__(
self.date = arrow.get(date_string)
self.trust_level = trust_level

def craft_assemble_release_task(self, architectures, is_staging=False):
def craft_assemble_nightly_task(self, architectures, is_staging=False):
artifacts = {
'public/target.{}.apk'.format(arch): {
"type": 'file',
"path": '/opt/fenix/app/build/outputs/apk/'
'{}Greenfield/release/app-{}-greenfield-release-unsigned.apk'.format(arch, arch),
'{}/nightly/app-{}-nightly-unsigned.apk'.format(arch, arch),
"expires": taskcluster.stringDate(taskcluster.fromNow(DEFAULT_EXPIRES_IN)),
}
for arch in architectures
Expand All @@ -68,7 +68,7 @@ def craft_assemble_release_task(self, architectures, is_staging=False):
)

gradle_commands = (
'./gradlew --no-daemon -PcrashReports=true -Ptelemetry=true clean test assembleRelease',
'./gradlew --no-daemon -PcrashReports=true -Ptelemetry=true clean test assembleNightly',
)

command = ' && '.join(
Expand Down Expand Up @@ -168,8 +168,8 @@ def craft_ktlint_task(self):
def craft_lint_task(self):
return self._craft_clean_gradle_task(
name='lint',
description='Running lint for arm64 release variant',
gradle_task='lintAarch64GreenfieldRelease',
description='Running lint for aarch64 release variant',
gradle_task='lintAarch64Release',
treeherder={
'jobKind': 'test',
'machine': {
Expand Down Expand Up @@ -327,22 +327,20 @@ def _craft_default_task_definition(
def craft_master_commit_signing_task(
self, assemble_task_id, variant
):
architecture, build_type, product = _get_architecture_and_build_type_and_product_from_variant(variant)
product = convert_camel_case_into_kebab_case(product)
postfix = convert_camel_case_into_kebab_case('{}-{}'.format(architecture, build_type))
architecture, build_type = _get_architecture_and_build_type_and_product_from_variant(variant)
routes = [
'index.project.mobile.fenix.branch.master.revision.{}.{}.{}'.format(
self.commit, product, postfix
self.commit, build_type, architecture
),
'index.project.mobile.fenix.branch.master.latest.{}.{}'.format(
product, postfix
'index.project.mobile.fenix.branch.master.latest.{}.{}.{}'.format(
product, build_type, architecture
),
'index.project.mobile.fenix.branch.master.pushdate.{}.{}.{}.revision.{}.{}.{}'.format(
self.date.year, self.date.month, self.date.day, self.commit,
product, postfix
build_type, architecture
),
'index.project.mobile.fenix.branch.master.pushdate.{}.{}.{}.latest.{}.{}'.format(
self.date.year, self.date.month, self.date.day, product, postfix
self.date.year, self.date.month, self.date.day, build_type, architecture
),
]

Expand Down Expand Up @@ -435,15 +433,13 @@ def craft_push_task(


def _craft_treeherder_platform_from_variant(variant):
architecture, build_type, _ = _get_architecture_and_build_type_and_product_from_variant(
variant
)
architecture, build_type = _get_architecture_and_build_type_and_product_from_variant(variant)
return 'android-{}-{}'.format(architecture, build_type)


def _craft_treeherder_group_symbol_from_variant(variant):
_, __, product = _get_architecture_and_build_type_and_product_from_variant(variant)
return product
_, build_type = _get_architecture_and_build_type_and_product_from_variant(variant)
return build_type


def _craft_artifacts_from_variant(variant):
Expand All @@ -457,26 +453,17 @@ def _craft_artifacts_from_variant(variant):


def _craft_apk_full_path_from_variant(variant):
architecture, build_type, product = _get_architecture_and_build_type_and_product_from_variant(
variant
)

short_variant = variant[:-len(build_type)]
architecture, build_type = _get_architecture_and_build_type_and_product_from_variant(variant)
postfix = '-unsigned' if build_type.startswith('release') else ''
product = lower_case_first_letter(product)

return '/opt/fenix/app/build/outputs/apk/{short_variant}/{build_type}/app-{architecture}-{product}-{build_type}{postfix}.apk'.format( # noqa: E501
return '/opt/fenix/app/build/outputs/apk/{architecture}/{build_type}/app-{architecture}-{build_type}{postfix}.apk'.format( # noqa: E501
architecture=architecture,
build_type=build_type,
product=product,
short_variant=short_variant,
postfix=postfix
)


_SUPPORTED_ARCHITECTURES = ('aarch64', 'arm', 'x86')
_SUPPORTED_BUILD_TYPES = ('Debug', 'Release', 'ReleaseRaptor')
_SUPPORTED_PRODUCTS = ('FirefoxBeta', 'FirefoxNightly', 'FirefoxRelease', 'Greenfield')


def _get_architecture_and_build_type_and_product_from_variant(variant):
Expand Down Expand Up @@ -504,20 +491,7 @@ def _get_architecture_and_build_type_and_product_from_variant(variant):
)
)

remaining_variant_data = variant[len(architecture):len(variant) - len(build_type)]
for supported_product in _SUPPORTED_PRODUCTS:
if remaining_variant_data == supported_product:
product = supported_product
break
else:
raise ValueError(
'Cannot identify product in "{}" "{}". '
'Expected to find one of these supported ones: {}'.format(
remaining_variant_data, variant, _SUPPORTED_PRODUCTS
)
)

return architecture, build_type, product
return architecture, build_type


def schedule_task(queue, taskId, task):
Expand Down
2 changes: 1 addition & 1 deletion config/pre-push-recommended.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
./gradlew -q \
ktlint \
detekt \
app:assembleX86GreenfieldDebug
app:assembleX86Debug

0 comments on commit 637eb20

Please sign in to comment.