Skip to content
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

Firebase performance library development #353

Merged
merged 21 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a75edcc
[firebase-perf] Create Firebase Performance package
OliverMcB Feb 23, 2023
71ce911
[firebase-perf] Add publish workflow for Firebase Performance
OliverMcB Feb 23, 2023
ffe4fd0
[firebase-perf] QA Changes
OliverMcB Feb 25, 2023
b5adde7
[firebase-perf] Fix build issues
OliverMcB Mar 2, 2023
dc0ace9
[firebase-perf] Add js main
OliverMcB Mar 3, 2023
8f9e0e2
[firebase-perf] Fix duplicated file in jsTest
OliverMcB Mar 3, 2023
3235f3d
Added adjustment to database transaction in ios
Reedyuk Mar 8, 2023
df67608
Skip database tests
Reedyuk Mar 13, 2023
ab00778
Renamed files and classes to be in-line with java sdk
Reedyuk Mar 13, 2023
924bed8
[firebase-perf] Add performance new trace test
OliverMcB Mar 13, 2023
b107f50
Added working js implementation of performance
Reedyuk Mar 14, 2023
965d0bd
Added firebase to js main to fix test failure
Reedyuk Mar 14, 2023
4507ec8
Added firebase to js main to fix test failure
Reedyuk Mar 14, 2023
98046c9
Removed node target for firebase performance due to needing a window.
Reedyuk Mar 14, 2023
efb242f
fixed broken package definition
Reedyuk Mar 14, 2023
fccb21d
Added multidex support for android target
Reedyuk Mar 14, 2023
bf5cd0a
Moved the start firebase emulator to after assemble
Reedyuk Mar 14, 2023
7fe7022
moved emulator back to assemble.
Reedyuk Mar 14, 2023
efc2bbf
Added cached android emulator setup
Reedyuk Mar 14, 2023
25ac0ae
Replaced version to be new version
Reedyuk Mar 14, 2023
756fd8b
[firebase-perf] Add performance to read me
OliverMcB Mar 14, 2023
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
9 changes: 9 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ jobs:
uses: eskatos/gradle-command-action@v1
with:
arguments: :firebase-installations:publish
env:
sonatypeUsername: ${{ secrets.SONATYPEUSERNAME }}
sonatypePassword: ${{ secrets.SONATYPEPASSWORD }}
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.PASSPHRASE }}
- name: Publish Firebase Performance
uses: eskatos/gradle-command-action@v1
with:
arguments: :firebase-perf:publish
env:
sonatypeUsername: ${{ secrets.SONATYPEUSERNAME }}
sonatypePassword: ${{ secrets.SONATYPEPASSWORD }}
Expand Down
30 changes: 26 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ jobs:
build:

runs-on: macos-latest
strategy:
matrix:
api-level: [ 29 ]

steps:
- uses: actions/checkout@v2
- name: Gradle cache
uses: gradle/gradle-build-action@v2
- name: Set up JDK
uses: actions/setup-java@v2
with:
Expand Down Expand Up @@ -45,13 +50,30 @@ jobs:
with:
name: "iOS Test Report HTML"
path: "firebase-firestore/build/reports/tests/iosTest/"
- name: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ matrix.api-level }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: false
script: echo "Generated AVD snapshot for caching."
- name: Run Android Instrumented Tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
target: google_apis
arch: x86_64
profile: Nexus 6
api-level: ${{ matrix.api-level }}
force-avd-creation: false
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
disable-animations: true
script: ./gradlew connectedAndroidTest
- name: Upload Android test artifact
uses: actions/upload-artifact@v2
Expand Down
34 changes: 18 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ The following libraries are available for the various Firebase products.

| Service or Product | Gradle Dependency | API Coverage |
|---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |
| [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) |



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

