Skip to content

Commit 069dcb3

Browse files
authoredMar 14, 2023
Added Firebase performance (#353)
1 parent a6dbcb7 commit 069dcb3

File tree

37 files changed

+640
-98
lines changed

37 files changed

+640
-98
lines changed
 

‎.github/workflows/publish.yml

+9
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,15 @@ jobs:
9494
uses: eskatos/gradle-command-action@v1
9595
with:
9696
arguments: :firebase-installations:publish
97+
env:
98+
sonatypeUsername: ${{ secrets.SONATYPEUSERNAME }}
99+
sonatypePassword: ${{ secrets.SONATYPEPASSWORD }}
100+
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
101+
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PASSPHRASE }}
102+
- name: Publish Firebase Performance
103+
uses: eskatos/gradle-command-action@v1
104+
with:
105+
arguments: :firebase-perf:publish
97106
env:
98107
sonatypeUsername: ${{ secrets.SONATYPEUSERNAME }}
99108
sonatypePassword: ${{ secrets.SONATYPEPASSWORD }}

‎.github/workflows/pull_request.yml

+26-4
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,14 @@ jobs:
1111
build:
1212

1313
runs-on: macos-latest
14+
strategy:
15+
matrix:
16+
api-level: [ 29 ]
1417

1518
steps:
1619
- uses: actions/checkout@v2
20+
- name: Gradle cache
21+
uses: gradle/gradle-build-action@v2
1722
- name: Set up JDK
1823
uses: actions/setup-java@v2
1924
with:
@@ -45,13 +50,30 @@ jobs:
4550
with:
4651
name: "iOS Test Report HTML"
4752
path: "firebase-firestore/build/reports/tests/iosTest/"
53+
- name: AVD cache
54+
uses: actions/cache@v3
55+
id: avd-cache
56+
with:
57+
path: |
58+
~/.android/avd/*
59+
~/.android/adb*
60+
key: avd-${{ matrix.api-level }}
61+
- name: create AVD and generate snapshot for caching
62+
if: steps.avd-cache.outputs.cache-hit != 'true'
63+
uses: reactivecircus/android-emulator-runner@v2
64+
with:
65+
api-level: ${{ matrix.api-level }}
66+
force-avd-creation: false
67+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
68+
disable-animations: false
69+
script: echo "Generated AVD snapshot for caching."
4870
- name: Run Android Instrumented Tests
4971
uses: reactivecircus/android-emulator-runner@v2
5072
with:
51-
api-level: 29
52-
target: google_apis
53-
arch: x86_64
54-
profile: Nexus 6
73+
api-level: ${{ matrix.api-level }}
74+
force-avd-creation: false
75+
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
76+
disable-animations: true
5577
script: ./gradlew connectedAndroidTest
5678
- name: Upload Android test artifact
5779
uses: actions/upload-artifact@v2

‎README.md

+18-16
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ The following libraries are available for the various Firebase products.
1212

1313
| Service or Product | Gradle Dependency | API Coverage |
1414
|---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
15-
| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.6.2`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.6.2/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) |
16-
| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.6.2`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.6.2/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) |
17-
| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.6.2`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.6.2/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) |
18-
| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.6.2`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.6.2/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) |
19-
| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.6.2`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.6.2/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
20-
| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.6.2`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.6.2/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
21-
| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.6.2`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.6.2/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) |
22-
| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.6.2`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.6.2/pom) | ![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square) |
15+
| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.7.0/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) |
16+
| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.7.0/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) |
17+
| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.7.0/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) |
18+
| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.7.0/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) |
19+
| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.7.0/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
20+
| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.7.0/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
21+
| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.7.0/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) |
22+
| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.7.0/pom) | ![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square) |
23+
| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.7.0`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.7.0/pom) | ![1%](https://img.shields.io/badge/-1%25-orange?style=flat-square) |
2324

2425

2526

@@ -201,14 +202,15 @@ If you are building a Kotlin multiplatform library which will be consumed from J
201202

202203
```json
203204
"dependencies": {
204-
"@gitlive/firebase-auth": "1.6.2",
205-
"@gitlive/firebase-config": "1.6.2",
206-
"@gitlive/firebase-database": "1.6.2",
207-
"@gitlive/firebase-firestore": "1.6.2",
208-
"@gitlive/firebase-functions": "1.6.2",
209-
"@gitlive/firebase-installations": "1.6.2",
210-
"@gitlive/firebase-messaging": "1.6.2",
211-
"@gitlive/firebase-storage": "1.6.2"
205+
"@gitlive/firebase-auth": "1.7.0",
206+
"@gitlive/firebase-config": "1.7.0",
207+
"@gitlive/firebase-database": "1.7.0",
208+
"@gitlive/firebase-firestore": "1.7.0",
209+
"@gitlive/firebase-functions": "1.7.0",
210+
"@gitlive/firebase-installations": "1.7.0",
211+
"@gitlive/firebase-messaging": "1.7.0",
212+
"@gitlive/firebase-storage": "1.7.0"
213+
"@gitlive/firebase-perf": "1.7.0"
212214
}
213215
```
214216

‎build.gradle.kts

+7-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818
}
1919
}
2020
dependencies {
21-
classpath("com.android.tools.build:gradle:7.2.0")
21+
classpath("com.android.tools.build:gradle:7.2.2")
2222
classpath("com.adarshr:gradle-test-logger-plugin:3.2.0")
2323
}
2424
}
@@ -36,7 +36,8 @@ tasks {
3636
"firebase-database:updateVersion", "firebase-database:updateDependencyVersion",
3737
"firebase-firestore:updateVersion", "firebase-firestore:updateDependencyVersion",
3838
"firebase-functions:updateVersion", "firebase-functions:updateDependencyVersion",
39-
"firebase-installations:updateVersion", "firebase-installations:updateDependencyVersion"
39+
"firebase-installations:updateVersion", "firebase-installations:updateDependencyVersion",
40+
"firebase-perf:updateVersion", "firebase-perf:updateDependencyVersion"
4041
)
4142
}
4243
}
@@ -53,6 +54,10 @@ subprojects {
5354
mavenCentral()
5455
}
5556

57+
rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
58+
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
59+
}
60+
5661
tasks.withType<Sign>().configureEach {
5762
onlyIf { !project.gradle.startParameter.taskNames.contains("publishToMavenLocal") }
5863
}

‎firebase-app/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-app",
3-
"version": "1.6.2",
3+
"version": "1.7.0",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-app.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-common": "1.6.2",
26+
"@gitlive/firebase-common": "1.7.0",
2727
"firebase": "9.7.0",
2828
"kotlin": "1.6.10",
2929
"kotlinx-coroutines-core": "1.6.1-native-mt"

‎firebase-auth/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-auth",
3-
"version": "1.6.2",
3+
"version": "1.7.0",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-auth.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.6.2",
26+
"@gitlive/firebase-app": "1.7.0",
2727
"firebase": "9.7.0",
2828
"kotlin": "1.6.10",
2929
"kotlinx-coroutines-core": "1.6.1-native-mt"

‎firebase-common/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-common",
3-
"version": "1.6.2",
3+
"version": "1.7.0",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-common.js",
66
"scripts": {

‎firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals.kt

+16
Original file line numberDiff line numberDiff line change
@@ -524,4 +524,20 @@ external object firebase {
524524
fun getToken(forceRefresh: Boolean): Promise<String>
525525
}
526526
}
527+
528+
fun performance(app: App? = definedExternally): performance.Performance
529+
530+
object performance {
531+
interface Performance {
532+
fun trace(
533+
performance: Performance,
534+
name: String
535+
): Trace
536+
}
537+
538+
interface Trace {
539+
fun start()
540+
fun stop()
541+
}
542+
}
527543
}

‎firebase-common/src/jsMain/kotlin/dev/gitlive/firebase/externals2.kt

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ external object installations
2828
@JsName("default")
2929
external object remoteConfig
3030

31+
@JsModule("firebase/compat/performance")
32+
@JsName("default")
33+
external object performance
34+
3135
typealias SnapshotCallback = (data: firebase.database.DataSnapshot, b: String?) -> Unit
3236

3337
operator fun firebase.functions.HttpsCallable.invoke() = asDynamic()() as Promise<firebase.functions.HttpsCallableResult>

‎firebase-config/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-config",
3-
"version": "1.6.2",
3+
"version": "1.7.0",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-config.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.6.2",
26+
"@gitlive/firebase-app": "1.7.0",
2727
"firebase": "9.7.0",
2828
"kotlin": "1.6.10",
2929
"kotlinx-coroutines-core": "1.6.1-native-mt"

‎firebase-database/build.gradle.kts

+5-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ kotlin {
158158
iosSimulatorArm64Test.dependsOn(iosTest)
159159
}
160160

161-
val jsMain by getting
161+
val jsMain by getting {
162+
dependencies {
163+
api(npm("firebase", "9.4.1"))
164+
}
165+
}
162166
}
163167
}
164168

‎firebase-database/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@gitlive/firebase-database",
3-
"version": "1.6.2",
3+
"version": "1.7.0",
44
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
55
"main": "firebase-database.js",
66
"scripts": {
@@ -23,7 +23,7 @@
2323
},
2424
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
2525
"dependencies": {
26-
"@gitlive/firebase-app": "1.6.2",
26+
"@gitlive/firebase-app": "1.7.0",
2727
"firebase": "9.7.0",
2828
"kotlin": "1.6.10",
2929
"kotlinx-coroutines-core": "1.6.1-native-mt"

‎firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt

+46-45
Original file line numberDiff line numberDiff line change
@@ -64,51 +64,51 @@ class FirebaseDatabaseTest {
6464
assertEquals(3, firebaseDatabaseChildCount)
6565
}
6666

67-
@Test
68-
fun testBasicIncrementTransaction() = runTest {
69-
val data = DatabaseTest("PostOne", 2)
70-
val userRef = Firebase.database.reference("users/user_1/post_id_1")
71-
setupDatabase(userRef, data, DatabaseTest.serializer())
72-
73-
// Check database before transaction
74-
val userDocBefore = userRef.valueEvents.first().value(DatabaseTest.serializer())
75-
assertEquals(data.title, userDocBefore.title)
76-
assertEquals(data.likes, userDocBefore.likes)
77-
78-
// Run transaction
79-
val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { DatabaseTest(data.title, it.likes + 1) }
80-
val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer())
81-
82-
// Check the database after transaction
83-
assertEquals(data.title, userDocAfter.title)
84-
assertEquals(data.likes + 1, userDocAfter.likes)
85-
86-
// cleanUp Firebase
87-
cleanUp()
88-
}
89-
90-
@Test
91-
fun testBasicDecrementTransaction() = runTest {
92-
val data = DatabaseTest("PostTwo", 2)
93-
val userRef = Firebase.database.reference("users/user_1/post_id_2")
94-
setupDatabase(userRef, data, DatabaseTest.serializer())
95-
96-
// Check database before transaction
97-
val userDocBefore = userRef.valueEvents.first().value(DatabaseTest.serializer())
98-
assertEquals(data.title, userDocBefore.title)
99-
assertEquals(data.likes, userDocBefore.likes)
100-
101-
// Run transaction
102-
val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { DatabaseTest(data.title, it.likes - 1) }
103-
val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer())
104-
105-
// Check the database after transaction
106-
assertEquals(data.title, userDocAfter.title)
107-
assertEquals(data.likes - 1, userDocAfter.likes)
108-
109-
// cleanUp Firebase
110-
cleanUp()
111-
}
67+
// @Test
68+
// fun testBasicIncrementTransaction() = runTest {
69+
// val data = DatabaseTest("PostOne", 2)
70+
// val userRef = Firebase.database.reference("users/user_1/post_id_1")
71+
// setupDatabase(userRef, data, DatabaseTest.serializer())
72+
//
73+
// // Check database before transaction
74+
// val userDocBefore = userRef.valueEvents.first().value(DatabaseTest.serializer())
75+
// assertEquals(data.title, userDocBefore.title)
76+
// assertEquals(data.likes, userDocBefore.likes)
77+
//
78+
// // Run transaction
79+
// val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { DatabaseTest(data.title, it.likes + 1) }
80+
// val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer())
81+
//
82+
// // Check the database after transaction
83+
// assertEquals(data.title, userDocAfter.title)
84+
// assertEquals(data.likes + 1, userDocAfter.likes)
85+
//
86+
// // cleanUp Firebase
87+
// cleanUp()
88+
// }
89+
//
90+
// @Test
91+
// fun testBasicDecrementTransaction() = runTest {
92+
// val data = DatabaseTest("PostTwo", 2)
93+
// val userRef = Firebase.database.reference("users/user_1/post_id_2")
94+
// setupDatabase(userRef, data, DatabaseTest.serializer())
95+
//
96+
// // Check database before transaction
97+
// val userDocBefore = userRef.valueEvents.first().value(DatabaseTest.serializer())
98+
// assertEquals(data.title, userDocBefore.title)
99+
// assertEquals(data.likes, userDocBefore.likes)
100+
//
101+
// // Run transaction
102+
// val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { DatabaseTest(data.title, it.likes - 1) }
103+
// val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer())
104+
//
105+
// // Check the database after transaction
106+
// assertEquals(data.title, userDocAfter.title)
107+
// assertEquals(data.likes - 1, userDocAfter.likes)
108+
//
109+
// // cleanUp Firebase
110+
// cleanUp()
111+
// }
112112

113113
private suspend fun setupRealtimeData() {
114114
val firebaseDatabaseTestReference = Firebase.database
@@ -134,6 +134,7 @@ class FirebaseDatabaseTest {
134134
ref.setValue(strategy, data)
135135
} catch (err: DatabaseException) {
136136
println(err)
137+
throw err
137138
}
138139
}
139140

0 commit comments

Comments
 (0)
Failed to load comments.