Skip to content

Commit dc3f410

Browse files
authored
Set test type to release only in CI. (#522)
* Set test type to release only in CI. This fixes Android Studio issue, where it is impossible to run integration tests in debug mode. Additionally move build type configuration to FirebaseLibraryPlugin to avoid projects.all configuration in gradle. * Add comment back.
1 parent 771d23c commit dc3f410

File tree

2 files changed

+22
-33
lines changed

2 files changed

+22
-33
lines changed

buildSrc/src/main/groovy/com/google/firebase/gradle/plugins/FirebaseLibraryPlugin.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer;
2121
import org.gradle.api.Plugin;
2222
import org.gradle.api.Project;
23-
import org.gradle.api.tasks.bundling.Jar;
2423
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;
2524

2625
public class FirebaseLibraryPlugin implements Plugin<Project> {
@@ -33,6 +32,28 @@ public void apply(Project project) {
3332

3433
LibraryExtension android = project.getExtensions().getByType(LibraryExtension.class);
3534

35+
// In the case of and android library signing config only affects instrumentation test APK.
36+
// We need it signed with default debug credentials in order for FTL to accept the APK.
37+
android.buildTypes(
38+
types ->
39+
types
40+
.getByName("release")
41+
.setSigningConfig(types.getByName("debug").getSigningConfig()));
42+
43+
// skip debug tests in CI
44+
// TODO(vkryachko): provide ability for teams to control this if needed
45+
if (System.getenv().containsKey("FIREBASE_CI")) {
46+
android.setTestBuildType("release");
47+
project
48+
.getTasks()
49+
.all(
50+
task -> {
51+
if ("testDebugUnitTest".equals(task.getName())) {
52+
task.setEnabled(false);
53+
}
54+
});
55+
}
56+
3657
android.testServer(new FirebaseTestServer(project, firebaseLibrary.testLab));
3758

3859
// reduce the likelihood of kotlin module files colliding.

root-project.gradle

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -140,38 +140,6 @@ configure(subprojects) {
140140
}
141141
}
142142

143-
/**
144-
* Disable "debug" build type for all subprojects.
145-
*
146-
* They are identical to "release" and are not used in either release or smoke tests. Disabling them
147-
* to reduce the number of tests we run on pre/post-submit.
148-
*/
149-
configure(subprojects) {
150-
afterEvaluate { Project sub ->
151-
if (!sub.plugins.hasPlugin('com.android.library') && !sub.plugins.hasPlugin('com.android.application')) {
152-
return
153-
}
154-
155-
// skip debug unit tests in CI
156-
// TODO(vkryachko): provide ability for teams to control this if needed
157-
if (System.getenv().containsKey("FIREBASE_CI")) {
158-
sub.tasks.all {Task task ->
159-
if (task.name == 'testDebugUnitTest') {
160-
task.enabled = false
161-
}
162-
}
163-
}
164-
sub.android {
165-
testBuildType "release"
166-
167-
buildTypes {
168-
// In the case of and android library signing config only affects instrumentation test APK.
169-
// We need it signed with default debug credentials in order for FTL to accept the APK.
170-
release.signingConfig = debug.signingConfig
171-
}
172-
}
173-
}
174-
}
175143

176144
/**
177145
* Configure "Preguarding" and Desugaring for the subprojects.

0 commit comments

Comments
 (0)