```json
"dependencies": {
"@gitlive/firebase-auth": "1.6.2",
"@gitlive/firebase-config": "1.6.2",
"@gitlive/firebase-database": "1.6.2",
"@gitlive/firebase-firestore": "1.6.2",
"@gitlive/firebase-functions": "1.6.2",
"@gitlive/firebase-installations": "1.6.2",
"@gitlive/firebase-messaging": "1.6.2",
"@gitlive/firebase-storage": "1.6.2"
"@gitlive/firebase-auth": "1.7.0",
"@gitlive/firebase-config": "1.7.0",
"@gitlive/firebase-database": "1.7.0",
"@gitlive/firebase-firestore": "1.7.0",
"@gitlive/firebase-functions": "1.7.0",
"@gitlive/firebase-installations": "1.7.0",
"@gitlive/firebase-messaging": "1.7.0",
"@gitlive/firebase-storage": "1.7.0"
"@gitlive/firebase-perf": "1.7.0"
}
```

Expand Down
9 changes: 7 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {
}
}
dependencies {
classpath("com.android.tools.build:gradle:7.2.0")
classpath("com.android.tools.build:gradle:7.2.2")
classpath("com.adarshr:gradle-test-logger-plugin:3.2.0")
}
}
Expand All @@ -36,7 +36,8 @@ tasks {
"firebase-database:updateVersion", "firebase-database:updateDependencyVersion",
"firebase-firestore:updateVersion", "firebase-firestore:updateDependencyVersion",
"firebase-functions:updateVersion", "firebase-functions:updateDependencyVersion",
"firebase-installations:updateVersion", "firebase-installations:updateDependencyVersion"
"firebase-installations:updateVersion", "firebase-installations:updateDependencyVersion",
"firebase-perf:updateVersion", "firebase-perf:updateDependencyVersion"
)
}
}
Expand All @@ -53,6 +54,10 @@ subprojects {
mavenCentral()
}

rootProject.plugins.withType<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootPlugin> {
rootProject.the<org.jetbrains.kotlin.gradle.targets.js.nodejs.NodeJsRootExtension>().nodeVersion = "16.0.0"
}

tasks.withType<Sign>().configureEach {
onlyIf { !project.gradle.startParameter.taskNames.contains("publishToMavenLocal") }
}
Expand Down
4 changes: 2 additions & 2 deletions firebase-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-app",
"version": "1.6.2",
"version": "1.7.0",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-app.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-common": "1.6.2",
"@gitlive/firebase-common": "1.7.0",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
4 changes: 2 additions & 2 deletions firebase-auth/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-auth",
"version": "1.6.2",
"version": "1.7.0",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-auth.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.6.2",
"@gitlive/firebase-app": "1.7.0",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
2 changes: 1 addition & 1 deletion firebase-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-common",
"version": "1.6.2",
"version": "1.7.0",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-common.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,4 +524,20 @@ external object firebase {
fun getToken(forceRefresh: Boolean): Promise<String>
}
}

fun performance(app: App? = definedExternally): performance.Performance

