Skip to content

Commit

Permalink
Make sure default variant is always used in CI end-2-end tests (#3045)
Browse files Browse the repository at this point in the history
Task/Issue URL:
https://app.asana.com/0/488551667048375/1204340991927492/f

### Description
This PR makes sure the default variant is always used when running end
to end tests on CI

### Steps to test this PR

- [x] Build the app normally and a variant should be allocated to your
- [x] Build the app using `-Pforce-default-variant`, for example
`./gradlew installInternalDebug -Pforce-default-variant` and make sure
you are always assigned the default variant.
- [x] All CI tests should also pass in this PR
- [x] All tests in
https://github.com/duckduckgo/Android/actions/runs/4637681307 should
pass and if they are not is not because the onboarding cannot be
finished
  • Loading branch information
marcosholgado authored Apr 7, 2023
1 parent 9388144 commit f35d21d
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ads-end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Assemble release APK
uses: gradle/gradle-build-action@v2
with:
arguments: assembleInternalRelease
arguments: assembleInternalRelease -Pforce-default-variant

- name: Move APK to new folder
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-debug-apk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- name: Build
uses: gradle/gradle-build-action@v2
with:
arguments: assembleInternalDebug
arguments: assembleInternalDebug -Pforce-default-variant

- name: Obtain debug apk
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Assemble release APK
uses: gradle/gradle-build-action@v2
with:
arguments: assemblePlayRelease
arguments: assemblePlayRelease -Pforce-default-variant

- name: Move APK to new folder
if: always()
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/privacy-dashboard-end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Assemble release APK
uses: gradle/gradle-build-action@v2
with:
arguments: assemblePlayRelease
arguments: assemblePlayRelease -Pforce-default-variant

- name: Move APK to new folder
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ interface AppBuildConfig {
val manufacturer: String
val model: String
val deviceLocale: Locale
val isDefaultVariantForced: Boolean
}

enum class BuildFlavor {
Expand Down
5 changes: 5 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ android {
} else {
buildConfigField "boolean", "IS_PERFORMANCE_TEST", "false"
}
if (project.hasProperty('force-default-variant')) {
buildConfigField "boolean", "FORCE_DEFAULT_VARIANT", "true"
} else {
buildConfigField "boolean", "FORCE_DEFAULT_VARIANT", "false"
}
}
buildFeatures {
viewBinding = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class RealAppBuildConfig @Inject constructor() : AppBuildConfig {
}
}
override val isPerformanceTest: Boolean = BuildConfig.IS_PERFORMANCE_TEST

override val isDefaultVariantForced: Boolean = BuildConfig.FORCE_DEFAULT_VARIANT
override val deviceLocale: Locale
get() = Locale.getDefault()
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ class ExperimentationVariantManager(
var newVariant = generateVariant(activeVariants)
val compliesWithFilters = newVariant.filterBy(appBuildConfig)

if (!compliesWithFilters) {
if (!compliesWithFilters || appBuildConfig.isDefaultVariantForced) {
newVariant = DEFAULT_VARIANT
}
Timber.i("Current variant is null; allocating new one $newVariant")
Expand Down

0 comments on commit f35d21d

Please sign in to comment.