Skip to content

[Firebase Segmentation] Add custom installation id cache layer and tests for it. #524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Jun 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1962431
Add type arguments in StorageTaskManager (#517)
schmidt-sebastian Jun 13, 2019
b69b2c8
Output artifact list during local publishing. (#515)
allisonbm92 Jun 13, 2019
8881325
Implement Firebase segmentation SDK device local cache
diwu-arete Jun 13, 2019
771d23c
fix functions (#523)
VinayGuthal Jun 14, 2019
dc3f410
Set test type to release only in CI. (#522)
vkryachko Jun 14, 2019
864748f
[Firebase Segmentation] Add custom installation id cache layer and te…
diwu-arete Jun 14, 2019
0a3ebf6
Add test for updating cache
diwu-arete Jun 14, 2019
2d158ed
Switch to use SQLiteOpenHelper
diwu-arete Jun 15, 2019
18d4e7e
Minor fix to error message to match the admin sdk. (#525)
rsgowman Jun 17, 2019
d65c21c
Added clean task to smoke tests. (#527)
allisonbm92 Jun 17, 2019
3e2cc89
Update deps to post-androidx gms versions. (#526)
vkryachko Jun 17, 2019
f118d39
Switch to use SharedPreferences from SQLite.
diwu-arete Jun 17, 2019
4da5d31
Change the cache class to be singleton
diwu-arete Jun 18, 2019
c1f7644
Copy firebase-firestore-ktx dependencies on firestore into its own su…
Jun 18, 2019
d1ff0ec
Wrap shared pref commit in a async task.
diwu-arete Jun 18, 2019
2c5102c
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 18, 2019
41fbfee
Address comments
diwu-arete Jun 18, 2019
097ff36
Bump firestore version for release (#530)
vkryachko Jun 18, 2019
5fd2fa0
Google format fix
diwu-arete Jun 18, 2019
e950003
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
diwu-arete Jun 18, 2019
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
2 changes: 1 addition & 1 deletion buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ dependencies {
implementation 'org.jsoup:jsoup:1.11.2'
implementation 'digital.wup:android-maven-publish:3.6.2'
implementation 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20'
implementation 'org.json:json:20180813'

implementation 'io.opencensus:opencensus-api:0.18.0'
implementation 'io.opencensus:opencensus-exporter-stats-stackdriver:0.18.0'
runtime 'io.opencensus:opencensus-impl:0.18.0'

implementation 'com.android.tools.build:gradle:3.2.1'
testImplementation 'junit:junit:4.12'
testImplementation 'org.json:json:20180813'
testImplementation('org.spockframework:spock-core:1.1-groovy-2.4') {
exclude group: 'org.codehaus.groovy'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.google.firebase.gradle.plugins.ci.device.FirebaseTestServer;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.tasks.bundling.Jar;
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile;

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

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

// In the case of and android library signing config only affects instrumentation test APK.
// We need it signed with default debug credentials in order for FTL to accept the APK.
android.buildTypes(
types ->
types
.getByName("release")
.setSigningConfig(types.getByName("debug").getSigningConfig()));

// skip debug tests in CI
// TODO(vkryachko): provide ability for teams to control this if needed
if (System.getenv().containsKey("FIREBASE_CI")) {
android.setTestBuildType("release");
project
.getTasks()
.all(
task -> {
if ("testDebugUnitTest".equals(task.getName())) {
task.setEnabled(false);
}
});
}

android.testServer(new FirebaseTestServer(project, firebaseLibrary.testLab));

// reduce the likelihood of kotlin module files colliding.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class AffectedProjectFinder {
Set<String> changedPaths;

@Builder
AffectedProjectFinder(Project project, List<Pattern> ignorePaths) {
this(project, changedPaths(project.rootDir), ignorePaths)
}

AffectedProjectFinder(Project project,
Set<String> changedPaths,
List<Pattern> ignorePaths) {
Expand All @@ -49,6 +53,13 @@ class AffectedProjectFinder {
return project.subprojects
}

private static Set<String> changedPaths(File workDir) {
return 'git diff --name-only --submodule=diff HEAD@{0} HEAD@{1}'
.execute([], workDir)
.text
.readLines()
}

/**
* Performs a post-order project tree traversal and returns a set of projects that own the
* 'changedPaths'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class ContinuousIntegrationPlugin implements Plugin<Project> {

def affectedProjects = AffectedProjectFinder.builder()
.project(project)
.changedPaths(changedPaths(project.rootDir))
.ignorePaths(extension.ignorePaths)
.build()
.find()
Expand Down Expand Up @@ -143,13 +142,6 @@ class ContinuousIntegrationPlugin implements Plugin<Project> {
}
}

private static Set<String> changedPaths(File workDir) {
return 'git diff --name-only --submodule=diff HEAD@{0} HEAD@{1}'
.execute([], workDir)
.text
.readLines()
}

private static final ANDROID_PLUGINS = ["com.android.application", "com.android.library",
"com.android.test"]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.gradle.plugins.ci

import com.google.firebase.gradle.plugins.FirebaseLibraryExtension
import com.google.firebase.gradle.plugins.ci.AffectedProjectFinder
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.artifacts.ProjectDependency
import org.json.JSONArray
import org.json.JSONObject

/** Builds Firebase libraries for consumption by the smoke tests. */
class SmokeTestsPlugin implements Plugin<Project> {
@Override
public void apply(Project project) {
def assembleAllTask = project.task("assembleAllForSmokeTests")

// Wait until after the projects have been evaluated or else we might skip projects.
project.gradle.projectsEvaluated {
def changedProjects = getChangedProjects(project)
def changedArtifacts = new HashSet<String>()
def allArtifacts = new HashSet<String>()

// Visit each project and add the artifacts to the appropriate sets.
project.subprojects {
def firebaseLibrary = it.extensions.findByType(FirebaseLibraryExtension)
if (firebaseLibrary == null) {
return
}

def groupId = firebaseLibrary.groupId.get()
def artifactId = firebaseLibrary.artifactId.get()
def artifact = "$groupId:$artifactId:$it.version-SNAPSHOT"
allArtifacts.add(artifact)

if (changedProjects.contains(it)) {
changedArtifacts.add(artifact)
}
}

// Reuse the publish task for building the libraries.
def publishAllTask = project.tasks.getByPath("publishAllToBuildDir")
assembleAllTask.dependsOn(publishAllTask)

// Generate a JSON file listing the artifacts after everything is complete.
assembleAllTask.doLast {
def changed = new JSONArray()
changedArtifacts.each { changed.put(it) }

def all = new JSONArray()
allArtifacts.each { all.put(it) }

def json = new JSONObject()
json.put("all", all)
json.put("changed", changed)

def path = project.buildDir.toPath()
path.resolve("m2repository/changed-artifacts.json").write(json.toString())
}
}
}

private static Set<Project> getChangedProjects(Project p) {
Set<Project> roots = new AffectedProjectFinder(p, []).find()
HashSet<Project> changed = new HashSet<>()

getChangedProjectsLoop(roots, changed)
return changed
}

private static void getChangedProjectsLoop(Collection<Project> projects, Set<Project> changed) {
for (Project p : projects) {
// Skip project if it is not a Firebase library.
if (p.extensions.findByType(FirebaseLibraryExtension) == null) {
continue;
}

// Skip processing and recursion if this project has already been added to the set.
if (!changed.add(p)) {
continue;
}

// Find all (head) dependencies to other projects in this respository.
def all = p.configurations.releaseRuntimeClasspath.allDependencies
def affected =
all.findAll { it instanceof ProjectDependency }.collect { it.getDependencyProject() }

// Recurse with the new dependencies.
getChangedProjectsLoop(affected, changed)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class Publisher {
pom.dependencies.dependency.each {
// remove multidex as it is supposed to be added by final applications and is needed for
// some libraries only for instrumentation tests to build.
if (it.groupId.text() in ['com.android.support', 'androidx'] && it.artifactId.text() == 'multidex') {
if (it.groupId.text() in ['com.android.support', 'androidx.multidex'] && it.artifactId.text() == 'multidex') {
it.parent().remove(it)
}
it.appendNode('type', [:], deps["${it.groupId.text()}:${it.artifactId.text()}"])
Expand Down
6 changes: 3 additions & 3 deletions fiamui-app/fiamui-app.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ android {

dependencies {
implementation project(path: ":firebase-inappmessaging-display")
implementation "com.google.firebase:firebase-measurement-connector:17.0.1"
implementation "com.google.firebase:firebase-measurement-connector:18.0.0"
implementation('com.google.firebase:firebase-inappmessaging:17.0.3') {
exclude group: 'com.google.firebase', module: 'firebase-common'
}
implementation('com.google.firebase:firebase-analytics:16.0.4') {
implementation('com.google.firebase:firebase-analytics:17.0.0') {
exclude group: 'com.google.firebase', module: 'firebase-common'
}

Expand All @@ -67,7 +67,7 @@ dependencies {
implementation "com.google.code.findbugs:jsr305:3.0.2"
implementation "com.squareup.okhttp:okhttp:2.7.5"
implementation "com.google.auto.value:auto-value-annotations:1.6.5"
implementation "com.google.android.gms:play-services-basement:16.2.0"
implementation "com.google.android.gms:play-services-basement:17.0.0"

// The following dependencies are not required to use the FIAM UI library.
// They are used to make some aspects of the demo app implementation simpler for
Expand Down
4 changes: 2 additions & 2 deletions firebase-common/firebase-common.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ android {
}

dependencies {
implementation 'com.google.android.gms:play-services-basement:16.2.0'
implementation "com.google.android.gms:play-services-tasks:16.0.1"
implementation 'com.google.android.gms:play-services-basement:17.0.0'
implementation "com.google.android.gms:play-services-tasks:17.0.0"

api 'com.google.auto.value:auto-value-annotations:1.6.5'
compileOnly 'com.google.code.findbugs:jsr305:3.0.2'
Expand Down
4 changes: 2 additions & 2 deletions firebase-common/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.1.0
version=18.0.1
latestReleasedVersion=18.0.0
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ android {
}

dependencies {
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-base:17.0.0'

testImplementation 'junit:junit:4.12'
testImplementation 'net.java:quickcheck:0.6'
Expand Down
4 changes: 2 additions & 2 deletions firebase-database-collection/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=16.0.2
latestReleasedVersion=16.0.1
version=17.0.1
latestReleasedVersion=17.0.0
8 changes: 4 additions & 4 deletions firebase-database/firebase-database.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ dependencies {
implementation project(':firebase-common')
implementation project(':firebase-database-collection')

implementation 'com.google.android.gms:play-services-basement:16.2.0'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-tasks:16.0.1'
implementation('com.google.firebase:firebase-auth-interop:17.0.0') {
implementation 'com.google.android.gms:play-services-basement:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.google.android.gms:play-services-tasks:17.0.0'
implementation('com.google.firebase:firebase-auth-interop:18.0.0') {
exclude group: "com.google.firebase", module: "firebase-common"
}

Expand Down
4 changes: 2 additions & 2 deletions firebase-database/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

version=17.0.0
latestReleasedVersion=16.1.0
version=18.0.1
latestReleasedVersion=18.0.0
android.enableUnitTestBinaryResources=true
4 changes: 2 additions & 2 deletions firebase-datatransport/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=16.0.1
latestReleasedVersion=16.0.0
version=17.0.1
latestReleasedVersion=17.0.0
android.enableUnitTestBinaryResources=true
8 changes: 4 additions & 4 deletions firebase-firestore/firebase-firestore.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ dependencies {
implementation 'io.grpc:grpc-protobuf-lite:1.21.0'
implementation 'io.grpc:grpc-okhttp:1.21.0'
implementation 'io.grpc:grpc-android:1.21.0'
implementation 'com.google.android.gms:play-services-basement:16.2.0'
implementation 'com.google.android.gms:play-services-tasks:16.0.1'
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.android.gms:play-services-basement:17.0.0'
implementation 'com.google.android.gms:play-services-tasks:17.0.0'
implementation 'com.google.android.gms:play-services-base:17.0.0'
implementation 'com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava'

implementation 'com.squareup.okhttp:okhttp:2.7.5'
implementation('com.google.firebase:firebase-auth-interop:17.0.0') {
implementation('com.google.firebase:firebase-auth-interop:18.0.0') {
exclude group: "com.google.firebase", module: "firebase-common"
}

Expand Down
4 changes: 2 additions & 2 deletions firebase-firestore/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=19.0.2
latestReleasedVersion=19.0.1
version=20.1.0
latestReleasedVersion=20.0.0
12 changes: 7 additions & 5 deletions firebase-firestore/ktx/ktx.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ plugins {

firebaseLibrary {
releaseWith project(':firebase-firestore')
publishSources = true
}

android {
compileSdkVersion project.targetSdkVersion
compileSdkVersion 28
defaultConfig {
minSdkVersion project.minSdkVersion
multiDexEnabled true
Expand All @@ -33,21 +34,22 @@ android {
main.java.srcDirs += 'src/main/kotlin'
test.java {
srcDir 'src/test/kotlin'
srcDir '../src/testUtil/java'
srcDir '../src/roboUtil/java'
srcDir 'src/test/java'
}
}
testOptions.unitTests.includeAndroidResources = true
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"

implementation project(':firebase-common')
implementation project(':firebase-common:ktx')
implementation project(':firebase-firestore')
implementation 'androidx.annotation:annotation:1.1.0'

testImplementation project(':firebase-database-collection')
testImplementation 'org.mockito:mockito-core:2.25.0'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.google.firebase.firestore;

import com.google.firebase.firestore.model.DocumentKey;

public final class TestAccessHelper {

/** Makes the DocumentReference constructor accessible. */
public static DocumentReference createDocumentReference(DocumentKey documentKey) {
// We can use null here because the tests only use this as a wrapper for documentKeys.
return new DocumentReference(documentKey, null);
}

/** Makes the getKey() method accessible. */
public static DocumentKey referenceKey(DocumentReference documentReference) {
return documentReference.getKey();
}
}
Loading