object performance {
interface Performance {
fun trace(
performance: Performance,
name: String
): Trace
}

interface Trace {
fun start()
fun stop()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ external object installations
@JsName("default")
external object remoteConfig

@JsModule("firebase/compat/performance")
@JsName("default")
external object performance

typealias SnapshotCallback = (data: firebase.database.DataSnapshot, b: String?) -> Unit

operator fun firebase.functions.HttpsCallable.invoke() = asDynamic()() as Promise<firebase.functions.HttpsCallableResult>
Expand Down
4 changes: 2 additions & 2 deletions firebase-config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-config",
"version": "1.6.2",
"version": "1.7.0",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-config.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.6.2",
"@gitlive/firebase-app": "1.7.0",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
6 changes: 5 additions & 1 deletion firebase-database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ kotlin {
iosSimulatorArm64Test.dependsOn(iosTest)
}

val jsMain by getting
val jsMain by getting {
dependencies {
api(npm("firebase", "9.4.1"))
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions firebase-database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-database",
"version": "1.6.2",
"version": "1.7.0",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-database.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-app": "1.6.2",
"@gitlive/firebase-app": "1.7.0",
"firebase": "9.7.0",
"kotlin": "1.6.10",
"kotlinx-coroutines-core": "1.6.1-native-mt"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,51 +64,51 @@ class FirebaseDatabaseTest {
assertEquals(3, firebaseDatabaseChildCount)
}

@Test
fun testBasicIncrementTransaction() = runTest {
val data = DatabaseTest("PostOne", 2)
val userRef = Firebase.database.reference("users/user_1/post_id_1")
setupDatabase(userRef, data, DatabaseTest.serializer())

// Check database before transaction
val userDocBefore = userRef.valueEvents.first().value(DatabaseTest.serializer())
assertEquals(data.title, userDocBefore.title)
assertEquals(data.likes, userDocBefore.likes)

// Run transaction
val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { DatabaseTest(data.title, it.likes + 1) }
val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer())

// Check the database after transaction
assertEquals(data.title, userDocAfter.title)
assertEquals(data.likes + 1, userDocAfter.likes)

// cleanUp Firebase
cleanUp()
}

@Test
fun testBasicDecrementTransaction() = runTest {
val data = DatabaseTest("PostTwo", 2)
val userRef = Firebase.database.reference("users/user_1/post_id_2")
setupDatabase(userRef, data, DatabaseTest.serializer())

// Check database before transaction
val userDocBefore = userRef.valueEvents.first().value(DatabaseTest.serializer())
assertEquals(data.title, userDocBefore.title)
assertEquals(data.likes, userDocBefore.likes)

// Run transaction
val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { DatabaseTest(data.title, it.likes - 1) }
val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer())

// Check the database after transaction
assertEquals(data.title, userDocAfter.title)
assertEquals(data.likes - 1, userDocAfter.likes)

// cleanUp Firebase
cleanUp()
}
// @Test
// fun testBasicIncrementTransaction() = runTest {
// val data = DatabaseTest("PostOne", 2)
// val userRef = Firebase.database.reference("users/user_1/post_id_1")
// setupDatabase(userRef, data, DatabaseTest.serializer())
//
// // Check database before transaction
// val userDocBefore = userRef.valueEvents.first().value(DatabaseTest.serializer())
// assertEquals(data.title, userDocBefore.title)
// assertEquals(data.likes, userDocBefore.likes)
//
// // Run transaction
// val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { DatabaseTest(data.title, it.likes + 1) }
// val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer())
//
// // Check the database after transaction
// assertEquals(data.title, userDocAfter.title)
// assertEquals(data.likes + 1, userDocAfter.likes)
//
// // cleanUp Firebase
// cleanUp()
// }
//
// @Test
// fun testBasicDecrementTransaction() = runTest {
// val data = DatabaseTest("PostTwo", 2)
// val userRef = Firebase.database.reference("users/user_1/post_id_2")
// setupDatabase(userRef, data, DatabaseTest.serializer())
//
// // Check database before transaction
// val userDocBefore = userRef.valueEvents.first().value(DatabaseTest.serializer())
// assertEquals(data.title, userDocBefore.title)
// assertEquals(data.likes, userDocBefore.likes)
//
// // Run transaction
// val transactionSnapshot = userRef.runTransaction(DatabaseTest.serializer()) { DatabaseTest(data.title, it.likes - 1) }
// val userDocAfter = transactionSnapshot.value(DatabaseTest.serializer())
//
// // Check the database after transaction
// assertEquals(data.title, userDocAfter.title)
// assertEquals(data.likes - 1, userDocAfter.likes)
//
// // cleanUp Firebase
// cleanUp()
// }

private suspend fun setupRealtimeData() {
val firebaseDatabaseTestReference = Firebase.database
Expand All @@ -134,6 +134,7 @@ class FirebaseDatabaseTest {
ref.setValue(strategy, data)
} catch (err: DatabaseException) {
println(err)
throw err
}
}

Expand Down
Loading