From 76e1f43efb074bfc62fc37152aaa204f196b3542 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Mon, 15 May 2023 17:09:55 +0200 Subject: [PATCH 01/29] Move to Kotlin 1.8.21 & gradle 8 --- .../ISSUE_TEMPLATE/increase-api-coverage.md | 6 +- .github/workflows/publish.yml | 2 +- .github/workflows/pull_request.yml | 12 ++-- .gitignore | 11 +--- build.gradle.kts | 51 +++++++++------- firebase-app/build.gradle.kts | 47 ++++++++------ firebase-app/firebase_app.podspec | 39 ++++++++++++ .../kotlin/dev/gitlive/firebase/firebase.kt | 0 .../src/androidMain/AndroidManifest.xml | 1 - .../kotlin/dev/gitlive/firebase/firebase.kt | 2 - firebase-auth/build.gradle.kts | 54 ++++++++-------- firebase-auth/firebase_auth.podspec | 39 ++++++++++++ .../AndroidManifest.xml | 3 +- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 0 .../src/androidMain/AndroidManifest.xml | 1 - .../dev/gitlive/firebase/auth/credentials.kt | 24 ++++++-- firebase-common/build.gradle.kts | 61 ++++++++++++------- .../dev/gitlive/firebase/EncodersTest.kt | 0 .../src/androidMain/AndroidManifest.xml | 1 - .../kotlin/dev/gitlive/firebase/decoders.kt | 6 +- .../kotlin/dev/gitlive/firebase/encoders.kt | 6 +- firebase-config/build.gradle.kts | 53 +++++++++------- firebase-config/firebase_config.podspec | 39 ++++++++++++ .../firebase/remoteconfig/RemoteConfig.kt | 0 .../src/androidMain/AndroidManifest.xml | 1 - .../remoteconfig/FirebaseRemoteConfig.kt | 5 +- firebase-crashlytics/build.gradle.kts | 50 ++++++++------- .../firebase_crashlytics.podspec | 39 ++++++++++++ .../AndroidManifest.xml | 3 +- .../firebase/crashlytics/crashlytics.kt | 0 .../res/values/strings.xml | 0 .../src/androidMain/AndroidManifest.xml | 1 - .../firebase/crashlytics/crashlytics.kt | 1 + firebase-database/build.gradle.kts | 49 +++++++++------ firebase-database/firebase_database.podspec | 39 ++++++++++++ .../dev/gitlive/firebase/database/database.kt | 0 .../src/androidMain/AndroidManifest.xml | 1 - .../gitlive/firebase/database/ServerValue.kt | 1 + firebase-firestore/build.gradle.kts | 60 +++++++++++------- firebase-firestore/firebase_firestore.podspec | 39 ++++++++++++ .../AndroidManifest.xml | 3 +- .../gitlive/firebase/firestore/firestore.kt | 0 .../src/androidMain/AndroidManifest.xml | 1 - firebase-functions/build.gradle.kts | 53 +++++++++++----- firebase-functions/firebase_functions.podspec | 39 ++++++++++++ .../src/androidMain/AndroidManifest.xml | 1 - .../gitlive/firebase/functions/functions.kt | 1 + firebase-installations/build.gradle.kts | 47 ++++++++------ .../firebase_installations.podspec | 39 ++++++++++++ .../src/androidMain/AndroidManifest.xml | 1 - firebase-perf/build.gradle.kts | 54 ++++++++-------- firebase-perf/firebase_perf.podspec | 39 ++++++++++++ .../AndroidManifest.xml | 3 +- .../gitlive/firebase/perf/metrics/Trace.kt | 0 .../dev/gitlive/firebase/perf/performance.kt | 0 .../src/androidMain/AndroidManifest.xml | 1 - gradle.properties | 10 +++ gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle.kts | 9 ++- 59 files changed, 775 insertions(+), 275 deletions(-) rename firebase-app/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/firebase.kt (100%) delete mode 100644 firebase-app/src/androidMain/AndroidManifest.xml rename firebase-auth/src/{androidAndroidTest => androidInstrumentedTest}/AndroidManifest.xml (74%) rename firebase-auth/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/auth/auth.kt (100%) delete mode 100644 firebase-auth/src/androidMain/AndroidManifest.xml rename firebase-common/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/EncodersTest.kt (100%) delete mode 100644 firebase-common/src/androidMain/AndroidManifest.xml rename firebase-config/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt (100%) delete mode 100644 firebase-config/src/androidMain/AndroidManifest.xml rename {firebase-firestore/src/androidAndroidTest => firebase-crashlytics/src/androidInstrumentedTest}/AndroidManifest.xml (74%) rename firebase-crashlytics/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt (100%) rename firebase-crashlytics/src/{androidAndroidTest => androidInstrumentedTest}/res/values/strings.xml (100%) delete mode 100644 firebase-crashlytics/src/androidMain/AndroidManifest.xml rename firebase-database/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/database/database.kt (100%) delete mode 100644 firebase-database/src/androidMain/AndroidManifest.xml rename {firebase-perf/src/androidAndroidTest => firebase-firestore/src/androidInstrumentedTest}/AndroidManifest.xml (74%) rename firebase-firestore/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/firestore/firestore.kt (100%) delete mode 100644 firebase-firestore/src/androidMain/AndroidManifest.xml delete mode 100644 firebase-functions/src/androidMain/AndroidManifest.xml delete mode 100644 firebase-installations/src/androidMain/AndroidManifest.xml rename {firebase-crashlytics/src/androidAndroidTest => firebase-perf/src/androidInstrumentedTest}/AndroidManifest.xml (71%) rename firebase-perf/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt (100%) rename firebase-perf/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/perf/performance.kt (100%) delete mode 100644 firebase-perf/src/androidMain/AndroidManifest.xml diff --git a/.github/ISSUE_TEMPLATE/increase-api-coverage.md b/.github/ISSUE_TEMPLATE/increase-api-coverage.md index dff3b2be9..c58ca8478 100644 --- a/.github/ISSUE_TEMPLATE/increase-api-coverage.md +++ b/.github/ISSUE_TEMPLATE/increase-api-coverage.md @@ -7,6 +7,6 @@ assignees: '' --- -| Library | Class | Member | Platforms | -| :-----------------| :------------------------ | :----------------------------------- | :---------------------- | -| e.g auth | e.g FirebaseAuth | e.g signInWithGithub | e.g Android, iOS | +| Library | Class | Member | Platforms | +|:---------|:-----------------|:---------------------|:-----------------| +| e.g auth | e.g FirebaseAuth | e.g signInWithGithub | e.g Android, iOS | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f39b05640..647de28b0 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -22,7 +22,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '11' + java-version: '17' - uses: gradle/gradle-build-action@v2 - name: Setup versions run: ./gradlew :updateVersions diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 34b6cdd24..343fb3fea 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,7 +12,7 @@ jobs: runs-on: macos-latest strategy: matrix: - api-level: [ 29 ] + api-level: [ 33 ] steps: - uses: actions/checkout@v3 - name: Cocoapods cache @@ -29,7 +29,7 @@ jobs: uses: actions/setup-java@v3 with: distribution: 'zulu' - java-version: '11' + java-version: '17' cache: gradle - name: Gradle cache uses: gradle/gradle-build-action@v2 @@ -42,16 +42,16 @@ jobs: - name: Assemble run: ./gradlew assemble - name: Run JS Tests - run: ./gradlew cleanTest jsLegacyTest + run: ./gradlew cleanTest jsTest - name: Upload JS test artifact uses: actions/upload-artifact@v3 if: failure() with: name: "JS Test Report HTML" path: | - **/build/reports/tests/jsLegacyTest/ - **/build/reports/tests/jsLegacyBrowserTest/ - **/build/reports/tests/jsLegacyNodeTest/ + **/build/reports/tests/jsTest/ + **/build/reports/tests/jsBrowserTest/ + **/build/reports/tests/jsNodeTest/ - name: Run iOS Tests run: ./gradlew cleanTest iosX64Test - name: Upload iOS test artifact diff --git a/.gitignore b/.gitignore index 292e59669..891e657d4 100644 --- a/.gitignore +++ b/.gitignore @@ -5,17 +5,10 @@ local.properties /**/*.iml *.iml -firebase-app/src/nativeInterop/cinterop/modules/ -firebase-functions/src/nativeInterop/cinterop/modules/ -firebase-auth/src/nativeInterop/cinterop/modules/ -firebase-firestore/src/nativeInterop/cinterop/modules/ -firebase-database/src/nativeInterop/cinterop/modules/ Firebase*.zip /Firebase -/.DS_Store +.DS_Store *.log - -/**/nativeInterop/cinterop/Cartfile.resolved -/**/nativeInterop/cinterop/Carthage/ +/kotlin-js-store/ /kotlin-js-store/yarn.lock diff --git a/build.gradle.kts b/build.gradle.kts index cbcc2716d..04529c4b9 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,8 +8,8 @@ repositories { } plugins { - kotlin("multiplatform") version "1.8.20" apply false - kotlin("native.cocoapods") version "1.8.20" apply false + kotlin("multiplatform") apply false + kotlin("native.cocoapods") apply false id("base") id("com.github.ben-manes.versions") version "0.42.0" } @@ -24,17 +24,17 @@ buildscript { } } dependencies { - classpath("com.android.tools.build:gradle:7.2.2") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20-RC") + classpath("com.android.tools.build:gradle:${project.extra["gradlePluginVersion"]}") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${project.extra["kotlinVersion"]}") classpath("com.adarshr:gradle-test-logger-plugin:3.2.0") } } -val targetSdkVersion by extra(32) +val compileSdkVersion by extra(33) val minSdkVersion by extra(19) tasks { - val updateVersions by registering { + register("updateVersions") { dependsOn( "firebase-app:updateVersion", "firebase-app:updateDependencyVersion", "firebase-auth:updateVersion", "firebase-auth:updateDependencyVersion", @@ -62,16 +62,16 @@ subprojects { } tasks.withType().configureEach { - onlyIf { !project.gradle.startParameter.taskNames.contains("publishToMavenLocal") } + onlyIf { project.gradle.startParameter.taskNames.contains("MavenRepository") } } tasks { - val updateVersion by registering(Exec::class) { + register("updateVersion") { commandLine("npm", "--allow-same-version", "--prefix", projectDir, "version", "${project.property("${project.name}.version")}") } - val updateDependencyVersion by registering(Copy::class) { + register("updateDependencyVersion") { mustRunAfter("updateVersion") val from = file("package.json") from.writeText( @@ -117,7 +117,7 @@ subprojects { into(file("$buildDir/node_module")) } - val prepareForNpmPublish by registering { + register("prepareForNpmPublish") { dependsOn( unzipJar, copyPackageJson, @@ -127,7 +127,7 @@ subprojects { ) } - val publishToNpm by creating(Exec::class) { + create("publishToNpm") { workingDir("$buildDir/node_module") isIgnoreExitValue = true if(Os.isFamily(Os.FAMILY_WINDOWS)) { @@ -162,22 +162,25 @@ subprojects { mkdir("$buildDir/node_module") } + val coroutinesVersion: String by project + val firebaseBoMVersion: String by project + dependencies { - "commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") - "androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.4") - "androidMainImplementation"(platform("com.google.firebase:firebase-bom:31.4.0")) + "commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") + "androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") + "androidMainImplementation"(platform("com.google.firebase:firebase-bom:$firebaseBoMVersion")) "commonTestImplementation"(kotlin("test-common")) "commonTestImplementation"(kotlin("test-annotations-common")) - "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4") - "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4") + "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") + "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") if (this@afterEvaluate.name != "firebase-crashlytics") { "jsTestImplementation"(kotlin("test-js")) } - "androidAndroidTestImplementation"(kotlin("test-junit")) - "androidAndroidTestImplementation"("junit:junit:4.13.2") - "androidAndroidTestImplementation"("androidx.test:core:1.4.0") - "androidAndroidTestImplementation"("androidx.test.ext:junit:1.1.3") - "androidAndroidTestImplementation"("androidx.test:runner:1.4.0") + "androidInstrumentedTestImplementation"(kotlin("test-junit")) + "androidInstrumentedTestImplementation"("junit:junit:4.13.2") + "androidInstrumentedTestImplementation"("androidx.test:core:1.5.0") + "androidInstrumentedTestImplementation"("androidx.test.ext:junit:1.1.5") + "androidInstrumentedTestImplementation"("androidx.test:runner:1.5.2") } } @@ -236,6 +239,12 @@ subprojects { } } } + + // Workaround for setting kotlinOptions.jvmTarget + // See https://youtrack.jetbrains.com/issue/KT-55947/Unable-to-set-kapt-jvm-target-version + tasks.withType().configureEach { + kotlinOptions.jvmTarget = "11" + } } tasks.withType { diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index e9dac4b24..9f6414826 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -16,23 +16,28 @@ repositories { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace="dev.gitlive.firebase" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -62,12 +67,12 @@ kotlin { } noPodspec() pod("FirebaseCore") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() nodejs { testTask { @@ -88,21 +93,31 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true } } - val commonMain by getting { + getByName("commonMain") { dependencies { implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { + dependencies { + api("com.google.firebase:firebase-common-ktx") + } + } + + getByName("androidInstrumentedTest") { dependencies { - api("com.google.firebase:firebase-common") + dependsOn(commonTest) } } @@ -114,8 +129,6 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/firebase-app/firebase_app.podspec b/firebase-app/firebase_app.podspec index e69de29bb..d2af87047 100644 --- a/firebase-app/firebase_app.podspec +++ b/firebase-app/firebase_app.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_app' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_app.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-app', + 'PRODUCT_MODULE_NAME' => 'firebase_app', + } + + spec.script_phases = [ + { + :name => 'Build firebase_app', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/firebase-app/src/androidAndroidTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt similarity index 100% rename from firebase-app/src/androidAndroidTest/kotlin/dev/gitlive/firebase/firebase.kt rename to firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt diff --git a/firebase-app/src/androidMain/AndroidManifest.xml b/firebase-app/src/androidMain/AndroidManifest.xml deleted file mode 100644 index d5130296d..000000000 --- a/firebase-app/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt index 38894f1fe..34d8b03c3 100644 --- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -1,7 +1,5 @@ package dev.gitlive.firebase -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.initialize import kotlin.test.Test expect val context: Any diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index 2b1e440ec..cd71cd552 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -2,9 +2,6 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.konan.target.KonanTarget - version = project.property("firebase-auth.version") as String plugins { @@ -25,27 +22,28 @@ plugins { //} android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.auth" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } - getByName("androidTest"){ - java.srcDir(file("src/androidAndroidTest/kotlin")) - manifest.srcFile("src/androidAndroidTest/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -86,12 +84,12 @@ kotlin { } noPodspec() pod("FirebaseAuth") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() nodejs { testTask { @@ -112,23 +110,33 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { dependencies { - api("com.google.firebase:firebase-auth") + api("com.google.firebase:firebase-auth-ktx") + } + } + + getByName("androidInstrumentedTest") { + dependencies { + dependsOn(commonTest) } } @@ -140,8 +148,6 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/firebase-auth/firebase_auth.podspec b/firebase-auth/firebase_auth.podspec index e69de29bb..4b6003c05 100644 --- a/firebase-auth/firebase_auth.podspec +++ b/firebase-auth/firebase_auth.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_auth' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_auth.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-auth', + 'PRODUCT_MODULE_NAME' => 'firebase_auth', + } + + spec.script_phases = [ + { + :name => 'Build firebase_auth', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/firebase-auth/src/androidAndroidTest/AndroidManifest.xml b/firebase-auth/src/androidInstrumentedTest/AndroidManifest.xml similarity index 74% rename from firebase-auth/src/androidAndroidTest/AndroidManifest.xml rename to firebase-auth/src/androidInstrumentedTest/AndroidManifest.xml index 22ae9ef69..3d8df4081 100644 --- a/firebase-auth/src/androidAndroidTest/AndroidManifest.xml +++ b/firebase-auth/src/androidInstrumentedTest/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/firebase-auth/src/androidAndroidTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt similarity index 100% rename from firebase-auth/src/androidAndroidTest/kotlin/dev/gitlive/firebase/auth/auth.kt rename to firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt diff --git a/firebase-auth/src/androidMain/AndroidManifest.xml b/firebase-auth/src/androidMain/AndroidManifest.xml deleted file mode 100644 index dd935eb3b..000000000 --- a/firebase-auth/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt index d45066c3f..5782f9974 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -7,6 +7,7 @@ package dev.gitlive.firebase.auth import android.app.Activity import com.google.firebase.FirebaseException import com.google.firebase.auth.OAuthProvider +import com.google.firebase.auth.PhoneAuthOptions import com.google.firebase.auth.PhoneAuthProvider import kotlinx.coroutines.CompletableDeferred import kotlinx.coroutines.coroutineScope @@ -78,9 +79,9 @@ actual class OAuthProvider(val android: com.google.firebase.auth.OAuthProvider) } } -actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthProvider) { +actual class PhoneAuthProvider(val createOptionsBuilder: () -> PhoneAuthOptions.Builder) { - actual constructor(auth: FirebaseAuth) : this(com.google.firebase.auth.PhoneAuthProvider.getInstance(auth.android)) + actual constructor(auth: FirebaseAuth) : this({ PhoneAuthOptions.newBuilder(auth.android) }) actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(com.google.firebase.auth.PhoneAuthProvider.getCredential(verificationId, smsCode)) @@ -90,7 +91,16 @@ actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthPr PhoneAuthProvider.OnVerificationStateChangedCallbacks() { override fun onCodeSent(verificationId: String, forceResending: PhoneAuthProvider.ForceResendingToken) { - verificationProvider.codeSent { android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, this, forceResending) } + verificationProvider.codeSent { + val options = createOptionsBuilder() + .setPhoneNumber(phoneNumber) + .setTimeout(verificationProvider.timeout, verificationProvider.unit) + .setActivity(verificationProvider.activity) + .setCallbacks(this) + .setForceResendingToken(forceResending) + .build() + PhoneAuthProvider.verifyPhoneNumber(options) + } } override fun onCodeAutoRetrievalTimeOut(verificationId: String) { @@ -113,7 +123,13 @@ actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthPr } } - android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, callback) + val options = createOptionsBuilder() + .setPhoneNumber(phoneNumber) + .setTimeout(verificationProvider.timeout, verificationProvider.unit) + .setActivity(verificationProvider.activity) + .setCallbacks(callback) + .build() + PhoneAuthProvider.verifyPhoneNumber(options) response.await().getOrThrow() } diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index 93df71e17..9219d960f 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -2,35 +2,36 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget - version = project.property("firebase-common.version") as String plugins { id("com.android.library") kotlin("multiplatform") - kotlin("plugin.serialization") version "1.8.20" + kotlin("plugin.serialization") } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.common" defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } - getByName("androidTest").java.srcDir(file("src/androidAndroidTest/kotlin")) + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -53,7 +54,7 @@ kotlin { iosSimulatorArm64() } - js { + js(IR) { useCommonJs() nodejs { testTask { @@ -74,8 +75,10 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true optIn("kotlin.Experimental") optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") @@ -84,15 +87,31 @@ kotlin { } } - val commonMain by getting { + getByName("commonMain") { + val serializationVersion: String by project + + dependencies { + api("org.jetbrains.kotlinx:kotlinx-serialization-core:$serializationVersion") + } + } + + val commonTest by getting { + dependencies { + implementation(kotlin("test")) + implementation(kotlin("test-common")) + implementation(kotlin("test-annotations-common")) + } + } + + getByName("androidMain") { dependencies { - api("org.jetbrains.kotlinx:kotlinx-serialization-core:1.3.2") + api("com.google.firebase:firebase-common-ktx") } } - val androidMain by getting { + getByName("androidInstrumentedTest") { dependencies { - api("com.google.firebase:firebase-common") + dependsOn(commonTest) } } @@ -105,9 +124,9 @@ kotlin { iosSimulatorArm64Test.dependsOn(iosTest) } - val jsMain by getting { + getByName("jsMain") { dependencies { - api(npm("firebase", "9.4.1")) + api(npm("firebase", "9.21.0")) } } } diff --git a/firebase-common/src/androidAndroidTest/kotlin/dev/gitlive/firebase/EncodersTest.kt b/firebase-common/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/EncodersTest.kt similarity index 100% rename from firebase-common/src/androidAndroidTest/kotlin/dev/gitlive/firebase/EncodersTest.kt rename to firebase-common/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/EncodersTest.kt diff --git a/firebase-common/src/androidMain/AndroidManifest.xml b/firebase-common/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 5408449c4..000000000 --- a/firebase-common/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/decoders.kt b/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/decoders.kt index 7d19ca40d..f9501d342 100644 --- a/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/decoders.kt +++ b/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/decoders.kt @@ -31,7 +31,7 @@ expect fun getPolymorphicType(value: Any?, discriminator: String): String class FirebaseDecoder(internal val value: Any?) : Decoder { override val serializersModule: SerializersModule - get() = EmptySerializersModule + get() = EmptySerializersModule() override fun beginStructure(descriptor: SerialDescriptor) = structureDecoder(descriptor) @@ -59,7 +59,7 @@ class FirebaseDecoder(internal val value: Any?) : Decoder { override fun decodeNull() = decodeNull(value) - override fun decodeInline(inlineDescriptor: SerialDescriptor) = FirebaseDecoder(value) + override fun decodeInline(descriptor: SerialDescriptor) = FirebaseDecoder(value) override fun decodeSerializableValue(deserializer: DeserializationStrategy): T { return decodeSerializableValuePolymorphic(value, deserializer) @@ -87,7 +87,7 @@ open class FirebaseCompositeDecoder( private val get: (descriptor: SerialDescriptor, index: Int) -> Any? ): CompositeDecoder { - override val serializersModule = EmptySerializersModule + override val serializersModule = EmptySerializersModule() override fun decodeSequentially() = true diff --git a/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/encoders.kt b/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/encoders.kt index dfbf7f93f..5e5c409b8 100644 --- a/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/encoders.kt +++ b/firebase-common/src/commonMain/kotlin/dev/gitlive/firebase/encoders.kt @@ -22,7 +22,7 @@ class FirebaseEncoder(internal val shouldEncodeElementDefault: Boolean) : Encode var value: Any? = null - override val serializersModule = EmptySerializersModule + override val serializersModule = EmptySerializersModule() private var polymorphicDiscriminator: String? = null override fun beginStructure(descriptor: SerialDescriptor): CompositeEncoder { @@ -82,7 +82,7 @@ class FirebaseEncoder(internal val shouldEncodeElementDefault: Boolean) : Encode this.value = value } - override fun encodeInline(inlineDescriptor: SerialDescriptor): Encoder = + override fun encodeInline(descriptor: SerialDescriptor): Encoder = FirebaseEncoder(shouldEncodeElementDefault) override fun encodeSerializableValue(serializer: SerializationStrategy, value: T) { @@ -99,7 +99,7 @@ open class FirebaseCompositeEncoder constructor( private val set: (descriptor: SerialDescriptor, index: Int, value: Any?) -> Unit, ): CompositeEncoder { - override val serializersModule = EmptySerializersModule + override val serializersModule = EmptySerializersModule() // private fun SerializationStrategy.toFirebase(): SerializationStrategy = when(descriptor.kind) { // StructureKind.MAP -> FirebaseMapSerializer(descriptor.getElementDescriptor(1)) as SerializationStrategy diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index 06593ead3..5b6fdc35e 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -2,9 +2,6 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.konan.target.KonanTarget - version = project.property("firebase-config.version") as String plugins { @@ -15,26 +12,28 @@ plugins { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.remoteconfig" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } - getByName("androidTest"){ - java.srcDir(file("src/androidAndroidTest/kotlin")) - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -75,12 +74,12 @@ kotlin { } noPodspec() pod("FirebaseRemoteConfig") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() browser { testTask { @@ -94,23 +93,33 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { dependencies { - api("com.google.firebase:firebase-config") + api("com.google.firebase:firebase-config-ktx") + } + } + + getByName("androidInstrumentedTest") { + dependencies { + dependsOn(commonTest) } } @@ -122,8 +131,6 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/firebase-config/firebase_config.podspec b/firebase-config/firebase_config.podspec index e69de29bb..3b2184367 100644 --- a/firebase-config/firebase_config.podspec +++ b/firebase-config/firebase_config.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_config' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_config.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-config', + 'PRODUCT_MODULE_NAME' => 'firebase_config', + } + + spec.script_phases = [ + { + :name => 'Build firebase_config', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end diff --git a/firebase-config/src/androidAndroidTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt similarity index 100% rename from firebase-config/src/androidAndroidTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt rename to firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt diff --git a/firebase-config/src/androidMain/AndroidManifest.xml b/firebase-config/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 8a1a47b14..000000000 --- a/firebase-config/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 851e0e22d..19077716f 100644 --- a/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/iosMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -23,6 +23,7 @@ actual fun Firebase.remoteConfig(app: FirebaseApp): FirebaseRemoteConfig = TODO( // FirebaseRemoteConfig(FIRRemoteConfig.remoteConfigWithApp(Firebase.app.ios)) actual class FirebaseRemoteConfig internal constructor(val ios: FIRRemoteConfig) { + @Suppress("UNCHECKED_CAST") actual val all: Map get() { return listOf( @@ -54,8 +55,8 @@ actual class FirebaseRemoteConfig internal constructor(val ios: FIRRemoteConfig) ios.await { ensureInitializedWithCompletionHandler(it) } actual suspend fun fetch(minimumFetchIntervalInSeconds: Long?) { - val status: FIRRemoteConfigFetchStatus = if (minimumFetchIntervalInSeconds != null) { - ios.awaitResult { + if (minimumFetchIntervalInSeconds != null) { + ios.awaitResult { fetchWithExpirationDuration(minimumFetchIntervalInSeconds.toDouble(), it) } } else { diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index 712bc858b..3c44f9167 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -2,9 +2,6 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.konan.target.KonanTarget - version = project.property("firebase-crashlytics.version") as String plugins { @@ -14,28 +11,29 @@ plugins { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.crashlytics" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled = true } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } - getByName("androidTest"){ - java.srcDir(file("src/androidAndroidTest/kotlin")) - manifest.srcFile("src/androidAndroidTest/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -63,7 +61,7 @@ kotlin { } noPodspec() pod("FirebaseCrashlytics") { - version = "10.7.0" + version = "10.9.0" } } } @@ -71,23 +69,33 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.6" - languageVersion = "1.6" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { + dependencies { + api("com.google.firebase:firebase-crashlytics-ktx") + } + } + + getByName("androidInstrumentedTest") { dependencies { - api("com.google.firebase:firebase-crashlytics") + dependsOn(commonTest) } } diff --git a/firebase-crashlytics/firebase_crashlytics.podspec b/firebase-crashlytics/firebase_crashlytics.podspec index e69de29bb..5e9af0c12 100644 --- a/firebase-crashlytics/firebase_crashlytics.podspec +++ b/firebase-crashlytics/firebase_crashlytics.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_crashlytics' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_crashlytics.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-crashlytics', + 'PRODUCT_MODULE_NAME' => 'firebase_crashlytics', + } + + spec.script_phases = [ + { + :name => 'Build firebase_crashlytics', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end diff --git a/firebase-firestore/src/androidAndroidTest/AndroidManifest.xml b/firebase-crashlytics/src/androidInstrumentedTest/AndroidManifest.xml similarity index 74% rename from firebase-firestore/src/androidAndroidTest/AndroidManifest.xml rename to firebase-crashlytics/src/androidInstrumentedTest/AndroidManifest.xml index 22ae9ef69..3d8df4081 100644 --- a/firebase-firestore/src/androidAndroidTest/AndroidManifest.xml +++ b/firebase-crashlytics/src/androidInstrumentedTest/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/firebase-crashlytics/src/androidAndroidTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt similarity index 100% rename from firebase-crashlytics/src/androidAndroidTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt rename to firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt diff --git a/firebase-crashlytics/src/androidAndroidTest/res/values/strings.xml b/firebase-crashlytics/src/androidInstrumentedTest/res/values/strings.xml similarity index 100% rename from firebase-crashlytics/src/androidAndroidTest/res/values/strings.xml rename to firebase-crashlytics/src/androidInstrumentedTest/res/values/strings.xml diff --git a/firebase-crashlytics/src/androidMain/AndroidManifest.xml b/firebase-crashlytics/src/androidMain/AndroidManifest.xml deleted file mode 100644 index c77076714..000000000 --- a/firebase-crashlytics/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index e1f00a7bd..209e82f9f 100644 --- a/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/iosMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -30,6 +30,7 @@ actual class FirebaseCrashlytics internal constructor(val ios: FIRCrashlytics) { actual fun setCustomKey(key: String, value: Float) { ios.setCustomValue(key, value.toString()) } actual fun setCustomKey(key: String, value: Int) { ios.setCustomValue(key, value.toString()) } actual fun setCustomKey(key: String, value: Long) { ios.setCustomValue(key, value.toString()) } + @Suppress("UNCHECKED_CAST") actual fun setCustomKeys(customKeys: Map) { ios.setCustomKeysAndValues(customKeys as Map) } } diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index ef75443c2..11c3af08e 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -17,22 +17,27 @@ repositories { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.database" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -60,12 +65,12 @@ kotlin { } noPodspec() pod("FirebaseDatabase") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() nodejs { testTask { @@ -86,8 +91,10 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.coroutines.FlowPreview") @@ -95,16 +102,24 @@ kotlin { } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { + dependencies { + api("com.google.firebase:firebase-database-ktx") + } + } + + getByName("androidInstrumentedTest") { dependencies { - api("com.google.firebase:firebase-database") + dependsOn(commonTest) } } @@ -117,9 +132,9 @@ kotlin { iosSimulatorArm64Test.dependsOn(iosTest) } - val jsMain by getting { + getByName("jsMain") { dependencies { - api(npm("firebase", "9.4.1")) + api(npm("firebase", "9.21.0")) } } } diff --git a/firebase-database/firebase_database.podspec b/firebase-database/firebase_database.podspec index e69de29bb..92161b6fd 100644 --- a/firebase-database/firebase_database.podspec +++ b/firebase-database/firebase_database.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_database' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_database.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-database', + 'PRODUCT_MODULE_NAME' => 'firebase_database', + } + + spec.script_phases = [ + { + :name => 'Build firebase_database', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end diff --git a/firebase-database/src/androidAndroidTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt similarity index 100% rename from firebase-database/src/androidAndroidTest/kotlin/dev/gitlive/firebase/database/database.kt rename to firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt diff --git a/firebase-database/src/androidMain/AndroidManifest.xml b/firebase-database/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 31845b00f..000000000 --- a/firebase-database/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt index 82400fb41..7d9ad55ee 100644 --- a/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt +++ b/firebase-database/src/iosMain/kotlin/dev/gitlive/firebase/database/ServerValue.kt @@ -13,6 +13,7 @@ actual class ServerValue internal actual constructor( ){ actual companion object { actual val TIMESTAMP: ServerValue get() = ServerValue(NativeServerValue.timestamp()) + @Suppress("CAST_NEVER_SUCCEEDS") actual fun increment(delta: Double): ServerValue = ServerValue(NativeServerValue.increment(delta as NSNumber)) } diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 0fc7a3614..025ece2ae 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -12,28 +12,29 @@ plugins { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.firestore" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled = true } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } - getByName("androidTest"){ - java.srcDir(file("src/androidAndroidTest/kotlin")) - manifest.srcFile("src/androidAndroidTest/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -62,12 +63,12 @@ kotlin { } noPodspec() pod("FirebaseFirestore") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() nodejs { testTask { @@ -85,27 +86,46 @@ kotlin { } } + tasks.withType> { + kotlinOptions.freeCompilerArgs += listOf( + "-Xopt-in=kotlin.Experimental", + "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-Xopt-in=kotlinx.serialization.InternalSerializationApi", + "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi" + ) + } + sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.InternalSerializationApi") } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { dependencies { - api("com.google.firebase:firebase-firestore") + api("com.google.firebase:firebase-firestore-ktx") + } + } + + getByName("androidInstrumentedTest") { + dependencies { + dependsOn(commonTest) } } @@ -117,8 +137,6 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/firebase-firestore/firebase_firestore.podspec b/firebase-firestore/firebase_firestore.podspec index e69de29bb..29b48e79f 100644 --- a/firebase-firestore/firebase_firestore.podspec +++ b/firebase-firestore/firebase_firestore.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_firestore' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_firestore.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-firestore', + 'PRODUCT_MODULE_NAME' => 'firebase_firestore', + } + + spec.script_phases = [ + { + :name => 'Build firebase_firestore', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end diff --git a/firebase-perf/src/androidAndroidTest/AndroidManifest.xml b/firebase-firestore/src/androidInstrumentedTest/AndroidManifest.xml similarity index 74% rename from firebase-perf/src/androidAndroidTest/AndroidManifest.xml rename to firebase-firestore/src/androidInstrumentedTest/AndroidManifest.xml index 22ae9ef69..3d8df4081 100644 --- a/firebase-perf/src/androidAndroidTest/AndroidManifest.xml +++ b/firebase-firestore/src/androidInstrumentedTest/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/firebase-firestore/src/androidAndroidTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt similarity index 100% rename from firebase-firestore/src/androidAndroidTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt rename to firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt diff --git a/firebase-firestore/src/androidMain/AndroidManifest.xml b/firebase-firestore/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 4836c588e..000000000 --- a/firebase-firestore/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index a38a92d93..c0c68bc1b 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -11,22 +11,27 @@ plugins { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.functions" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -54,12 +59,12 @@ kotlin { } noPodspec() pod("FirebaseFunctions") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() nodejs { testTask { @@ -77,30 +82,48 @@ kotlin { } } + tasks.withType> { + kotlinOptions.freeCompilerArgs += listOf( + "-Xopt-in=kotlin.Experimental", + "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", + "-Xopt-in=kotlinx.serialization.InternalSerializationApi" + ) + } + sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.InternalSerializationApi") } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { dependencies { api("com.google.firebase:firebase-functions") } } + getByName("androidInstrumentedTest") { + dependencies { + dependsOn(commonTest) + } + } + if (supportIosTarget) { val iosMain by getting val iosSimulatorArm64Main by getting @@ -109,8 +132,6 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/firebase-functions/firebase_functions.podspec b/firebase-functions/firebase_functions.podspec index e69de29bb..b8404a94a 100644 --- a/firebase-functions/firebase_functions.podspec +++ b/firebase-functions/firebase_functions.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_functions' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_functions.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-functions', + 'PRODUCT_MODULE_NAME' => 'firebase_functions', + } + + spec.script_phases = [ + { + :name => 'Build firebase_functions', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end diff --git a/firebase-functions/src/androidMain/AndroidManifest.xml b/firebase-functions/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 3a59d0707..000000000 --- a/firebase-functions/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt index 44c5b0a3f..76b5e6082 100644 --- a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -29,6 +29,7 @@ actual class FirebaseFunctions internal constructor(val android: com.google.fire actual fun httpsCallable(name: String, timeout: Long?) = HttpsCallableReference(android.getHttpsCallable(name).apply { timeout?.let { setTimeout(it, TimeUnit.MILLISECONDS) } }) + @Suppress("DEPRECATION") actual fun useFunctionsEmulator(origin: String) = android.useFunctionsEmulator(origin) actual fun useEmulator(host: String, port: Int) = android.useEmulator(host, port) diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index d5c58a3b8..a3ae6f03b 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -11,22 +11,27 @@ plugins { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.installations" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -54,12 +59,12 @@ kotlin { } noPodspec() pod("FirebaseInstallations") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() nodejs { testTask { @@ -80,22 +85,32 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { + dependencies { + api("com.google.firebase:firebase-installations-ktx") + } + } + + getByName("androidInstrumentedTest") { dependencies { - api("com.google.firebase:firebase-installations") + dependsOn(commonTest) } } @@ -107,8 +122,6 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/firebase-installations/firebase_installations.podspec b/firebase-installations/firebase_installations.podspec index e69de29bb..272bd1ece 100644 --- a/firebase-installations/firebase_installations.podspec +++ b/firebase-installations/firebase_installations.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_installations' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_installations.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-installations', + 'PRODUCT_MODULE_NAME' => 'firebase_installations', + } + + spec.script_phases = [ + { + :name => 'Build firebase_installations', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end diff --git a/firebase-installations/src/androidMain/AndroidManifest.xml b/firebase-installations/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 80d1e04ed..000000000 --- a/firebase-installations/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index e6d662fb7..5e1b49c35 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -2,9 +2,6 @@ * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ -import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget -import org.jetbrains.kotlin.konan.target.KonanTarget - version = project.property("firebase-perf.version") as String plugins { @@ -14,28 +11,29 @@ plugins { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.perf" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" multiDexEnabled = true } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } - getByName("androidTest"){ - java.srcDir(file("src/androidAndroidTest/kotlin")) - manifest.srcFile("src/androidAndroidTest/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -63,12 +61,12 @@ kotlin { } noPodspec() pod("FirebasePerformance") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() browser { testTask { @@ -82,23 +80,33 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.6" - languageVersion = "1.6" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { dependencies { - api("com.google.firebase:firebase-perf") + api("com.google.firebase:firebase-perf-ktx") + } + } + + getByName("androidInstrumentedTest") { + dependencies { + dependsOn(commonTest) } } @@ -111,8 +119,6 @@ kotlin { val iosSimulatorArm64Test by sourceSets.getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/firebase-perf/firebase_perf.podspec b/firebase-perf/firebase_perf.podspec index e69de29bb..48f76f5dd 100644 --- a/firebase-perf/firebase_perf.podspec +++ b/firebase-perf/firebase_perf.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_perf' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_perf.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-perf', + 'PRODUCT_MODULE_NAME' => 'firebase_perf', + } + + spec.script_phases = [ + { + :name => 'Build firebase_perf', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end diff --git a/firebase-crashlytics/src/androidAndroidTest/AndroidManifest.xml b/firebase-perf/src/androidInstrumentedTest/AndroidManifest.xml similarity index 71% rename from firebase-crashlytics/src/androidAndroidTest/AndroidManifest.xml rename to firebase-perf/src/androidInstrumentedTest/AndroidManifest.xml index b054003ba..3d8df4081 100644 --- a/firebase-crashlytics/src/androidAndroidTest/AndroidManifest.xml +++ b/firebase-perf/src/androidInstrumentedTest/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/firebase-perf/src/androidAndroidTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt similarity index 100% rename from firebase-perf/src/androidAndroidTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt rename to firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt diff --git a/firebase-perf/src/androidAndroidTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt similarity index 100% rename from firebase-perf/src/androidAndroidTest/kotlin/dev/gitlive/firebase/perf/performance.kt rename to firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt diff --git a/firebase-perf/src/androidMain/AndroidManifest.xml b/firebase-perf/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 1f882cd22..000000000 --- a/firebase-perf/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/gradle.properties b/gradle.properties index bbc44ae48..677b24dae 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,6 +19,7 @@ systemProp.org.gradle.internal.publish.checksums.insecure=true testOptions.unitTests.isIncludeAndroidResources=true kotlin.mpp.enableCInteropCommonization=true kotlin.native.cacheKind=none +kotlin.mpp.androidSourceSetLayoutVersion=2 # Set to true to skip tests and even compilation of the iOS target. skipIosTarget=false @@ -57,3 +58,12 @@ firebase-functions.version=1.8.1 firebase-installations.version=1.8.1 firebase-perf.version=1.8.1 firebase-crashlytics.version=1.8.1 + +# Dependencies Versions: +gradlePluginVersion=8.0.0 +kotlinVersion=1.8.21 +coroutinesVersion=1.7.0 +serializationVersion=1.5.0 +firebaseBoMVersion=32.0.0 +apiVersion=1.8 +languageVersion=1.8 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index aa991fcea..fae08049a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle.kts b/settings.gradle.kts index 06ccce75c..74e871f80 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -11,5 +11,12 @@ include( "firebase-crashlytics" ) -//enableFeaturePreview("GRADLE_METADATA") +pluginManagement { + val kotlinVersion: String by settings + plugins { + kotlin("multiplatform") version kotlinVersion + kotlin("native.cocoapods") version kotlinVersion + kotlin("plugin.serialization") version kotlinVersion + } +} From 7fe7a647e97307357ca8f1c91aeba57905a1ca77 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 16 May 2023 10:20:36 +0200 Subject: [PATCH 02/29] Fixes to fix CI + cleanup --- .gitignore | 1 - firebase-app/build.gradle.kts | 5 ----- firebase-auth/build.gradle.kts | 10 ---------- .../kotlin/dev/gitlive/firebase/auth/user.kt | 8 ++++---- .../kotlin/dev/gitlive/firebase/auth/user.kt | 12 ++++++++---- .../iosMain/kotlin/dev/gitlive/firebase/auth/user.kt | 8 ++++---- .../jsMain/kotlin/dev/gitlive/firebase/auth/user.kt | 12 ++++++------ 7 files changed, 22 insertions(+), 34 deletions(-) diff --git a/.gitignore b/.gitignore index 891e657d4..adbab484d 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,5 @@ Firebase*.zip /Firebase .DS_Store *.log - /kotlin-js-store/ /kotlin-js-store/yarn.lock diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index 9f6414826..4b2eddc17 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -10,11 +10,6 @@ plugins { kotlin("multiplatform") } -repositories { - google() - mavenCentral() -} - android { val minSdkVersion: Int by project val compileSdkVersion: Int by project diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index cd71cd552..a19fd4a30 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -11,16 +11,6 @@ plugins { //id("com.quittle.android-emulator") version "0.2.0" } -//buildscript { -// repositories { -// google() -// gradlePluginPortal() -// } -// dependencies { -// classpath("com.android.tools.build:gradle:3.6.1") -// } -//} - android { val minSdkVersion: Int by project val compileSdkVersion: Int by project diff --git a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt index 47a942bdb..9077fa2b7 100644 --- a/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/androidMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -8,16 +8,16 @@ import android.net.Uri import com.google.firebase.auth.UserProfileChangeRequest import kotlinx.coroutines.tasks.await -actual class FirebaseUser internal constructor(val android: com.google.firebase.auth.FirebaseUser) { +actual class FirebaseUser internal constructor(val android: com.google.firebase.auth.FirebaseUser) : FirebaseUserProfile { actual val uid: String get() = android.uid - actual val displayName: String? + override val displayName: String? get() = android.displayName actual val email: String? get() = android.email actual val phoneNumber: String? get() = android.phoneNumber - actual val photoURL: String? + override val photoURL: String? get() = android.photoUrl?.toString() actual val isAnonymous: Boolean get() = android.isAnonymous @@ -46,7 +46,7 @@ actual class FirebaseUser internal constructor(val android: com.google.firebase. actual suspend fun updateEmail(email: String) = android.updateEmail(email).await().run { Unit } actual suspend fun updatePassword(password: String) = android.updatePassword(password).await().run { Unit } actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = android.updatePhoneNumber(credential.android).await().run { Unit } - actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { + override suspend fun updateProfile(displayName: String?, photoUrl: String?) { val request = UserProfileChangeRequest.Builder() .setDisplayName(displayName) .setPhotoUri(photoUrl?.let { Uri.parse(it) }) diff --git a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt index 3d00c412f..bdbddc6af 100644 --- a/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -4,12 +4,17 @@ package dev.gitlive.firebase.auth -expect class FirebaseUser { - val uid: String +// Javascript IR compilation has issues with referencing to actual values as default parameters, so we should use an interface instead +interface FirebaseUserProfile { val displayName: String? + val photoURL: String? + suspend fun updateProfile(displayName: String? = this.displayName, photoUrl: String? = this.photoURL) +} + +expect class FirebaseUser : FirebaseUserProfile { + val uid: String val email: String? val phoneNumber: String? - val photoURL: String? val isAnonymous: Boolean val isEmailVerified: Boolean val metaData: UserMetaData? @@ -28,7 +33,6 @@ expect class FirebaseUser { suspend fun updateEmail(email: String) suspend fun updatePassword(password: String) suspend fun updatePhoneNumber(credential: PhoneAuthCredential) - suspend fun updateProfile(displayName: String? = this.displayName, photoUrl: String? = this.photoURL) suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings? = null) } diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt index d322fdb4c..b27c6d2a2 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -7,16 +7,16 @@ package dev.gitlive.firebase.auth import cocoapods.FirebaseAuth.* import platform.Foundation.NSURL -actual class FirebaseUser internal constructor(val ios: FIRUser) { +actual class FirebaseUser internal constructor(val ios: FIRUser) : FirebaseUserProfile { actual val uid: String get() = ios.uid - actual val displayName: String? + override val displayName: String? get() = ios.displayName actual val email: String? get() = ios.email actual val phoneNumber: String? get() = ios.phoneNumber - actual val photoURL: String? + override val photoURL: String? get() = ios.photoURL?.absoluteString actual val isAnonymous: Boolean get() = ios.anonymous @@ -64,7 +64,7 @@ actual class FirebaseUser internal constructor(val ios: FIRUser) { actual suspend fun updateEmail(email: String) = ios.await { updateEmail(email, it) }.run { Unit } actual suspend fun updatePassword(password: String) = ios.await { updatePassword(password, it) }.run { Unit } actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = ios.await { updatePhoneNumberCredential(credential.ios, it) }.run { Unit } - actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { + override suspend fun updateProfile(displayName: String?, photoUrl: String?) { val request = ios.profileChangeRequest().apply { this.displayName = displayName this.photoURL = photoUrl?.let { NSURL.URLWithString(it) } diff --git a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt index ab6cb796e..8eca92182 100644 --- a/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt +++ b/firebase-auth/src/jsMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -4,16 +4,16 @@ import dev.gitlive.firebase.firebase import kotlinx.coroutines.await import kotlin.js.Date -actual class FirebaseUser internal constructor(val js: firebase.user.User) { +actual class FirebaseUser internal constructor(val js: firebase.user.User) : FirebaseUserProfile { actual val uid: String get() = rethrow { js.uid } - actual val displayName: String? + override val displayName: String? get() = rethrow { js.displayName } actual val email: String? get() = rethrow { js.email } actual val phoneNumber: String? get() = rethrow { js.phoneNumber } - actual val photoURL: String? + override val photoURL: String? get() = rethrow { js.photoURL } actual val isAnonymous: Boolean get() = rethrow { js.isAnonymous } @@ -43,7 +43,7 @@ actual class FirebaseUser internal constructor(val js: firebase.user.User) { actual suspend fun updateEmail(email: String) = rethrow { js.updateEmail(email).await() } actual suspend fun updatePassword(password: String) = rethrow { js.updatePassword(password).await() } actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = rethrow { js.updatePhoneNumber(credential.js).await() } - actual suspend fun updateProfile(displayName: String?, photoUrl: String?) = rethrow { + override suspend fun updateProfile(displayName: String?, photoUrl: String?) = rethrow { val request = object : firebase.user.ProfileUpdateRequest { override val displayName: String? = displayName override val photoURL: String? = photoUrl @@ -56,9 +56,9 @@ actual class FirebaseUser internal constructor(val js: firebase.user.User) { actual class UserInfo(val js: firebase.user.UserInfo) { actual val displayName: String? get() = rethrow { js.displayName } - actual val email: String? + actual val email: String? get() = rethrow { js.email } - actual val phoneNumber: String? + actual val phoneNumber: String? get() = rethrow { js.phoneNumber } actual val photoURL: String? get() = rethrow { js.photoURL } From 010e672337be29359e641de047c5b4b75a6fc260 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 16 May 2023 11:57:58 +0200 Subject: [PATCH 03/29] Fixed some gradle warnings --- firebase-common/build.gradle.kts | 1 - firebase-firestore/build.gradle.kts | 9 --------- firebase-functions/build.gradle.kts | 8 -------- 3 files changed, 18 deletions(-) diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index 9219d960f..6818b241f 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -80,7 +80,6 @@ kotlin { this.apiVersion = apiVersion this.languageVersion = languageVersion progressiveMode = true - optIn("kotlin.Experimental") optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.ExperimentalSerializationApi") optIn("kotlinx.serialization.InternalSerializationApi") diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 025ece2ae..9c855791d 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -86,15 +86,6 @@ kotlin { } } - tasks.withType> { - kotlinOptions.freeCompilerArgs += listOf( - "-Xopt-in=kotlin.Experimental", - "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xopt-in=kotlinx.serialization.InternalSerializationApi", - "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi" - ) - } - sourceSets { all { languageSettings.apply { diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index c0c68bc1b..4ecd3b2ff 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -82,14 +82,6 @@ kotlin { } } - tasks.withType> { - kotlinOptions.freeCompilerArgs += listOf( - "-Xopt-in=kotlin.Experimental", - "-Xopt-in=kotlinx.coroutines.ExperimentalCoroutinesApi", - "-Xopt-in=kotlinx.serialization.InternalSerializationApi" - ) - } - sourceSets { all { languageSettings.apply { From 3525b90631752cda0e4b1d15cd426ad3e09e23ac Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 16 May 2023 11:57:27 +0200 Subject: [PATCH 04/29] Fixing Android emulator --- .github/workflows/pull_request.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 343fb3fea..5e4e3badf 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -73,6 +73,8 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} + arch: x86_64 + target: google_apis force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false From c53dff1dda2851d0ee124484e2ec8f03d865adef Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 16 May 2023 12:07:34 +0200 Subject: [PATCH 05/29] Raise coroutines/serialization version --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 677b24dae..6914f2723 100644 --- a/gradle.properties +++ b/gradle.properties @@ -62,8 +62,8 @@ firebase-crashlytics.version=1.8.1 # Dependencies Versions: gradlePluginVersion=8.0.0 kotlinVersion=1.8.21 -coroutinesVersion=1.7.0 -serializationVersion=1.5.0 +coroutinesVersion=1.7.1 +serializationVersion=1.5.1 firebaseBoMVersion=32.0.0 apiVersion=1.8 languageVersion=1.8 From 46cf087db632e668b1e08386eed2adf0ac92c5b6 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 16 May 2023 14:03:24 +0200 Subject: [PATCH 06/29] More fixes (temp comment out assemble) --- .github/workflows/pull_request.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 5e4e3badf..4fc9261a0 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -39,8 +39,8 @@ jobs: run: npm install -g firebase-tools - name: Start Firebase emulator run: "firebase emulators:start --config=./test/firebase.json &" - - name: Assemble - run: ./gradlew assemble +# - name: Assemble +# run: ./gradlew assemble - name: Run JS Tests run: ./gradlew cleanTest jsTest - name: Upload JS test artifact @@ -83,6 +83,8 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} + arch: x86_64 + target: google_apis force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true From 6536957d9be0f010534187e5aa797b0168b016f4 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 16 May 2023 14:03:54 +0200 Subject: [PATCH 07/29] With assemble --- .github/workflows/pull_request.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 4fc9261a0..ec89583f8 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -39,8 +39,8 @@ jobs: run: npm install -g firebase-tools - name: Start Firebase emulator run: "firebase emulators:start --config=./test/firebase.json &" -# - name: Assemble -# run: ./gradlew assemble + - name: Assemble + run: ./gradlew assemble - name: Run JS Tests run: ./gradlew cleanTest jsTest - name: Upload JS test artifact From 76445e792117603917430ed5744dfb7f112bb966 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 20 Jun 2023 10:44:25 +0200 Subject: [PATCH 08/29] Fix test-utils --- README.md | 4 +-- firebase-database/build.gradle.kts | 2 +- firebase-firestore/build.gradle.kts | 2 +- test-utils/build.gradle.kts | 35 +++++++++++-------- .../src/androidMain/AndroidManifest.xml | 1 - 5 files changed, 24 insertions(+), 20 deletions(-) delete mode 100644 test-utils/src/androidMain/AndroidManifest.xml diff --git a/README.md b/README.md index d486b504e..f56eb151a 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ The Firebase Kotlin SDK uses Kotlin serialization to read and write custom class ```groovy plugins { - kotlin("multiplatform") version "1.8.20" // or kotlin("jvm") or any other kotlin plugin - kotlin("plugin.serialization") version "1.8.20" + kotlin("multiplatform") version "1.8.21" // or kotlin("jvm") or any other kotlin plugin + kotlin("plugin.serialization") version "1.8.21" } ``` diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 11c3af08e..506fd6ddd 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -8,7 +8,7 @@ plugins { id("com.android.library") kotlin("native.cocoapods") kotlin("multiplatform") - kotlin("plugin.serialization") version "1.8.20" + kotlin("plugin.serialization") } repositories { diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index eaa1acbc3..fae37d70b 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -8,7 +8,7 @@ plugins { id("com.android.library") kotlin("native.cocoapods") kotlin("multiplatform") - kotlin("plugin.serialization") version "1.8.20" + kotlin("plugin.serialization") } android { diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 18579f1e5..f9f3963e4 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -9,22 +9,27 @@ version = "0.0.1" plugins { id("com.android.library") kotlin("multiplatform") - kotlin("plugin.serialization") version "1.8.20" + kotlin("plugin.serialization") } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.testUtils" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } - packagingOptions { + + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -47,7 +52,7 @@ kotlin { iosSimulatorArm64() } - js { + js(IR) { useCommonJs() nodejs() browser() @@ -56,13 +61,15 @@ kotlin { sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true } } - val commonMain by getting { + getByName("commonMain") { dependencies { implementation(kotlin("test")) } @@ -76,7 +83,5 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/test-utils/src/androidMain/AndroidManifest.xml b/test-utils/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 07001b111..000000000 --- a/test-utils/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - From 361c007ef93f8368b9765aea82f727260b80514c Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 20 Jun 2023 14:42:42 +0200 Subject: [PATCH 09/29] Fixed issues for AndroidUnitTest --- build.gradle.kts | 17 +++++++-------- firebase-app/build.gradle.kts | 6 +++++- .../kotlin/dev/gitlive/firebase/firebase.kt | 1 + .../kotlin/dev/gitlive/firebase/firebase.kt | 18 ++++++++++++++++ .../kotlin/dev/gitlive/firebase/firebase.kt | 2 ++ .../kotlin/dev/gitlive/firebase/firebase.kt | 2 ++ .../kotlin/dev/gitlive/firebase/firebase.kt | 4 +++- firebase-auth/build.gradle.kts | 6 +++++- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 ++ .../kotlin/dev/gitlive/firebase/auth/auth.kt | 20 ++++++++++++++++++ .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 ++ .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 ++ .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 ++ firebase-common/build.gradle.kts | 3 --- .../dev/gitlive/firebase/EncodersTest.kt | 9 -------- firebase-config/build.gradle.kts | 6 +++++- .../firebase/remoteconfig/RemoteConfig.kt | 2 ++ .../firebase/remoteconfig/RemoteConfig.kt | 18 ++++++++++++++++ .../remoteconfig/FirebaseRemoteConfig.kt | 2 ++ .../firebase/remoteconfig/RemoteConfig.kt | 2 ++ .../remoteconfig/FirebaseRemoteConfig.kt | 2 ++ firebase-crashlytics/build.gradle.kts | 6 +++++- .../firebase/crashlytics/crashlytics.kt | 2 ++ .../firebase/crashlytics/crashlytics.kt | 21 +++++++++++++++++++ .../firebase/crashlytics/crashlytics.kt | 3 ++- .../firebase/crashlytics/crashlytics.kt | 2 ++ firebase-database/build.gradle.kts | 6 +++++- .../dev/gitlive/firebase/database/database.kt | 2 ++ .../dev/gitlive/firebase/database/database.kt | 20 ++++++++++++++++++ .../dev/gitlive/firebase/database/database.kt | 2 ++ .../dev/gitlive/firebase/database/database.kt | 2 ++ .../dev/gitlive/firebase/database/database.kt | 4 +++- .../gitlive/firebase/firestore/firestore.kt | 2 ++ .../gitlive/firebase/firestore/firestore.kt | 21 +++++++++++++++++++ .../gitlive/firebase/firestore/firestore.kt | 4 +++- .../gitlive/firebase/firestore/firestore.kt | 2 ++ .../gitlive/firebase/firestore/firestore.kt | 2 ++ firebase-functions/build.gradle.kts | 6 +++++- firebase-installations/build.gradle.kts | 6 +++++- firebase-perf/build.gradle.kts | 6 +++++- .../dev/gitlive/firebase/perf/performance.kt | 2 ++ .../dev/gitlive/firebase/perf/performance.kt | 21 +++++++++++++++++++ .../gitlive/firebase/perf/metrics/Trace.kt | 2 ++ .../dev/gitlive/firebase/perf/performance.kt | 2 ++ .../dev/gitlive/firebase/perf/performance.kt | 2 ++ .../dev/gitlive/firebase/perf/performance.kt | 2 ++ test-utils/build.gradle.kts | 3 +-- 47 files changed, 246 insertions(+), 35 deletions(-) create mode 100644 firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt create mode 100644 firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt delete mode 100644 firebase-common/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/EncodersTest.kt create mode 100644 firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt create mode 100644 firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt create mode 100644 firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt create mode 100644 firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt create mode 100644 firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt diff --git a/build.gradle.kts b/build.gradle.kts index da8b24c59..65e14fb67 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -172,8 +172,7 @@ subprojects { "commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") "androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") "androidMainImplementation"(platform("com.google.firebase:firebase-bom:$firebaseBoMVersion")) - "commonTestImplementation"(kotlin("test-common")) - "commonTestImplementation"(kotlin("test-annotations-common")) + "commonTestImplementation"(kotlin("test")) "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") if (this@afterEvaluate.name != "firebase-crashlytics") { @@ -187,6 +186,12 @@ subprojects { } } + // Workaround for setting kotlinOptions.jvmTarget + // See https://youtrack.jetbrains.com/issue/KT-55947/Unable-to-set-kapt-jvm-target-version + tasks.withType().configureEach { + kotlinOptions.jvmTarget = "11" + } + if (skipPublishing) return@subprojects apply(plugin = "maven-publish") @@ -245,18 +250,12 @@ subprojects { } } - - // Workaround for setting kotlinOptions.jvmTarget - // See https://youtrack.jetbrains.com/issue/KT-55947/Unable-to-set-kapt-jvm-target-version - tasks.withType().configureEach { - kotlinOptions.jvmTarget = "11" - } } tasks.withType { fun isNonStable(version: String): Boolean { - val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) } + val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.uppercase(java.util.Locale.ENGLISH).contains(it) } val versionMatch = "^[0-9,.v-]+(-r)?$".toRegex().matches(version) return (stableKeyword || versionMatch).not() diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index 4b2eddc17..45b0450cd 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -102,7 +102,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt index 10402d8f0..0f4a8fbe3 100644 --- a/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -10,3 +10,4 @@ import androidx.test.platform.app.InstrumentationRegistry actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt new file mode 100644 index 000000000..11fc69adb --- /dev/null +++ b/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:JvmName("tests") +package dev.gitlive.firebase + +import org.junit.Ignore + +actual val context: Any = "" + +actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } + +// Tests are to be run on AndroidInstrumentedTests. +// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest +// Therefore we just wont run them +// Kotlin 1.9 will introduce methods for disabling tests properly +actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt index 34d8b03c3..bf27bee32 100644 --- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -4,7 +4,9 @@ import kotlin.test.Test expect val context: Any expect fun runTest(test: suspend () -> Unit) +expect annotation class IgnoreForAndroidUnitTest constructor() +@IgnoreForAndroidUnitTest class FirebaseAppTest { @Test fun testInitialize() { diff --git a/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt index 8ec3e16ea..fbb904e83 100644 --- a/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -20,3 +20,5 @@ actual fun runTest(test: suspend () -> Unit) = runBlocking { } testRun.await() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt index 19b3f898f..8e5825527 100644 --- a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -10,4 +10,6 @@ actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) { runTest { test() } -} \ No newline at end of file +} + +actual annotation class IgnoreForAndroidUnitTest() \ No newline at end of file diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index a19fd4a30..d57d11893 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -116,7 +116,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 5aff507e9..986547b95 100644 --- a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -12,3 +12,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt new file mode 100644 index 000000000..bd4535ca0 --- /dev/null +++ b/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:JvmName("tests") +package dev.gitlive.firebase.auth + +import org.junit.Ignore + +actual val emulatorHost: String = "10.0.2.2" + +actual val context: Any = "" + +actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } + +// Tests are to be run on AndroidInstrumentedTests. +// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest +// Therefore we just wont run them +// Kotlin 1.9 will introduce methods for disabling tests properly +actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 12250e31e..97421ea52 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -11,7 +11,9 @@ import kotlin.test.* expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend () -> Unit) +expect annotation class IgnoreForAndroidUnitTest constructor() +@IgnoreForAndroidUnitTest class FirebaseAuthTest { @BeforeTest diff --git a/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 540531237..a5caaeea1 100644 --- a/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -22,3 +22,5 @@ actual fun runTest(test: suspend () -> Unit) = runBlocking { } testRun.await() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt index be90b4c54..f902bcc64 100644 --- a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -12,3 +12,5 @@ actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) { kotlinx.coroutines.test.runTest { test() } } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index ec1718352..61ddd57c8 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -96,9 +96,6 @@ kotlin { val commonTest by getting { dependencies { - implementation(kotlin("test")) - implementation(kotlin("test-common")) - implementation(kotlin("test-annotations-common")) implementation(project(":test-utils")) } } diff --git a/firebase-common/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/EncodersTest.kt b/firebase-common/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/EncodersTest.kt deleted file mode 100644 index 231ee7b7d..000000000 --- a/firebase-common/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/EncodersTest.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. - */ - -package dev.gitlive.firebase - -actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) -actual fun nativeListOf(vararg elements: Any): Any = listOf(*elements) -actual fun nativeAssertEquals(expected: Any?, actual: Any?) = kotlin.test.assertEquals(expected, actual) diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index 5b6fdc35e..fbb68202f 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -109,7 +109,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index 821ebf0f3..80741860d 100644 --- a/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -10,3 +10,5 @@ import androidx.test.platform.app.InstrumentationRegistry actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt new file mode 100644 index 000000000..d30260759 --- /dev/null +++ b/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:JvmName("tests") +package dev.gitlive.firebase.remoteconfig + +import org.junit.Ignore + +actual val context: Any = "" + +actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } + +// Tests are to be run on AndroidInstrumentedTests. +// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest +// Therefore we just wont run them +// Kotlin 1.9 will introduce methods for disabling tests properly +actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 8c1751c3d..ac484f810 100644 --- a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -16,7 +16,9 @@ import kotlin.test.assertEquals expect val context: Any expect fun runTest(test: suspend () -> Unit) +expect annotation class IgnoreForAndroidUnitTest constructor() +@IgnoreForAndroidUnitTest class FirebaseRemoteConfigTest { private val defaults = arrayOf( "test_default_boolean" to true, diff --git a/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index 6bf1fedad..56b1df440 100644 --- a/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -20,3 +20,5 @@ actual fun runTest(test: suspend () -> Unit) = runBlocking { } testRun.await() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 74650729c..bc6161681 100644 --- a/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -6,3 +6,5 @@ actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) { kotlinx.coroutines.test.runTest { test() } } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index 3c44f9167..df540ff1f 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -85,7 +85,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 6e8d9c0f4..8fab649f6 100644 --- a/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -13,3 +13,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt new file mode 100644 index 000000000..3b702ca2a --- /dev/null +++ b/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:JvmName("tests") +package dev.gitlive.firebase.crashlytics + +import kotlinx.coroutines.CoroutineScope +import org.junit.Ignore + +actual val emulatorHost: String = "10.0.2.2" + +actual val context: Any = "" + +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } + +// Tests are to be run on AndroidInstrumentedTests. +// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest +// Therefore we just wont run them +// Kotlin 1.9 will introduce methods for disabling tests properly +actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 92ac6d480..6895fcc59 100644 --- a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -12,12 +12,13 @@ import kotlinx.coroutines.CoroutineScope import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertFalse -import kotlin.test.assertNotNull expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend CoroutineScope.() -> Unit) +expect annotation class IgnoreForAndroidUnitTest constructor() +@IgnoreForAndroidUnitTest class FirebaseCrashlyticsTest { @BeforeTest diff --git a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 9fb5ce419..c4e13e787 100644 --- a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -22,3 +22,5 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { } testRun.await() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 506fd6ddd..4d72df4bc 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -109,7 +109,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt index 91653371b..a3a760644 100644 --- a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -11,3 +11,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt new file mode 100644 index 000000000..18841e2dc --- /dev/null +++ b/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:JvmName("tests") +package dev.gitlive.firebase.database + +import org.junit.Ignore + +actual val emulatorHost: String = "10.0.2.2" + +actual val context: Any = "" + +actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } + +// Tests are to be run on AndroidInstrumentedTests. +// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest +// Therefore we just wont run them +// Kotlin 1.9 will introduce methods for disabling tests properly +actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt index 4b747df92..2978ae90c 100644 --- a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -8,7 +8,9 @@ import kotlin.test.* expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend () -> Unit) +expect annotation class IgnoreForAndroidUnitTest constructor() +@IgnoreForAndroidUnitTest class FirebaseDatabaseTest { @Serializable diff --git a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt index b1c213873..427fb1edc 100644 --- a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -22,3 +22,5 @@ actual fun runTest(test: suspend () -> Unit) = runBlocking { } testRun.await() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt index 1ba05f836..9936ea6d9 100644 --- a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -5,4 +5,6 @@ actual val emulatorHost: String = "localhost" actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) { runTest { test() } -} \ No newline at end of file +} + +actual annotation class IgnoreForAndroidUnitTest() \ No newline at end of file diff --git a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 9c3f485e2..5c099bd29 100644 --- a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -14,3 +14,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt new file mode 100644 index 000000000..6279a50d7 --- /dev/null +++ b/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:JvmName("tests") +package dev.gitlive.firebase.firestore + +import kotlinx.coroutines.CoroutineScope +import org.junit.Ignore + +actual val emulatorHost: String = "10.0.2.2" + +actual val context: Any = "" + +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } + +// Tests are to be run on AndroidInstrumentedTests. +// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest +// Therefore we just wont run them +// Kotlin 1.9 will introduce methods for disabling tests properly +actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index b6cc28fd7..aac251ae1 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -27,7 +27,9 @@ import kotlin.test.assertTrue expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend CoroutineScope.() -> Unit) +expect annotation class IgnoreForAndroidUnitTest constructor() +@IgnoreForAndroidUnitTest class FirebaseFirestoreTest { @Serializable @@ -45,7 +47,7 @@ class FirebaseFirestoreTest { ) @BeforeTest - fun initializeFirebase() { + fun initializeFirebase() = runTest { Firebase .takeIf { Firebase.apps(context).isEmpty() } ?.apply { diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 294182dd3..66023dd84 100644 --- a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -22,3 +22,5 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { } testRun.await() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index f4cc24ae9..3f0547fc5 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -14,3 +14,5 @@ actual val context: Any = Unit actual fun runTest(test: suspend CoroutineScope.() -> Unit) { runTest { test() } } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 4ecd3b2ff..cc4466186 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -102,7 +102,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index a3ae6f03b..55c782dea 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -100,7 +100,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index 5e1b49c35..3ffbd3dda 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -96,7 +96,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 3d270a930..4775cf053 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -13,3 +13,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt new file mode 100644 index 000000000..7fa4328ed --- /dev/null +++ b/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:JvmName("tests") +package dev.gitlive.firebase.perf + +import kotlinx.coroutines.CoroutineScope +import org.junit.Ignore + +actual val emulatorHost: String = "10.0.2.2" + +actual val context: Any = "" + +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } + +// Tests are to be run on AndroidInstrumentedTests. +// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest +// Therefore we just wont run them +// Kotlin 1.9 will introduce methods for disabling tests properly +actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index e817e1243..6fac9d3dd 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -5,11 +5,13 @@ import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps import dev.gitlive.firebase.initialize import dev.gitlive.firebase.perf.FirebasePerformance +import dev.gitlive.firebase.perf.IgnoreForAndroidUnitTest import dev.gitlive.firebase.perf.performance import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals +@IgnoreForAndroidUnitTest class TraceTest { private lateinit var performance: FirebasePerformance diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 5a69e221c..e5a86349c 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -14,7 +14,9 @@ import kotlin.test.* expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend CoroutineScope.() -> Unit) +expect annotation class IgnoreForAndroidUnitTest constructor() +@IgnoreForAndroidUnitTest class FirebasePerformanceTest { @BeforeTest diff --git a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 977a9dda7..32eb93d2c 100644 --- a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -22,3 +22,5 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { } testRun.await() } + +actual annotation class IgnoreForAndroidUnitTest() diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 85fcd695b..e44e0f0f2 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -19,6 +19,8 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) { kotlinx.coroutines.test.runTest { test() } } +actual annotation class IgnoreForAndroidUnitTest() + class JsPerformanceTest { private lateinit var performance: FirebasePerformance diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index f9f3963e4..e9b0832c7 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -40,7 +40,6 @@ android { } kotlin { - android { publishAllLibraryVariants() } @@ -71,7 +70,7 @@ kotlin { getByName("commonMain") { dependencies { - implementation(kotlin("test")) + api(kotlin("test")) } } From 18711c103bbbef5c58465dab90be6b6e46417b51 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Fri, 15 Sep 2023 16:40:04 +0200 Subject: [PATCH 10/29] Ugrade to Kotlin 1.9.10 & fix tracking issues --- README.md | 10 +-- firebase-app/build.gradle.kts | 26 ++++--- firebase-auth/build.gradle.kts | 29 +++++--- firebase-common/build.gradle.kts | 30 ++++---- firebase-config/build.gradle.kts | 21 +++--- firebase-crashlytics/build.gradle.kts | 8 +-- firebase-database/build.gradle.kts | 28 ++++---- firebase-firestore/build.gradle.kts | 31 ++++---- firebase-functions/build.gradle.kts | 26 ++++--- firebase-installations/build.gradle.kts | 28 ++++---- firebase-perf/build.gradle.kts | 18 ++--- firebase-storage/build.gradle.kts | 72 ++++++++++++------- firebase-storage/firebase_storage.podspec | 39 ++++++++++ .../AndroidManifest.xml | 3 +- .../dev/gitlive/firebase/storage/storage.kt | 0 .../src/androidMain/AndroidManifest.xml | 1 - .../dev/gitlive/firebase/storage/storage.kt | 10 +++ gradle.properties | 11 ++- test-utils/build.gradle.kts | 10 +-- 19 files changed, 253 insertions(+), 148 deletions(-) rename firebase-storage/src/{androidAndroidTest => androidInstrumentedTest}/AndroidManifest.xml (73%) rename firebase-storage/src/{androidAndroidTest => androidInstrumentedTest}/kotlin/dev/gitlive/firebase/storage/storage.kt (100%) delete mode 100644 firebase-storage/src/androidMain/AndroidManifest.xml create mode 100644 firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt diff --git a/README.md b/README.md index 537d4905d..913a34b7d 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ Firebase as a backend for () { @Override public void onComplete(@NonNull Task task) { if (task.isSuccessful()) { - Log.d(TAG, "User profile updated."); + Log.d(TAG, "User profile updated.") } } - }); + }) //...becomes... diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index 9800ed346..a0622a989 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -46,12 +46,12 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget() { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } @@ -77,18 +77,22 @@ kotlin { js(IR) { useCommonJs() nodejs { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } @@ -127,7 +131,7 @@ kotlin { } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index 72423adb4..fb864295b 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -60,7 +60,7 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } @@ -82,23 +82,27 @@ kotlin { js(IR) { useCommonJs() nodejs { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } @@ -114,6 +118,9 @@ kotlin { this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -142,7 +149,7 @@ kotlin { } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index 452b52f07..4f5c64b0b 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -43,17 +43,17 @@ android { kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } } - val test by compilations.getting { + compilations.getByName("test") { kotlinOptions { jvmTarget = "17" } @@ -70,18 +70,22 @@ kotlin { js(IR) { useCommonJs() nodejs { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } @@ -140,11 +144,11 @@ kotlin { } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - val jvmTest by getting { + getByName("jvmTest") { dependencies { implementation(kotlin("test-junit")) } diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index 94be9873f..f769f17c8 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -60,17 +60,17 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } } - val test by compilations.getting { + compilations.getByName("test") { kotlinOptions { jvmTarget = "17" } @@ -95,11 +95,13 @@ kotlin { js(IR) { useCommonJs() browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } @@ -112,6 +114,9 @@ kotlin { this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -140,7 +145,7 @@ kotlin { } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index 04673c88e..7203f7cd2 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -47,17 +47,17 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } // jvm { -// val main by compilations.getting { +// compilations.getByName("main") { // kotlinOptions { // jvmTarget = "17" // } // } -// val test by compilations.getting { +// compilations.getByName("test") { // kotlinOptions { // jvmTarget = "17" // } @@ -116,7 +116,7 @@ kotlin { } } -// val jvmMain by getting { +// getByName("jvmMain") { // kotlin.srcDir("src/androidMain/kotlin") // } diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index b2727003a..0caeb8a05 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -51,17 +51,17 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } } - val test by compilations.getting { + compilations.getByName("test") { kotlinOptions { jvmTarget = "17" } @@ -86,18 +86,22 @@ kotlin { js(IR) { useCommonJs() nodejs { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } @@ -127,7 +131,7 @@ kotlin { implementation(project(":test-utils")) } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index d81c7c809..d9d5527fb 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -49,17 +49,17 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } } - val test by compilations.getting { + compilations.getByName("test") { kotlinOptions { jvmTarget = "17" } @@ -84,18 +84,22 @@ kotlin { js(IR) { useCommonJs() nodejs { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } @@ -109,6 +113,9 @@ kotlin { progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.InternalSerializationApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -137,7 +144,7 @@ kotlin { } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index a1424bc17..790841a1f 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -45,7 +45,7 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } @@ -67,23 +67,27 @@ kotlin { js(IR) { useCommonJs() nodejs { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } @@ -128,7 +132,7 @@ kotlin { } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index a54b1402d..0bc84a454 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -45,17 +45,17 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } } - val test by compilations.getting { + compilations.getByName("test") { kotlinOptions { jvmTarget = "17" } @@ -80,18 +80,22 @@ kotlin { js(IR) { useCommonJs() nodejs { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } @@ -131,7 +135,7 @@ kotlin { } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index 9a1075041..6a5660233 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -47,17 +47,17 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } } - val test by compilations.getting { + compilations.getByName("test") { kotlinOptions { jvmTarget = "17" } @@ -82,11 +82,13 @@ kotlin { js(IR) { useCommonJs() browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } @@ -127,7 +129,7 @@ kotlin { } } -// val jvmMain by getting { +// getByName("jvmMain") { // kotlin.srcDir("src/androidMain/kotlin") // } diff --git a/firebase-storage/build.gradle.kts b/firebase-storage/build.gradle.kts index c49c2d52e..ae9a8ddf7 100644 --- a/firebase-storage/build.gradle.kts +++ b/firebase-storage/build.gradle.kts @@ -11,22 +11,28 @@ plugins { } android { - compileSdk = property("targetSdkVersion") as Int + val minSdkVersion: Int by project + val compileSdkVersion: Int by project + + compileSdk = compileSdkVersion + namespace = "dev.gitlive.firebase.storage" + defaultConfig { - minSdk = property("minSdkVersion") as Int - targetSdk = property("targetSdkVersion") as Int + minSdk = minSdkVersion + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } - sourceSets { - getByName("main") { - manifest.srcFile("src/androidMain/AndroidManifest.xml") - } + + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 } + testOptions { unitTests.apply { isIncludeAndroidResources = true } } - packagingOptions { + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") resources.pickFirsts.add("META-INF/LGPL2.1") @@ -40,17 +46,17 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } } - val test by compilations.getting { + compilations.getByName("test") { kotlinOptions { jvmTarget = "17" } @@ -67,51 +73,65 @@ kotlin { } noPodspec() pod("FirebaseStorage") { - version = "10.7.0" + version = "10.9.0" } } } - js { + js(IR) { useCommonJs() nodejs { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } browser { - testTask { - useKarma { - useChromeHeadless() + testTask( + Action { + useKarma { + useChromeHeadless() + } } - } + ) } } sourceSets { all { languageSettings.apply { - apiVersion = "1.8" - languageVersion = "1.8" + val apiVersion: String by project + val languageVersion: String by project + this.apiVersion = apiVersion + this.languageVersion = languageVersion progressiveMode = true } } - val commonMain by getting { + getByName("commonMain") { dependencies { api(project(":firebase-app")) implementation(project(":firebase-common")) } } - val androidMain by getting { + val commonTest by getting + + getByName("androidMain") { dependencies { api("com.google.firebase:firebase-storage") } } + getByName("androidInstrumentedTest") { + dependencies { + dependsOn(commonTest) + } + } + if (supportIosTarget) { val iosMain by getting val iosSimulatorArm64Main by getting @@ -120,8 +140,6 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - val jsMain by getting } } diff --git a/firebase-storage/firebase_storage.podspec b/firebase-storage/firebase_storage.podspec index e69de29bb..4464bab9e 100644 --- a/firebase-storage/firebase_storage.podspec +++ b/firebase-storage/firebase_storage.podspec @@ -0,0 +1,39 @@ +Pod::Spec.new do |spec| + spec.name = 'firebase_storage' + spec.version = '1.8.1' + spec.homepage = '' + spec.source = { :http=> ''} + spec.authors = '' + spec.license = '' + spec.summary = '' + spec.vendored_frameworks = 'build/cocoapods/framework/firebase_storage.framework' + spec.libraries = 'c++' + + + + spec.pod_target_xcconfig = { + 'KOTLIN_PROJECT_PATH' => ':firebase-storage', + 'PRODUCT_MODULE_NAME' => 'firebase_storage', + } + + spec.script_phases = [ + { + :name => 'Build firebase_storage', + :execution_position => :before_compile, + :shell_path => '/bin/sh', + :script => <<-SCRIPT + if [ "YES" = "$OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED" ]; then + echo "Skipping Gradle build task invocation due to OVERRIDE_KOTLIN_BUILD_IDE_SUPPORTED environment variable set to \"YES\"" + exit 0 + fi + set -ev + REPO_ROOT="$PODS_TARGET_SRCROOT" + "$REPO_ROOT/../gradlew" -p "$REPO_ROOT" $KOTLIN_PROJECT_PATH:syncFramework \ + -Pkotlin.native.cocoapods.platform=$PLATFORM_NAME \ + -Pkotlin.native.cocoapods.archs="$ARCHS" \ + -Pkotlin.native.cocoapods.configuration="$CONFIGURATION" + SCRIPT + } + ] + +end \ No newline at end of file diff --git a/firebase-storage/src/androidAndroidTest/AndroidManifest.xml b/firebase-storage/src/androidInstrumentedTest/AndroidManifest.xml similarity index 73% rename from firebase-storage/src/androidAndroidTest/AndroidManifest.xml rename to firebase-storage/src/androidInstrumentedTest/AndroidManifest.xml index 1e24abdd0..3d8df4081 100644 --- a/firebase-storage/src/androidAndroidTest/AndroidManifest.xml +++ b/firebase-storage/src/androidInstrumentedTest/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/firebase-storage/src/androidAndroidTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt similarity index 100% rename from firebase-storage/src/androidAndroidTest/kotlin/dev/gitlive/firebase/storage/storage.kt rename to firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt diff --git a/firebase-storage/src/androidMain/AndroidManifest.xml b/firebase-storage/src/androidMain/AndroidManifest.xml deleted file mode 100644 index 47467c44f..000000000 --- a/firebase-storage/src/androidMain/AndroidManifest.xml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt new file mode 100644 index 000000000..881533b47 --- /dev/null +++ b/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -0,0 +1,10 @@ +package dev.gitlive.firebase.storage + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.runBlocking + +actual val emulatorHost: String = "10.0.2.2" + +actual val context: Any = "" + +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } diff --git a/gradle.properties b/gradle.properties index a2a3f26a1..071162885 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,13 +13,12 @@ kotlin.native.enableParallelExecutionCheck=false kotlin.setJvmTargetFromAndroidCompileOptions=true kotlin.native.binary.memoryModel=experimental kotlin.native.binary.freezing=disabled -org.gradle.jvmargs=-Xmx2048m +org.gradle.jvmargs=-Xmx8G -Dfile.encoding\=UTF-8 -XX:MaxMetaspaceSize=512m -Dkotlin.daemon.jvm.options\=-Xmx8G,-XX:MaxMetaspaceSize=512m org.gradle.parallel=true systemProp.org.gradle.internal.publish.checksums.insecure=true testOptions.unitTests.isIncludeAndroidResources=true kotlin.mpp.enableCInteropCommonization=true kotlin.native.cacheKind=none -kotlin.mpp.androidSourceSetLayoutVersion=2 # Set to true to skip tests and even compilation of the iOS target. skipIosTarget=false @@ -63,10 +62,10 @@ firebase-crashlytics.version=1.10.0 firebase-storage.version=1.10.0 # Dependencies Versions: -gradlePluginVersion=8.0.0 -kotlinVersion=1.8.21 -coroutinesVersion=1.7.1 -serializationVersion=1.5.1 +gradlePluginVersion=8.1.1 +kotlinVersion=1.9.10 +coroutinesVersion=1.7.3 +serializationVersion=1.6.0 firebaseBoMVersion=32.0.0 apiVersion=1.8 languageVersion=1.8 diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 296f656c3..7a89b65ef 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -40,17 +40,17 @@ android { } kotlin { - android { + androidTarget { publishAllLibraryVariants() } jvm { - val main by compilations.getting { + compilations.getByName("main") { kotlinOptions { jvmTarget = "17" } } - val test by compilations.getting { + compilations.getByName("test") { kotlinOptions { jvmTarget = "17" } @@ -87,7 +87,7 @@ kotlin { } } - val jvmMain by getting { + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } @@ -100,7 +100,7 @@ kotlin { iosSimulatorArm64Test.dependsOn(iosTest) } - val jsMain by getting { + getByName("jsMain") { dependencies { implementation(kotlin("test-js")) } From f372c418d2a2908fc84201e4994dd23be17d9195 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Mon, 18 Sep 2023 12:31:54 +0200 Subject: [PATCH 11/29] Raise firebase versions --- build.gradle.kts | 2 +- firebase-app/build.gradle.kts | 2 +- firebase-auth/build.gradle.kts | 6 +- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 1 + .../kotlin/dev/gitlive/firebase/auth/auth.kt | 150 ++++++++++++++++++ .../dev/gitlive/firebase/auth/credentials.kt | 134 ++++++++++++++++ .../dev/gitlive/firebase/auth/multifactor.kt | 42 +++++ .../kotlin/dev/gitlive/firebase/auth/user.kt | 80 ++++++++++ firebase-config/build.gradle.kts | 2 +- firebase-crashlytics/build.gradle.kts | 3 +- firebase-database/build.gradle.kts | 2 +- firebase-firestore/build.gradle.kts | 2 +- firebase-functions/build.gradle.kts | 2 +- firebase-installations/build.gradle.kts | 2 +- firebase-perf/build.gradle.kts | 2 +- firebase-storage/build.gradle.kts | 2 +- gradle.properties | 4 +- 17 files changed, 420 insertions(+), 18 deletions(-) create mode 100644 firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt create mode 100644 firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt create mode 100644 firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt create mode 100644 firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt diff --git a/build.gradle.kts b/build.gradle.kts index 64fd95ea2..626d63510 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -118,7 +118,7 @@ subprojects { "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") if (this@afterEvaluate.name != "firebase-crashlytics") { "jvmMainApi"("dev.gitlive:firebase-java-sdk:0.1.1") - "jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.6.0") { + "jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") { exclude("com.google.android.gms") } "jsTestImplementation"(kotlin("test-js")) diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index a0622a989..8e105180f 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -69,7 +69,7 @@ kotlin { } noPodspec() pod("FirebaseCore") { - version = "10.9.0" + version = "10.15.0" } } } diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index fb864295b..839907c4b 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -74,7 +74,7 @@ kotlin { } noPodspec() pod("FirebaseAuth") { - version = "10.9.0" + version = "10.15.0" } } } @@ -149,10 +149,6 @@ kotlin { } } - getByName("jvmMain") { - kotlin.srcDir("src/androidMain/kotlin") - } - if (supportIosTarget) { val iosMain by getting val iosSimulatorArm64Main by getting diff --git a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt index 26ddb3e85..ffa89818e 100644 --- a/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/iosMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -19,6 +19,7 @@ import platform.Foundation.* actual val Firebase.auth get() = FirebaseAuth(FIRAuth.auth()) +@Suppress("CAST_NEVER_SUCCEEDS") actual fun Firebase.auth(app: FirebaseApp): FirebaseAuth = FirebaseAuth( FIRAuth.authWithApp(app.ios as objcnames.classes.FIRApp) ) diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt new file mode 100644 index 000000000..839a4b2a4 --- /dev/null +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +@file:JvmName("android") +package dev.gitlive.firebase.auth + +import com.google.firebase.auth.ActionCodeEmailInfo +import com.google.firebase.auth.ActionCodeMultiFactorInfo +import com.google.firebase.auth.ActionCodeResult.* +import com.google.firebase.auth.FirebaseAuth.AuthStateListener +import dev.gitlive.firebase.Firebase +import dev.gitlive.firebase.FirebaseApp +import kotlinx.coroutines.channels.awaitClose +import kotlinx.coroutines.flow.Flow +import kotlinx.coroutines.flow.callbackFlow +import kotlinx.coroutines.tasks.await + +actual val Firebase.auth + get() = FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance()) + +actual fun Firebase.auth(app: FirebaseApp) = + FirebaseAuth(com.google.firebase.auth.FirebaseAuth.getInstance(app.android)) + +actual class FirebaseAuth internal constructor(val android: com.google.firebase.auth.FirebaseAuth) { + actual val currentUser: FirebaseUser? + get() = android.currentUser?.let { FirebaseUser(it) } + + actual val authStateChanged: Flow get() = callbackFlow { + val listener = object : AuthStateListener { + override fun onAuthStateChanged(auth: com.google.firebase.auth.FirebaseAuth) { + trySend(auth.currentUser?.let { FirebaseUser(it) }) + } + } + android.addAuthStateListener(listener) + awaitClose { android.removeAuthStateListener(listener) } + } + + actual val idTokenChanged get(): Flow = callbackFlow { + val listener = object : com.google.firebase.auth.FirebaseAuth.IdTokenListener { + override fun onIdTokenChanged(auth: com.google.firebase.auth.FirebaseAuth) { + trySend(auth.currentUser?.let { FirebaseUser(it) }) + } + } + android.addIdTokenListener(listener) + awaitClose { android.removeIdTokenListener(listener) } + } + + actual var languageCode: String + get() = android.languageCode.orEmpty() + set(value) { android.setLanguageCode(value) } + + + actual suspend fun applyActionCode(code: String) = android.applyActionCode(code).await().run { Unit } + actual suspend fun confirmPasswordReset(code: String, newPassword: String) = android.confirmPasswordReset(code, newPassword).await().run { Unit } + + actual suspend fun createUserWithEmailAndPassword(email: String, password: String) = + AuthResult(android.createUserWithEmailAndPassword(email, password).await()) + + actual suspend fun fetchSignInMethodsForEmail(email: String): List = android.fetchSignInMethodsForEmail(email).await().signInMethods.orEmpty() + + actual suspend fun sendPasswordResetEmail(email: String, actionCodeSettings: ActionCodeSettings?) { + android.sendPasswordResetEmail(email, actionCodeSettings?.toAndroid()).await() + } + + actual suspend fun sendSignInLinkToEmail(email: String, actionCodeSettings: ActionCodeSettings) = android.sendSignInLinkToEmail(email, actionCodeSettings.toAndroid()).await().run { Unit } + + actual fun isSignInWithEmailLink(link: String) = android.isSignInWithEmailLink(link) + + actual suspend fun signInWithEmailAndPassword(email: String, password: String) = + AuthResult(android.signInWithEmailAndPassword(email, password).await()) + + actual suspend fun signInWithCustomToken(token: String) = + AuthResult(android.signInWithCustomToken(token).await()) + + actual suspend fun signInAnonymously() = AuthResult(android.signInAnonymously().await()) + + actual suspend fun signInWithCredential(authCredential: AuthCredential) = + AuthResult(android.signInWithCredential(authCredential.android).await()) + + actual suspend fun signInWithEmailLink(email: String, link: String) = + AuthResult(android.signInWithEmailLink(email, link).await()) + + actual suspend fun signOut() = android.signOut() + + actual suspend fun updateCurrentUser(user: FirebaseUser) = android.updateCurrentUser(user.android).await().run { Unit } + actual suspend fun verifyPasswordResetCode(code: String): String = android.verifyPasswordResetCode(code).await() + + actual suspend fun checkActionCode(code: String): T { + val result = android.checkActionCode(code).await() + @Suppress("UNCHECKED_CAST") + return when(result.operation) { + SIGN_IN_WITH_EMAIL_LINK -> ActionCodeResult.SignInWithEmailLink + VERIFY_EMAIL -> ActionCodeResult.VerifyEmail(result.info!!.email) + PASSWORD_RESET -> ActionCodeResult.PasswordReset(result.info!!.email) + RECOVER_EMAIL -> (result.info as ActionCodeEmailInfo).run { + ActionCodeResult.RecoverEmail(email, previousEmail) + } + VERIFY_BEFORE_CHANGE_EMAIL -> (result.info as ActionCodeEmailInfo).run { + ActionCodeResult.VerifyBeforeChangeEmail(email, previousEmail) + } + REVERT_SECOND_FACTOR_ADDITION -> (result.info as ActionCodeMultiFactorInfo).run { + ActionCodeResult.RevertSecondFactorAddition(email, MultiFactorInfo(multiFactorInfo)) + } + ERROR -> throw UnsupportedOperationException(result.operation.toString()) + else -> throw UnsupportedOperationException(result.operation.toString()) + } as T + } + + actual fun useEmulator(host: String, port: Int) = android.useEmulator(host, port) +} + +actual class AuthResult internal constructor(val android: com.google.firebase.auth.AuthResult) { + actual val user: FirebaseUser? + get() = android.user?.let { FirebaseUser(it) } +} + +actual class AuthTokenResult(val android: com.google.firebase.auth.GetTokenResult) { + // actual val authTimestamp: Long +// get() = android.authTimestamp + actual val claims: Map + get() = android.claims + // actual val expirationTimestamp: Long +// get() = android.expirationTimestamp +// actual val issuedAtTimestamp: Long +// get() = android.issuedAtTimestamp + actual val signInProvider: String? + get() = android.signInProvider + actual val token: String? + get() = android.token +} + +internal fun ActionCodeSettings.toAndroid() = com.google.firebase.auth.ActionCodeSettings.newBuilder() + .setUrl(url) + .also { androidPackageName?.run { it.setAndroidPackageName(packageName, installIfNotAvailable, minimumVersion) } } + .also { dynamicLinkDomain?.run { it.setDynamicLinkDomain(this) } } + .setHandleCodeInApp(canHandleCodeInApp) + .also { iOSBundleId?.run { it.setIOSBundleId(this) } } + .build() + +actual typealias FirebaseAuthException = com.google.firebase.auth.FirebaseAuthException +actual typealias FirebaseAuthActionCodeException = com.google.firebase.auth.FirebaseAuthActionCodeException +actual typealias FirebaseAuthEmailException = com.google.firebase.auth.FirebaseAuthEmailException +actual typealias FirebaseAuthInvalidCredentialsException = com.google.firebase.auth.FirebaseAuthInvalidCredentialsException +actual typealias FirebaseAuthWeakPasswordException = com.google.firebase.auth.FirebaseAuthWeakPasswordException +actual typealias FirebaseAuthInvalidUserException = com.google.firebase.auth.FirebaseAuthInvalidUserException +actual typealias FirebaseAuthMultiFactorException = com.google.firebase.auth.FirebaseAuthMultiFactorException +actual typealias FirebaseAuthRecentLoginRequiredException = com.google.firebase.auth.FirebaseAuthRecentLoginRequiredException +actual typealias FirebaseAuthUserCollisionException = com.google.firebase.auth.FirebaseAuthUserCollisionException +actual typealias FirebaseAuthWebException = com.google.firebase.auth.FirebaseAuthWebException diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt new file mode 100644 index 000000000..c44acfadd --- /dev/null +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/credentials.kt @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +package dev.gitlive.firebase.auth + +import android.app.Activity +import com.google.firebase.FirebaseException +import com.google.firebase.auth.OAuthProvider +import com.google.firebase.auth.PhoneAuthProvider +import kotlinx.coroutines.CompletableDeferred +import kotlinx.coroutines.coroutineScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.tasks.await +import java.util.concurrent.TimeUnit + +actual open class AuthCredential(open val android: com.google.firebase.auth.AuthCredential) { + actual val providerId: String + get() = android.provider +} + +actual class PhoneAuthCredential(override val android: com.google.firebase.auth.PhoneAuthCredential) : AuthCredential(android) + +actual class OAuthCredential(override val android: com.google.firebase.auth.OAuthCredential) : AuthCredential(android) + +actual object EmailAuthProvider { + actual fun credential( + email: String, + password: String + ): AuthCredential = AuthCredential(com.google.firebase.auth.EmailAuthProvider.getCredential(email, password)) + + actual fun credentialWithLink( + email: String, + emailLink: String + ): AuthCredential = AuthCredential(com.google.firebase.auth.EmailAuthProvider.getCredentialWithLink(email, emailLink)) +} + +actual object FacebookAuthProvider { + actual fun credential(accessToken: String): AuthCredential = AuthCredential(com.google.firebase.auth.FacebookAuthProvider.getCredential(accessToken)) +} + +actual object GithubAuthProvider { + actual fun credential(token: String): AuthCredential = AuthCredential(com.google.firebase.auth.GithubAuthProvider.getCredential(token)) +} + +actual object GoogleAuthProvider { + actual fun credential(idToken: String?, accessToken: String?): AuthCredential { + require(idToken != null || accessToken != null) { + "Both parameters are optional but at least one must be present." + } + return AuthCredential(com.google.firebase.auth.GoogleAuthProvider.getCredential(idToken, accessToken)) + } +} + +actual class OAuthProvider(val android: com.google.firebase.auth.OAuthProvider) { + + actual constructor( + provider: String, + scopes: List, + customParameters: Map, + auth: FirebaseAuth + ) : this( + com.google.firebase.auth.OAuthProvider + .newBuilder(provider, auth.android) + .setScopes(scopes) + .addCustomParameters(customParameters) + .build() + ) + + actual companion object { + actual fun credential(providerId: String, accessToken: String?, idToken: String?, rawNonce: String?): OAuthCredential { + val builder = OAuthProvider.newCredentialBuilder(providerId) + accessToken?.let { builder.setAccessToken(it) } + idToken?.let { builder.setIdToken(it) } + rawNonce?.let { builder.setIdTokenWithRawNonce(idToken!!, it) } + return OAuthCredential(builder.build() as com.google.firebase.auth.OAuthCredential) + } + } +} + +actual class PhoneAuthProvider(val android: com.google.firebase.auth.PhoneAuthProvider) { + + actual constructor(auth: FirebaseAuth) : this(com.google.firebase.auth.PhoneAuthProvider.getInstance(auth.android)) + + actual fun credential(verificationId: String, smsCode: String): PhoneAuthCredential = PhoneAuthCredential(com.google.firebase.auth.PhoneAuthProvider.getCredential(verificationId, smsCode)) + + actual suspend fun verifyPhoneNumber(phoneNumber: String, verificationProvider: PhoneVerificationProvider): AuthCredential = coroutineScope { + val response = CompletableDeferred>() + val callback = object : + PhoneAuthProvider.OnVerificationStateChangedCallbacks() { + + override fun onCodeSent(verificationId: String, forceResending: PhoneAuthProvider.ForceResendingToken) { + verificationProvider.codeSent { + android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, this, forceResending) + } + } + + override fun onCodeAutoRetrievalTimeOut(verificationId: String) { + launch { + val code = verificationProvider.getVerificationCode() + try { + response.complete(Result.success(credential(verificationId, code))) + } catch (e: Exception) { + response.complete(Result.failure(e)) + } + } + } + + override fun onVerificationCompleted(credential: com.google.firebase.auth.PhoneAuthCredential) { + response.complete(Result.success(AuthCredential(credential))) + } + + override fun onVerificationFailed(error: FirebaseException) { + response.complete(Result.failure(error)) + } + + } + android.verifyPhoneNumber(phoneNumber, verificationProvider.timeout, verificationProvider.unit, verificationProvider.activity, callback) + + response.await().getOrThrow() + } +} + +actual interface PhoneVerificationProvider { + val activity: Activity + val timeout: Long + val unit: TimeUnit + fun codeSent(triggerResend: (Unit) -> Unit) + suspend fun getVerificationCode(): String +} + +actual object TwitterAuthProvider { + actual fun credential(token: String, secret: String): AuthCredential = AuthCredential(com.google.firebase.auth.TwitterAuthProvider.getCredential(token, secret)) +} diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt new file mode 100644 index 000000000..84b216a4d --- /dev/null +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/multifactor.kt @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +package dev.gitlive.firebase.auth + +import kotlinx.coroutines.tasks.await + +actual class MultiFactor(val android: com.google.firebase.auth.MultiFactor) { + actual val enrolledFactors: List + get() = android.enrolledFactors.map { MultiFactorInfo(it) } + actual suspend fun enroll(multiFactorAssertion: MultiFactorAssertion, displayName: String?) = android.enroll(multiFactorAssertion.android, displayName).await().run { Unit } + actual suspend fun getSession(): MultiFactorSession = MultiFactorSession(android.session.await()) + actual suspend fun unenroll(multiFactorInfo: MultiFactorInfo) = android.unenroll(multiFactorInfo.android).await().run { Unit } + actual suspend fun unenroll(factorUid: String) = android.unenroll(factorUid).await().run { Unit } +} + +actual class MultiFactorInfo(val android: com.google.firebase.auth.MultiFactorInfo) { + actual val displayName: String? + get() = android.displayName + actual val enrollmentTime: Double + get() = android.enrollmentTimestamp.toDouble() + actual val factorId: String + get() = android.factorId + actual val uid: String + get() = android.uid +} + +actual class MultiFactorAssertion(val android: com.google.firebase.auth.MultiFactorAssertion) { + actual val factorId: String + get() = android.factorId +} + +actual class MultiFactorSession(val android: com.google.firebase.auth.MultiFactorSession) + +actual class MultiFactorResolver(val android: com.google.firebase.auth.MultiFactorResolver) { + actual val auth: FirebaseAuth = FirebaseAuth(android.firebaseAuth) + actual val hints: List = android.hints.map { MultiFactorInfo(it) } + actual val session: MultiFactorSession = MultiFactorSession(android.session) + + actual suspend fun resolveSignIn(assertion: MultiFactorAssertion): AuthResult = AuthResult(android.resolveSignIn(assertion.android).await()) +} diff --git a/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt new file mode 100644 index 000000000..ba7c7bb64 --- /dev/null +++ b/firebase-auth/src/jvmMain/kotlin/dev/gitlive/firebase/auth/user.kt @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */ + +package dev.gitlive.firebase.auth + +import android.net.Uri +import com.google.firebase.auth.UserProfileChangeRequest +import kotlinx.coroutines.tasks.await + +actual class FirebaseUser internal constructor(val android: com.google.firebase.auth.FirebaseUser) { + actual val uid: String + get() = android.uid + actual val displayName: String? + get() = android.displayName + actual val email: String? + get() = android.email + actual val phoneNumber: String? + get() = android.phoneNumber + actual val photoURL: String? + get() = android.photoUrl?.toString() + actual val isAnonymous: Boolean + get() = android.isAnonymous + actual val isEmailVerified: Boolean + get() = android.isEmailVerified + actual val metaData: UserMetaData? + get() = android.metadata?.let{ UserMetaData(it) } + actual val multiFactor: MultiFactor + get() = MultiFactor(android.multiFactor) + actual val providerData: List + get() = android.providerData.map { UserInfo(it) } + actual val providerId: String + get() = android.providerId + actual suspend fun delete() = android.delete().await().run { Unit } + actual suspend fun reload() = android.reload().await().run { Unit } + actual suspend fun getIdToken(forceRefresh: Boolean): String? = android.getIdToken(forceRefresh).await().token + actual suspend fun getIdTokenResult(forceRefresh: Boolean): AuthTokenResult = android.getIdToken(forceRefresh).await().run { AuthTokenResult(this) } + actual suspend fun linkWithCredential(credential: AuthCredential): AuthResult = AuthResult(android.linkWithCredential(credential.android).await()) + actual suspend fun reauthenticate(credential: AuthCredential) = android.reauthenticate(credential.android).await().run { Unit } + actual suspend fun reauthenticateAndRetrieveData(credential: AuthCredential): AuthResult = AuthResult(android.reauthenticateAndRetrieveData(credential.android).await()) + actual suspend fun sendEmailVerification(actionCodeSettings: ActionCodeSettings?) { + val request = actionCodeSettings?.let { android.sendEmailVerification(it.toAndroid()) } ?: android.sendEmailVerification() + request.await() + } + actual suspend fun unlink(provider: String): FirebaseUser? = android.unlink(provider).await().user?.let { FirebaseUser(it) } + actual suspend fun updateEmail(email: String) = android.updateEmail(email).await().run { Unit } + actual suspend fun updatePassword(password: String) = android.updatePassword(password).await().run { Unit } + actual suspend fun updatePhoneNumber(credential: PhoneAuthCredential) = android.updatePhoneNumber(credential.android).await().run { Unit } + actual suspend fun updateProfile(displayName: String?, photoUrl: String?) { + val request = UserProfileChangeRequest.Builder() + .apply { if(displayName !== UNCHANGED) setDisplayName(displayName) } + .apply { if(photoUrl !== UNCHANGED) setPhotoUri(photoUrl?.let { Uri.parse(it) }) } + .build() + android.updateProfile(request).await() + } + actual suspend fun verifyBeforeUpdateEmail(newEmail: String, actionCodeSettings: ActionCodeSettings?) = + android.verifyBeforeUpdateEmail(newEmail, actionCodeSettings?.toAndroid()).await().run { Unit } +} + +actual class UserInfo(val android: com.google.firebase.auth.UserInfo) { + actual val displayName: String? + get() = android.displayName + actual val email: String? + get() = android.email + actual val phoneNumber: String? + get() = android.phoneNumber + actual val photoURL: String? + get() = android.photoUrl?.toString() + actual val providerId: String + get() = android.providerId + actual val uid: String + get() = android.uid +} + +actual class UserMetaData(val android: com.google.firebase.auth.FirebaseUserMetadata) { + actual val creationTime: Double? + get() = android.creationTimestamp.toDouble() + actual val lastSignInTime: Double? + get() = android.lastSignInTimestamp.toDouble() +} diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index f769f17c8..1d537e76b 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -87,7 +87,7 @@ kotlin { } noPodspec() pod("FirebaseRemoteConfig") { - version = "10.9.0" + version = "10.15.0" } } } diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index 7203f7cd2..672167d0b 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -74,7 +74,7 @@ kotlin { } noPodspec() pod("FirebaseCrashlytics") { - version = "10.9.0" + version = "10.15.0" } } } @@ -117,7 +117,6 @@ kotlin { } // getByName("jvmMain") { -// kotlin.srcDir("src/androidMain/kotlin") // } if (supportIosTarget) { diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 0caeb8a05..2e2e81a0a 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -78,7 +78,7 @@ kotlin { } noPodspec() pod("FirebaseDatabase") { - version = "10.9.0" + version = "10.15.0" } } } diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index d9d5527fb..e93b57755 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -76,7 +76,7 @@ kotlin { } noPodspec() pod("FirebaseFirestore") { - version = "10.9.0" + version = "10.15.0" } } } diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 790841a1f..56aa16403 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -59,7 +59,7 @@ kotlin { } noPodspec() pod("FirebaseFunctions") { - version = "10.9.0" + version = "10.15.0" } } } diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index 0bc84a454..35d2f6d6e 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -72,7 +72,7 @@ kotlin { } noPodspec() pod("FirebaseInstallations") { - version = "10.9.0" + version = "10.15.0" } } } diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index 6a5660233..c5b685276 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -74,7 +74,7 @@ kotlin { } noPodspec() pod("FirebasePerformance") { - version = "10.9.0" + version = "10.15.0" } } } diff --git a/firebase-storage/build.gradle.kts b/firebase-storage/build.gradle.kts index ae9a8ddf7..e44de3539 100644 --- a/firebase-storage/build.gradle.kts +++ b/firebase-storage/build.gradle.kts @@ -73,7 +73,7 @@ kotlin { } noPodspec() pod("FirebaseStorage") { - version = "10.9.0" + version = "10.15.0" } } } diff --git a/gradle.properties b/gradle.properties index 071162885..8060b5827 100644 --- a/gradle.properties +++ b/gradle.properties @@ -66,6 +66,6 @@ gradlePluginVersion=8.1.1 kotlinVersion=1.9.10 coroutinesVersion=1.7.3 serializationVersion=1.6.0 -firebaseBoMVersion=32.0.0 +firebaseBoMVersion=32.2.3 apiVersion=1.8 -languageVersion=1.8 +languageVersion=1.9 From 8625a2737683f5c284f735994119898fdf6a26b0 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 19 Sep 2023 14:56:30 +0200 Subject: [PATCH 12/29] Cleanup/test fixes --- build.gradle.kts | 10 +++------- firebase-app/build.gradle.kts | 7 ++++++- .../kotlin/dev/gitlive/firebase/firebase.kt | 3 ++- .../kotlin/dev/gitlive/firebase/firebase.kt | 2 +- .../iosTest/kotlin/dev/gitlive/firebase/firebase.kt | 3 ++- .../jsTest/kotlin/dev/gitlive/firebase/firebase.kt | 3 ++- .../jvmTest/kotlin/dev/gitlive/firebase/firebase.kt | 2 ++ firebase-auth/build.gradle.kts | 6 ++++++ .../kotlin/dev/gitlive/firebase/auth/auth.kt | 3 ++- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 +- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 3 ++- .../jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt | 3 ++- firebase-common/build.gradle.kts | 8 +++++++- firebase-config/build.gradle.kts | 5 +++++ .../gitlive/firebase/remoteconfig/RemoteConfig.kt | 3 ++- .../firebase/remoteconfig/FirebaseRemoteConfig.kt | 2 +- .../gitlive/firebase/remoteconfig/RemoteConfig.kt | 3 ++- .../firebase/remoteconfig/FirebaseRemoteConfig.kt | 3 ++- .../gitlive/firebase/remoteconfig/RemoteConfig.kt | 2 ++ firebase-crashlytics/build.gradle.kts | 5 +++++ .../dev/gitlive/firebase/crashlytics/crashlytics.kt | 3 ++- .../dev/gitlive/firebase/crashlytics/crashlytics.kt | 2 +- .../dev/gitlive/firebase/crashlytics/crashlytics.kt | 3 ++- firebase-database/build.gradle.kts | 13 +++++++------ .../dev/gitlive/firebase/database/database.kt | 3 ++- .../dev/gitlive/firebase/database/database.kt | 2 +- .../dev/gitlive/firebase/database/database.kt | 3 ++- .../dev/gitlive/firebase/database/database.kt | 3 ++- .../dev/gitlive/firebase/database/database.kt | 2 ++ firebase-firestore/build.gradle.kts | 7 +++++++ .../dev/gitlive/firebase/firestore/firestore.kt | 3 ++- .../dev/gitlive/firebase/firestore/firestore.kt | 2 +- .../dev/gitlive/firebase/firestore/firestore.kt | 3 ++- .../dev/gitlive/firebase/firestore/firestore.kt | 3 ++- .../dev/gitlive/firebase/firestore/firestore.kt | 2 ++ firebase-functions/build.gradle.kts | 6 ++++++ firebase-installations/build.gradle.kts | 6 ++++++ firebase-perf/build.gradle.kts | 5 +++++ .../dev/gitlive/firebase/perf/metrics/Trace.kt | 2 +- .../kotlin/dev/gitlive/firebase/perf/performance.kt | 3 ++- .../kotlin/dev/gitlive/firebase/perf/performance.kt | 2 +- .../kotlin/dev/gitlive/firebase/perf/performance.kt | 3 ++- .../kotlin/dev/gitlive/firebase/perf/performance.kt | 3 ++- .../kotlin/dev/gitlive/firebase/perf/performance.kt | 2 ++ firebase-storage/build.gradle.kts | 11 ++++++++++- .../kotlin/dev/gitlive/firebase/storage/storage.kt | 4 +++- .../kotlin/dev/gitlive/firebase/storage/storage.kt | 2 ++ .../kotlin/dev/gitlive/firebase/storage/storage.kt | 2 ++ .../kotlin/dev/gitlive/firebase/storage/storage.kt | 3 +++ .../kotlin/dev/gitlive/firebase/storage/storage.kt | 5 ++++- .../kotlin/dev/gitlive/firebase/storage/storage.kt | 5 ++++- test-utils/build.gradle.kts | 5 +++++ 52 files changed, 154 insertions(+), 47 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 626d63510..f2ebe61b4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -113,7 +113,8 @@ subprojects { "commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") "androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") "androidMainImplementation"(platform("com.google.firebase:firebase-bom:$firebaseBoMVersion")) - "commonTestImplementation"(kotlin("test")) + "commonTestImplementation"(kotlin("test-common")) + "commonTestImplementation"(kotlin("test-annotations-common")) "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") if (this@afterEvaluate.name != "firebase-crashlytics") { @@ -126,6 +127,7 @@ subprojects { "jvmTestImplementation"("junit:junit:4.13.2") } "androidInstrumentedTestImplementation"(kotlin("test-junit")) + "androidUnitTestImplementation"(kotlin("test-junit")) "androidInstrumentedTestImplementation"("junit:junit:4.13.2") "androidInstrumentedTestImplementation"("androidx.test:core:1.5.0") "androidInstrumentedTestImplementation"("androidx.test.ext:junit:1.1.5") @@ -133,12 +135,6 @@ subprojects { } } - // Workaround for setting kotlinOptions.jvmTarget - // See https://youtrack.jetbrains.com/issue/KT-55947/Unable-to-set-kapt-jvm-target-version - tasks.withType().configureEach { - kotlinOptions.jvmTarget = "11" - } - if (skipPublishing) return@subprojects apply(plugin = "maven-publish") diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index 8e105180f..f420c7771 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -46,8 +46,13 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { - androidTarget() { + androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { diff --git a/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt index 0f4a8fbe3..5af3ac4f7 100644 --- a/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -10,4 +10,5 @@ import androidx.test.platform.app.InstrumentationRegistry actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt index bf27bee32..b13b1fa24 100644 --- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -4,7 +4,7 @@ import kotlin.test.Test expect val context: Any expect fun runTest(test: suspend () -> Unit) -expect annotation class IgnoreForAndroidUnitTest constructor() +expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseAppTest { diff --git a/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt index fbb904e83..be761559f 100644 --- a/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -21,4 +21,5 @@ actual fun runTest(test: suspend () -> Unit) = runBlocking { testRun.await() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt index 8e5825527..9085cc728 100644 --- a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -12,4 +12,5 @@ actual fun runTest(test: suspend () -> Unit) { runTest { test() } } -actual annotation class IgnoreForAndroidUnitTest() \ No newline at end of file +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest \ No newline at end of file diff --git a/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt index c644686f9..5fe48b793 100644 --- a/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -8,3 +8,5 @@ package dev.gitlive.firebase actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index 839907c4b..e55bb0e77 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -62,6 +62,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } if (supportIosTarget) { @@ -120,6 +125,7 @@ kotlin { optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") if (name.lowercase().contains("ios")) { optIn("kotlinx.cinterop.ExperimentalForeignApi") + optIn("kotlinx.cinterop.BetaInteropApi") } } } diff --git a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 986547b95..57d5b9f1e 100644 --- a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -13,4 +13,5 @@ actual val context: Any = InstrumentationRegistry.getInstrumentation().targetCon actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 2ec143715..9dd68b31a 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -12,7 +12,7 @@ import kotlin.test.* expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend () -> Unit): TestResult -expect annotation class IgnoreForAndroidUnitTest constructor() +expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseAuthTest { diff --git a/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt index a5caaeea1..717c94d59 100644 --- a/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -23,4 +23,5 @@ actual fun runTest(test: suspend () -> Unit) = runBlocking { testRun.await() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt index c33341a74..e9442a26d 100644 --- a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -11,4 +11,5 @@ actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index 4f5c64b0b..2c33fb0ab 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -31,6 +31,7 @@ android { isIncludeAndroidResources = true } } + packaging { resources.pickFirsts.add("META-INF/kotlinx-serialization-core.kotlin_module") resources.pickFirsts.add("META-INF/AL2.0") @@ -45,6 +46,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { @@ -140,7 +146,7 @@ kotlin { getByName("jsMain") { dependencies { - api(npm("firebase", "9.21.0")) + api(npm("firebase", "10.4.0")) } } diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index 1d537e76b..4290f8cbd 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -62,6 +62,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { diff --git a/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index 80741860d..d7ab8f5cd 100644 --- a/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -11,4 +11,5 @@ actual val context: Any = InstrumentationRegistry.getInstrumentation().targetCon actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 56f44e446..2e54c1d13 100644 --- a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -17,7 +17,7 @@ import kotlin.test.assertEquals expect val context: Any expect fun runTest(test: suspend () -> Unit): TestResult -expect annotation class IgnoreForAndroidUnitTest constructor() +expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseRemoteConfigTest { diff --git a/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index 56b1df440..c402c6bf2 100644 --- a/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -21,4 +21,5 @@ actual fun runTest(test: suspend () -> Unit) = runBlocking { testRun.await() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 31c53ea67..3f5305c3f 100644 --- a/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -5,4 +5,5 @@ actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index ffd093829..efb50bde7 100644 --- a/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -8,3 +8,5 @@ package dev.gitlive.firebase.remoteconfig actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index 672167d0b..4e7e4587f 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -49,6 +49,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } // jvm { diff --git a/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 8fab649f6..a842a208c 100644 --- a/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -14,4 +14,5 @@ actual val context: Any = InstrumentationRegistry.getInstrumentation().targetCon actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index e85221cd8..78188aebd 100644 --- a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -17,7 +17,7 @@ import kotlin.test.assertFalse expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult -expect annotation class IgnoreForAndroidUnitTest constructor() +expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseCrashlyticsTest { diff --git a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index c4e13e787..c3ca41c03 100644 --- a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -23,4 +23,5 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { testRun.await() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 2e2e81a0a..acdc0f213 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -25,6 +25,7 @@ android { defaultConfig { minSdk = minSdkVersion + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } compileOptions { @@ -53,6 +54,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { @@ -131,6 +137,7 @@ kotlin { implementation(project(":test-utils")) } } + getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } @@ -155,12 +162,6 @@ kotlin { val iosSimulatorArm64Test by getting iosSimulatorArm64Test.dependsOn(iosTest) } - - getByName("jsMain") { - dependencies { - api(npm("firebase", "9.21.0")) - } - } } } diff --git a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt index 64c797106..03cd9f62e 100644 --- a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -13,4 +13,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt index 54e85dd14..2a339c495 100644 --- a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -9,7 +9,7 @@ import kotlin.test.* expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend () -> Unit): TestResult -expect annotation class IgnoreForAndroidUnitTest constructor() +expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseDatabaseTest { diff --git a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt index 427fb1edc..f6bc3beb6 100644 --- a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -23,4 +23,5 @@ actual fun runTest(test: suspend () -> Unit) = runBlocking { testRun.await() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt index fecffeb36..800bfea47 100644 --- a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -19,7 +19,8 @@ actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest private suspend fun awaitDatabaseConnection() = withContext(Dispatchers.Default) { withTimeout(5.seconds) { diff --git a/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt index 200bcec5d..a9757da98 100644 --- a/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -11,3 +11,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index e93b57755..70f482489 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -51,6 +51,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { @@ -113,8 +118,10 @@ kotlin { progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.InternalSerializationApi") + optIn("kotlinx.serialization.ExperimentalSerializationApi") if (name.lowercase().contains("ios")) { optIn("kotlinx.cinterop.ExperimentalForeignApi") + optIn("kotlinx.cinterop.BetaInteropApi") } } } diff --git a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 5c099bd29..aeb178a5f 100644 --- a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -15,4 +15,5 @@ actual val context: Any = InstrumentationRegistry.getInstrumentation().targetCon actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 89886cc65..b2536b54d 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -30,7 +30,7 @@ import kotlin.test.assertTrue expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult -expect annotation class IgnoreForAndroidUnitTest constructor() +expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseFirestoreTest { diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 66023dd84..847d16ead 100644 --- a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -23,4 +23,5 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { testRun.await() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 9c7e1cd13..a80fee0ff 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -13,4 +13,5 @@ actual val context: Any = Unit actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 297bb7f87..dfed2844a 100644 --- a/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -13,3 +13,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 56aa16403..3d4902db9 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -19,6 +19,7 @@ android { defaultConfig { minSdk = minSdkVersion + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } compileOptions { @@ -47,6 +48,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } if (supportIosTarget) { diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index 35d2f6d6e..858a4bf9b 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -19,6 +19,7 @@ android { defaultConfig { minSdk = minSdkVersion + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } compileOptions { @@ -47,6 +48,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index c5b685276..fd57f9bc5 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -49,6 +49,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 9580d0e80..a99532882 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -51,7 +51,7 @@ class AndroidTraceTest { assertEquals(3, attributes.size) - attributes.onEachIndexed { index, entry -> + attributes.onEachIndexed { _, entry -> assertEquals(entry.key.last(), entry.value.last()) } diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 4775cf053..9f588d89c 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -14,4 +14,5 @@ actual val context: Any = InstrumentationRegistry.getInstrumentation().targetCon actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 868723f06..053aefb1d 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -15,7 +15,7 @@ import kotlin.test.* expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult -expect annotation class IgnoreForAndroidUnitTest constructor() +expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebasePerformanceTest { diff --git a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 32eb93d2c..23657fe4c 100644 --- a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -23,4 +23,5 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { testRun.await() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 6ede90d03..0b0d708ba 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -17,7 +17,8 @@ actual val context: Any = Unit actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } -actual annotation class IgnoreForAndroidUnitTest() +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest class JsPerformanceTest { diff --git a/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 10d81bdfb..8fcbdfbd0 100644 --- a/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -12,3 +12,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/build.gradle.kts b/firebase-storage/build.gradle.kts index e44de3539..bd183e6e5 100644 --- a/firebase-storage/build.gradle.kts +++ b/firebase-storage/build.gradle.kts @@ -48,6 +48,11 @@ kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { @@ -118,7 +123,11 @@ kotlin { } } - val commonTest by getting + val commonTest by getting { + dependencies { + implementation(project(":test-utils")) + } + } getByName("androidMain") { dependencies { diff --git a/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt index e322394fb..f726d3c13 100644 --- a/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -13,4 +13,6 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } \ No newline at end of file +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 881533b47..94430eadc 100644 --- a/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -2,9 +2,11 @@ package dev.gitlive.firebase.storage import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.runBlocking +import org.junit.Ignore actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } +actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt index f5f0d0134..895c2f586 100644 --- a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -14,7 +14,9 @@ import kotlin.test.BeforeTest expect val emulatorHost: String expect val context: Any expect fun runTest(test: suspend CoroutineScope.() -> Unit) +expect annotation class IgnoreForAndroidUnitTest() +@IgnoreForAndroidUnitTest class FirebaseStorageTest { @BeforeTest diff --git a/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 8e7535b8c..164a0fecc 100644 --- a/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -30,3 +30,6 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { } testRun.await() } + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt index dd52a8147..a5326b1a9 100644 --- a/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -12,4 +12,7 @@ actual val context: Any = Unit actual fun runTest(test: suspend CoroutineScope.() -> Unit) { kotlinx.coroutines.test.runTest { test() } -} \ No newline at end of file +} + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt index e4fb62337..c358bc6e7 100644 --- a/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -12,4 +12,7 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } \ No newline at end of file +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } + +@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) +actual annotation class IgnoreForAndroidUnitTest diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 7a89b65ef..285cfdcac 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -42,6 +42,11 @@ android { kotlin { androidTarget { publishAllLibraryVariants() + compilations.configureEach { + kotlinOptions { + jvmTarget = "11" + } + } } jvm { From 1894f16a559d24aaeb8eb2427183a8b86d58016c Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 26 Sep 2023 11:51:33 +0200 Subject: [PATCH 13/29] Fixing tests --- .github/workflows/publish.yml | 2 +- .github/workflows/pull_request.yml | 2 +- firebase-firestore/build.gradle.kts | 8 ++++++++ .../gitlive/firebase/firestore/firestore.kt | 2 +- gradle.properties | 20 +++++++++---------- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ad1cdaaca..4f2821da7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -15,7 +15,7 @@ env: jobs: build: - runs-on: macos-latest + runs-on: macos-13 steps: - uses: actions/checkout@v3 - name: Set up JDK diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ec89583f8..ea674aa90 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,7 +9,7 @@ on: jobs: build: - runs-on: macos-latest + runs-on: macos-13 strategy: matrix: api-level: [ 33 ] diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 70f482489..7b977a883 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -93,6 +93,10 @@ kotlin { Action { useKarma { useChromeHeadless() + // Explicitly specify Mocha here since it seems to be throwing random errors otherwise + useMocha { + timeout = "15s" + } } } ) @@ -102,6 +106,10 @@ kotlin { Action { useKarma { useChromeHeadless() + // Explicitly specify Mocha here since it seems to be throwing random errors otherwise + useMocha { + timeout = "15s" + } } } ) diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index b2536b54d..3156416af 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -50,7 +50,7 @@ class FirebaseFirestoreTest { ) @BeforeTest - fun initializeFirebase() = runTest { + fun initializeFirebase() { Firebase .takeIf { Firebase.apps(context).isEmpty() } ?.apply { diff --git a/gradle.properties b/gradle.properties index 8060b5827..b87bfa20f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,7 +3,7 @@ android.useAndroidX=true kapt.use.worker.api=true kotlin.code.style=official kotlin.incremental.multiplatform=true -kotlin.js.compiler=both +kotlin.js.compiler=ir kotlin.js.experimental.generateKotlinExternals=false #kotlin.mpp.enableCompatibilityMetadataVariant=true #kotlin.mpp.enableGranularSourceSetsMetadata=true @@ -26,15 +26,15 @@ skipIosTarget=false firebase-app.skipIosTests=false # We are skipping auth ios tests due to an issue with keychain and simulator. firebase-auth.skipIosTests=true -firebase-common.skipIosTests=true -firebase-config.skipIosTests=true -firebase-database.skipIosTests=true -firebase-firestore.skipIosTests=true -firebase-functions.skipIosTests=true -firebase-installations.skipIosTests=true -firebase-perf.skipIosTests=true -firebase-crashlytics.skipIosTests=true -firebase-storage.skipIosTests=true +firebase-common.skipIosTests=false +firebase-config.skipIosTests=false +firebase-database.skipIosTests=false +firebase-firestore.skipIosTests=false +firebase-functions.skipIosTests=false +firebase-installations.skipIosTests=false +firebase-perf.skipIosTests=false +firebase-crashlytics.skipIosTests=false +firebase-storage.skipIosTests=false # We can have the functionality to skip js tests, due to compatibility issues. firebase-app.skipJsTests=false From 4097460b4ad1fccdafddae07d2b28df1d9e715a7 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 26 Sep 2023 13:33:21 +0200 Subject: [PATCH 14/29] Try raising timeout to something high --- firebase-firestore/build.gradle.kts | 4 ++-- firebase-firestore/karma.config.d/karma.conf.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 7b977a883..976c5bc98 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -95,7 +95,7 @@ kotlin { useChromeHeadless() // Explicitly specify Mocha here since it seems to be throwing random errors otherwise useMocha { - timeout = "15s" + timeout = "180s" } } } @@ -108,7 +108,7 @@ kotlin { useChromeHeadless() // Explicitly specify Mocha here since it seems to be throwing random errors otherwise useMocha { - timeout = "15s" + timeout = "180s" } } } diff --git a/firebase-firestore/karma.config.d/karma.conf.js b/firebase-firestore/karma.config.d/karma.conf.js index e2301eddd..54aae87a9 100644 --- a/firebase-firestore/karma.config.d/karma.conf.js +++ b/firebase-firestore/karma.config.d/karma.conf.js @@ -2,7 +2,7 @@ config.set({ client: { mocha: { - timeout: 5000 + timeout: 1800000 } }, }); From ca18a497effe3614e3b45c751a086d1d408c0959 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 26 Sep 2023 15:00:52 +0200 Subject: [PATCH 15/29] Remove assemble to speed up CI for js tests & make runTest > 10sec --- .github/workflows/pull_request.yml | 2 -- .../jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index ea674aa90..0750bbd71 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -39,8 +39,6 @@ jobs: run: npm install -g firebase-tools - name: Start Firebase emulator run: "firebase emulators:start --config=./test/firebase.json &" - - name: Assemble - run: ./gradlew assemble - name: Run JS Tests run: ./gradlew cleanTest jsTest - name: Upload JS test artifact diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index a80fee0ff..3c75398d3 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -6,12 +6,13 @@ package dev.gitlive.firebase.firestore import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.runTest +import kotlin.time.Duration.Companion.minutes actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runTest { test() } +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runTest(timeout = 5.minutes) { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest From 6755ff9df10846b3aadbc4b8a9d16e92cb736a39 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 26 Sep 2023 15:11:43 +0200 Subject: [PATCH 16/29] More timeouts --- .../src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt | 3 ++- firebase-auth/karma.config.d/karma.conf.js | 2 +- .../src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt | 4 +++- .../dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt | 4 +++- firebase-database/karma.config.d/karma.conf.js | 2 +- .../jsTest/kotlin/dev/gitlive/firebase/database/database.kt | 3 ++- .../jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt | 3 ++- .../src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt | 3 ++- 8 files changed, 16 insertions(+), 8 deletions(-) diff --git a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt index 9085cc728..44feee6d4 100644 --- a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -5,11 +5,12 @@ package dev.gitlive.firebase import kotlinx.coroutines.test.runTest +import kotlin.time.Duration.Companion.minutes actual val context: Any = Unit actual fun runTest(test: suspend () -> Unit) { - runTest { test() } + runTest(timeout = 5.minutes) { test() } } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) diff --git a/firebase-auth/karma.config.d/karma.conf.js b/firebase-auth/karma.config.d/karma.conf.js index e2301eddd..88b35fa20 100644 --- a/firebase-auth/karma.config.d/karma.conf.js +++ b/firebase-auth/karma.config.d/karma.conf.js @@ -2,7 +2,7 @@ config.set({ client: { mocha: { - timeout: 5000 + timeout: 180000 } }, }); diff --git a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt index e9442a26d..6a5057f49 100644 --- a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -4,12 +4,14 @@ package dev.gitlive.firebase.auth +import kotlin.time.Duration.Companion.minutes + actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } +actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 3f5305c3f..31ed60491 100644 --- a/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -1,9 +1,11 @@ package dev.gitlive.firebase.remoteconfig +import kotlin.time.Duration.Companion.minutes + actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } +actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/karma.config.d/karma.conf.js b/firebase-database/karma.config.d/karma.conf.js index e2301eddd..88b35fa20 100644 --- a/firebase-database/karma.config.d/karma.conf.js +++ b/firebase-database/karma.config.d/karma.conf.js @@ -2,7 +2,7 @@ config.set({ client: { mocha: { - timeout: 5000 + timeout: 180000 } }, }); diff --git a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt index 800bfea47..dbb582e69 100644 --- a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -8,12 +8,13 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first import kotlinx.coroutines.withContext import kotlinx.coroutines.withTimeout +import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds actual val emulatorHost: String = "127.0.0.1" // in JS tests connection is refused if we use localhost actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { +actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { // in JS tests we need to wait for the database to be connected awaitDatabaseConnection() test() diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 0b0d708ba..1712a7beb 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -10,12 +10,13 @@ import dev.gitlive.firebase.apps import dev.gitlive.firebase.initialize import kotlinx.coroutines.CoroutineScope import kotlin.test.* +import kotlin.time.Duration.Companion.minutes actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt index a5326b1a9..96e9365c3 100644 --- a/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -5,13 +5,14 @@ package dev.gitlive.firebase.storage import kotlinx.coroutines.CoroutineScope +import kotlin.time.Duration.Companion.minutes actual val emulatorHost: String = "127.0.0.1" actual val context: Any = Unit actual fun runTest(test: suspend CoroutineScope.() -> Unit) { - kotlinx.coroutines.test.runTest { test() } + kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) From 90d08cf40836e77b15eec2bcffac0e35e6a09e88 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 26 Sep 2023 16:30:14 +0200 Subject: [PATCH 17/29] Raise await DB connection --- .../src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt index dbb582e69..7102c1a8e 100644 --- a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -24,7 +24,7 @@ actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest(t actual annotation class IgnoreForAndroidUnitTest private suspend fun awaitDatabaseConnection() = withContext(Dispatchers.Default) { - withTimeout(5.seconds) { + withTimeout(2.minutes) { Firebase.database.reference(".info/connected").valueEvents.first { it.value() } } } From 267bfd14ae1af8ef1f033ae90cbb5cbd7a2bd393 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Wed, 27 Sep 2023 09:59:15 +0200 Subject: [PATCH 18/29] Raising min SDK from 19 to 23 This should be done because Android 14 (aka api 34) will only allow projects built with targetSDK >= 23 See https://developer.android.com/about/versions/14/behavior-changes-all#minimum-target-api-level --- build.gradle.kts | 4 ++-- firebase-app/package.json | 4 ++-- firebase-auth/package.json | 4 ++-- firebase-common/package.json | 2 +- firebase-config/package.json | 4 ++-- firebase-crashlytics/package.json | 4 ++-- firebase-database/package.json | 4 ++-- firebase-firestore/package.json | 4 ++-- firebase-functions/package.json | 4 ++-- firebase-installations/package.json | 4 ++-- firebase-perf/package.json | 4 ++-- firebase-storage/package.json | 4 ++-- 12 files changed, 23 insertions(+), 23 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f2ebe61b4..8f5edb200 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -29,8 +29,8 @@ buildscript { } } -val compileSdkVersion by extra(33) -val minSdkVersion by extra(19) +val compileSdkVersion by extra(34) +val minSdkVersion by extra(23) tasks { register("updateVersions") { diff --git a/firebase-app/package.json b/firebase-app/package.json index ad462e03f..b50a079b5 100644 --- a/firebase-app/package.json +++ b/firebase-app/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-app", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-app.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-common": "1.10.0", + "@gitlive/firebase-common": "1.10.1", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-auth/package.json b/firebase-auth/package.json index fe344e504..ca9c8c177 100644 --- a/firebase-auth/package.json +++ b/firebase-auth/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-auth", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-auth.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-common/package.json b/firebase-common/package.json index ad254de8f..7e9e38f26 100644 --- a/firebase-common/package.json +++ b/firebase-common/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-common", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-common.js", "scripts": { diff --git a/firebase-config/package.json b/firebase-config/package.json index 195116866..bac1afa9f 100644 --- a/firebase-config/package.json +++ b/firebase-config/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-config", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-config.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-crashlytics/package.json b/firebase-crashlytics/package.json index 1a32ade20..a2528a17f 100644 --- a/firebase-crashlytics/package.json +++ b/firebase-crashlytics/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-crashlytics", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-crashlytics.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-database/package.json b/firebase-database/package.json index 966515c71..c72c583fb 100644 --- a/firebase-database/package.json +++ b/firebase-database/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-database", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-database.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-firestore/package.json b/firebase-firestore/package.json index dd417f8b3..9ad0a0155 100644 --- a/firebase-firestore/package.json +++ b/firebase-firestore/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-firestore", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-firestore.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-functions/package.json b/firebase-functions/package.json index e0db81fe6..a11c484e1 100644 --- a/firebase-functions/package.json +++ b/firebase-functions/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-functions", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-functions.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-installations/package.json b/firebase-installations/package.json index 94aaac8c5..ecdc9e65a 100644 --- a/firebase-installations/package.json +++ b/firebase-installations/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-installations", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-installations.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-perf/package.json b/firebase-perf/package.json index ac32fe16c..29798b347 100644 --- a/firebase-perf/package.json +++ b/firebase-perf/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-perf", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-perf.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-storage/package.json b/firebase-storage/package.json index 6b757c5ec..b48bc7b14 100644 --- a/firebase-storage/package.json +++ b/firebase-storage/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-storage", - "version": "1.10.0", + "version": "1.10.1", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-storage.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.0", + "@gitlive/firebase-app": "1.10.1", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" From d018176ead2c81820328d4160f6913b1c64fcf64 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Wed, 27 Sep 2023 16:12:11 +0200 Subject: [PATCH 19/29] Fix for publishing --- build.gradle.kts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 8f5edb200..2364ca0ad 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -197,6 +197,10 @@ subprojects { } } + + tasks.withType(AbstractPublishToMaven::class.java).configureEach { + dependsOn(tasks.withType(Sign::class.java)) + } } tasks.withType { From d58c6b5eeead9e09ec48fcde4c1e5d581a9f58f3 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Wed, 27 Sep 2023 16:31:55 +0200 Subject: [PATCH 20/29] Raise pod versions --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2364ca0ad..0f1da272a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -197,7 +197,7 @@ subprojects { } } - + tasks.withType(AbstractPublishToMaven::class.java).configureEach { dependsOn(tasks.withType(Sign::class.java)) } From 4caba6bda109b0fe7b85401241bfc86513cea411 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Wed, 27 Sep 2023 17:36:13 +0200 Subject: [PATCH 21/29] Enforce tests to start with clean Firebase app This hopefully makes tests more stable (and more accurate --- .../commonTest/kotlin/dev/gitlive/firebase/firebase.kt | 7 +++++++ .../commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt | 7 +++++++ .../gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt | 3 +++ .../dev/gitlive/firebase/crashlytics/crashlytics.kt | 8 ++++++++ .../kotlin/dev/gitlive/firebase/database/database.kt | 7 +++++++ .../kotlin/dev/gitlive/firebase/firestore/firestore.kt | 8 ++++++++ .../kotlin/dev/gitlive/firebase/perf/performance.kt | 7 +++++++ .../kotlin/dev/gitlive/firebase/perf/performance.kt | 4 +++- 8 files changed, 50 insertions(+), 1 deletion(-) diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt index b13b1fa24..9809c0090 100644 --- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -1,6 +1,7 @@ package dev.gitlive.firebase import kotlin.test.Test +import kotlin.test.assertEquals expect val context: Any expect fun runTest(test: suspend () -> Unit) @@ -21,6 +22,12 @@ class FirebaseAppTest { gcmSenderId = "846484016111" ) ) + + assertEquals(1, Firebase.apps(context).size) + + Firebase.apps(context).forEach { + it.delete() + } } } \ No newline at end of file diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 9dd68b31a..3b6f5df77 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -37,6 +37,13 @@ class FirebaseAuthTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testSignInWithUsernameAndPassword() = runTest { val uid = getTestUid("test@test.com", "test123") diff --git a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 2e54c1d13..9d62b0253 100644 --- a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -50,6 +50,9 @@ class FirebaseRemoteConfigTest { @AfterTest fun tearDown() = runTest { Firebase.remoteConfig.reset() + Firebase.apps(context).forEach { + it.delete() + } } @Test diff --git a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 78188aebd..a50585bd0 100644 --- a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -10,6 +10,7 @@ import dev.gitlive.firebase.apps import dev.gitlive.firebase.initialize import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.TestResult +import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertFalse @@ -41,6 +42,13 @@ class FirebaseCrashlyticsTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testRecordException() = runTest { diff --git a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt index 2a339c495..14f921962 100644 --- a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -40,6 +40,13 @@ class FirebaseDatabaseTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testSetValue() = runTest { val testValue = "test" diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 3156416af..e7b0fd106 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -19,6 +19,7 @@ import kotlinx.coroutines.withContext import kotlinx.serialization.Serializable import kotlinx.serialization.builtins.nullable import kotlin.random.Random +import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals @@ -69,6 +70,13 @@ class FirebaseFirestoreTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testStringOrderBy() = runTest { setupFirestoreData() diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 053aefb1d..f2ef6ae2a 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -39,6 +39,13 @@ class FirebasePerformanceTest { } } + @AfterTest + fun deinitializeFirebase() { + Firebase.apps(context).forEach { + it.delete() + } + } + @Test fun testNewTrace() = runTest { diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 1712a7beb..8a71f4902 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -16,7 +16,9 @@ actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { + test() +} @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest From 4d3e7c551b1103876d5a1024e2cc4270856a7e4d Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Wed, 27 Sep 2023 20:15:10 +0200 Subject: [PATCH 22/29] Run on API 34 --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 0750bbd71..158b8ab6c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,7 +12,7 @@ jobs: runs-on: macos-13 strategy: matrix: - api-level: [ 33 ] + api-level: [ 34 ] steps: - uses: actions/checkout@v3 - name: Cocoapods cache From f3f693a4bcca797bd75e2f262d5c43a227263e3e Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Wed, 27 Sep 2023 23:21:53 +0200 Subject: [PATCH 23/29] Better test cleanup --- build.gradle.kts | 2 - .../kotlin/dev/gitlive/firebase/firebase.kt | 1 - .../kotlin/dev/gitlive/firebase/firebase.kt | 2 +- .../kotlin/dev/gitlive/firebase/firebase.kt | 2 - .../kotlin/dev/gitlive/firebase/firebase.kt | 2 +- .../kotlin/dev/gitlive/firebase/firebase.kt | 12 +-- .../kotlin/dev/gitlive/firebase/firebase.kt | 6 +- .../kotlin/dev/gitlive/firebase/firebase.kt | 15 ---- .../kotlin/dev/gitlive/firebase/firebase.kt | 2 +- .../kotlin/dev/gitlive/firebase/firebase.kt | 7 -- .../kotlin/dev/gitlive/firebase/firebase.kt | 1 - .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 - .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 - .../kotlin/dev/gitlive/firebase/auth/auth.kt | 64 ++++++------- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 15 ---- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 - .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 - .../firebase/remoteconfig/RemoteConfig.kt | 2 - .../firebase/remoteconfig/RemoteConfig.kt | 2 - .../remoteconfig/FirebaseRemoteConfig.kt | 45 ++++------ .../firebase/remoteconfig/RemoteConfig.kt | 15 ---- .../remoteconfig/FirebaseRemoteConfig.kt | 5 -- .../firebase/remoteconfig/RemoteConfig.kt | 1 - .../firebase/crashlytics/crashlytics.kt | 3 - .../firebase/crashlytics/crashlytics.kt | 3 - .../firebase/crashlytics/crashlytics.kt | 46 +++------- .../firebase/crashlytics/crashlytics.kt | 15 ---- .../dev/gitlive/firebase/database/database.kt | 2 - .../dev/gitlive/firebase/database/database.kt | 2 - .../dev/gitlive/firebase/database/database.kt | 64 ++++++------- .../dev/gitlive/firebase/database/database.kt | 15 ---- .../dev/gitlive/firebase/database/database.kt | 22 ----- .../dev/gitlive/firebase/database/database.kt | 1 - .../gitlive/firebase/firestore/firestore.kt | 4 - .../gitlive/firebase/firestore/firestore.kt | 2 - .../firebase/firestore/FieldValueTests.kt | 1 + .../firebase/firestore/GeoPointTests.kt | 1 + .../firebase/firestore/TimestampTests.kt | 1 + .../gitlive/firebase/firestore/firestore.kt | 90 +++++++++---------- .../gitlive/firebase/firestore/firestore.kt | 15 ---- .../gitlive/firebase/firestore/firestore.kt | 6 -- .../gitlive/firebase/firestore/firestore.kt | 4 - .../gitlive/firebase/perf/metrics/Trace.kt | 44 ++++----- .../dev/gitlive/firebase/perf/performance.kt | 3 - .../dev/gitlive/firebase/perf/performance.kt | 2 - .../gitlive/firebase/perf/metrics/Trace.kt | 39 ++++---- .../dev/gitlive/firebase/perf/performance.kt | 28 ++---- .../dev/gitlive/firebase/perf/performance.kt | 15 ---- .../gitlive/firebase/perf/metrics/Trace.kt | 32 ++++--- .../dev/gitlive/firebase/perf/performance.kt | 31 ++----- .../dev/gitlive/firebase/perf/performance.kt | 3 - .../dev/gitlive/firebase/storage/storage.kt | 3 - .../dev/gitlive/firebase/storage/storage.kt | 3 - .../dev/gitlive/firebase/storage/storage.kt | 28 +++--- .../dev/gitlive/firebase/storage/storage.kt | 23 ----- .../dev/gitlive/firebase/storage/storage.kt | 7 -- .../dev/gitlive/firebase/storage/storage.kt | 5 -- test-utils/build.gradle.kts | 4 + .../kotlin/dev/gitlive/firebase/TestUtils.kt | 7 ++ .../kotlin/dev/gitlive/firebase/TestUtils.kt | 17 ++++ .../kotlin/dev/gitlive/firebase/TestUtils.kt | 24 +++++ .../kotlin/dev/gitlive/firebase/TestUtils.kt | 8 ++ .../kotlin/dev/gitlive/firebase/TestUtils.kt | 17 ++++ 63 files changed, 309 insertions(+), 540 deletions(-) create mode 100644 test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt diff --git a/build.gradle.kts b/build.gradle.kts index 0f1da272a..dadd2db21 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -115,8 +115,6 @@ subprojects { "androidMainImplementation"(platform("com.google.firebase:firebase-bom:$firebaseBoMVersion")) "commonTestImplementation"(kotlin("test-common")) "commonTestImplementation"(kotlin("test-annotations-common")) - "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") - "commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") if (this@afterEvaluate.name != "firebase-crashlytics") { "jvmMainApi"("dev.gitlive:firebase-java-sdk:0.1.1") "jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") { diff --git a/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt index 5af3ac4f7..bdc3f7e6c 100644 --- a/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -9,6 +9,5 @@ import androidx.test.platform.app.InstrumentationRegistry actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt index 0527e2e92..6b43c3c07 100644 --- a/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -35,7 +35,7 @@ actual class FirebaseApp internal constructor(val android: com.google.firebase.F actual val options: FirebaseOptions get() = android.options.run { FirebaseOptions(applicationId, apiKey, databaseUrl, gaTrackingId, storageBucket, projectId) } - actual fun delete() = android.delete() + actual suspend fun delete() = android.delete() } actual fun Firebase.apps(context: Any?) = com.google.firebase.FirebaseApp.getApps(context as Context) diff --git a/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt index 11fc69adb..5785b8376 100644 --- a/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/androidUnitTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -9,8 +9,6 @@ import org.junit.Ignore actual val context: Any = "" -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } - // Tests are to be run on AndroidInstrumentedTests. // Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest // Therefore we just wont run them diff --git a/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt index 75e3df31d..a02e952c9 100644 --- a/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -19,7 +19,7 @@ object Firebase expect class FirebaseApp { val name: String val options: FirebaseOptions - fun delete() + suspend fun delete() } /** Returns the default firebase app instance. */ diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt index 9809c0090..568946990 100644 --- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -4,23 +4,15 @@ import kotlin.test.Test import kotlin.test.assertEquals expect val context: Any -expect fun runTest(test: suspend () -> Unit) expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseAppTest { @Test - fun testInitialize() { + fun testInitialize() = runTest { Firebase.initialize( context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + firebaseOptions ) assertEquals(1, Firebase.apps(context).size) diff --git a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt index c8488259f..e3074d2dc 100644 --- a/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/iosMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -33,7 +33,11 @@ actual class FirebaseApp internal constructor(val ios: FIRApp) { actual val options: FirebaseOptions get() = ios.options.run { FirebaseOptions(bundleID, APIKey!!, databaseURL!!, trackingID, storageBucket, projectID) } - actual fun delete() { } + actual suspend fun delete() { + val deleted = CompletableDeferred() + ios.deleteApp { deleted.complete(Unit) } + deleted.await() + } } actual fun Firebase.apps(context: Any?) = FIRApp.allApps() diff --git a/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt index be761559f..c56fadc7d 100644 --- a/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/iosTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -4,22 +4,7 @@ package dev.gitlive.firebase -import kotlinx.coroutines.* -import platform.Foundation.* - actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = runBlocking { - val testRun = MainScope().async { test() } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) - ) - yield() - } - testRun.await() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt index 6bffaa7be..ed7619ab9 100644 --- a/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsMain/kotlin/dev/gitlive/firebase/firebase.kt @@ -34,7 +34,7 @@ actual class FirebaseApp internal constructor(val js: JsFirebaseApp) { FirebaseOptions(appId, apiKey, databaseURL, gaTrackingId, storageBucket, projectId, messagingSenderId, authDomain) } - actual fun delete() { + actual suspend fun delete() { deleteApp(js) } } diff --git a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt index 44feee6d4..699d3b292 100644 --- a/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jsTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -4,14 +4,7 @@ package dev.gitlive.firebase -import kotlinx.coroutines.test.runTest -import kotlin.time.Duration.Companion.minutes - actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) { - runTest(timeout = 5.minutes) { test() } -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest \ No newline at end of file diff --git a/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt index 5fe48b793..4bdd21eac 100644 --- a/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/jvmTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -7,6 +7,5 @@ package dev.gitlive.firebase actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 57d5b9f1e..0d4d18e96 100644 --- a/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -11,7 +11,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt index bd4535ca0..68b090d67 100644 --- a/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/androidUnitTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -11,8 +11,6 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } - // Tests are to be run on AndroidInstrumentedTests. // Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest // Therefore we just wont run them diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 3b6f5df77..9adf6d569 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -5,40 +5,32 @@ package dev.gitlive.firebase.auth import dev.gitlive.firebase.* -import kotlinx.coroutines.test.TestResult import kotlin.random.Random import kotlin.test.* expect val emulatorHost: String expect val context: Any -expect fun runTest(test: suspend () -> Unit): TestResult expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseAuthTest { + lateinit var auth: FirebaseAuth + @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(context).isEmpty() } - ?.apply { - initialize( - context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - Firebase.auth.useEmulator(emulatorHost, 9099) - } + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( + context, + firebaseOptions + ) + + auth = Firebase.auth(app).apply { + useEmulator(emulatorHost, 9099) + } } @AfterTest - fun deinitializeFirebase() { + fun deinitializeFirebase() = runBlockingTest { Firebase.apps(context).forEach { it.delete() } @@ -47,20 +39,20 @@ class FirebaseAuthTest { @Test fun testSignInWithUsernameAndPassword() = runTest { val uid = getTestUid("test@test.com", "test123") - val result = Firebase.auth.signInWithEmailAndPassword("test@test.com", "test123") + val result = auth.signInWithEmailAndPassword("test@test.com", "test123") assertEquals(uid, result.user!!.uid) } @Test fun testCreateUserWithEmailAndPassword() = runTest { val email = "test+${Random.nextInt(100000)}@test.com" - val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123") + val createResult = auth.createUserWithEmailAndPassword(email, "test123") assertNotEquals(null, createResult.user?.uid) assertEquals(null, createResult.user?.displayName) assertEquals(null, createResult.user?.phoneNumber) assertEquals(email, createResult.user?.email) - val signInResult = Firebase.auth.signInWithEmailAndPassword(email, "test123") + val signInResult = auth.signInWithEmailAndPassword(email, "test123") assertEquals(createResult.user?.uid, signInResult.user?.uid) signInResult.user!!.delete() @@ -69,19 +61,19 @@ class FirebaseAuthTest { @Test fun testFetchSignInMethods() = runTest { val email = "test+${Random.nextInt(100000)}@test.com" - var signInMethodResult = Firebase.auth.fetchSignInMethodsForEmail(email) + var signInMethodResult = auth.fetchSignInMethodsForEmail(email) assertEquals(emptyList(), signInMethodResult) - Firebase.auth.createUserWithEmailAndPassword(email, "test123") - signInMethodResult = Firebase.auth.fetchSignInMethodsForEmail(email) + auth.createUserWithEmailAndPassword(email, "test123") + signInMethodResult = auth.fetchSignInMethodsForEmail(email) assertEquals(listOf("password"), signInMethodResult) - Firebase.auth.signInWithEmailAndPassword(email, "test123").user!!.delete() + auth.signInWithEmailAndPassword(email, "test123").user!!.delete() } @Test fun testSendEmailVerification() = runTest { val email = "test+${Random.nextInt(100000)}@test.com" - val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123") + val createResult = auth.createUserWithEmailAndPassword(email, "test123") assertNotEquals(null, createResult.user?.uid) createResult.user!!.sendEmailVerification() @@ -91,10 +83,10 @@ class FirebaseAuthTest { @Test fun sendPasswordResetEmail() = runTest { val email = "test+${Random.nextInt(100000)}@test.com" - val createResult = Firebase.auth.createUserWithEmailAndPassword(email, "test123") + val createResult = auth.createUserWithEmailAndPassword(email, "test123") assertNotEquals(null, createResult.user?.uid) - Firebase.auth.sendPasswordResetEmail(email) + auth.sendPasswordResetEmail(email) createResult.user!!.delete() } @@ -103,7 +95,7 @@ class FirebaseAuthTest { fun testSignInWithCredential() = runTest { val uid = getTestUid("test@test.com", "test123") val credential = EmailAuthProvider.credential("test@test.com", "test123") - val result = Firebase.auth.signInWithCredential(credential) + val result = auth.signInWithCredential(credential) assertEquals(uid, result.user!!.uid) } @@ -111,8 +103,8 @@ class FirebaseAuthTest { fun testIsSignInWithEmailLink() { val validLink = "http://localhost:9099/emulator/action?mode=signIn&lang=en&oobCode=_vr0QcFcxcVeLZbrcU-GpTaZiuxlHquqdC8MSy0YM_vzWCTAQgV9Jq&apiKey=fake-api-key&continueUrl=https%3A%2F%2Fexample.com%2Fsignin" val invalidLink = "http://localhost:9099/emulator/action?mode=signIn&lang=en&&apiKey=fake-api-key&continueUrl=https%3A%2F%2Fexample.com%2Fsignin" - assertTrue(Firebase.auth.isSignInWithEmailLink(validLink)) - assertFalse(Firebase.auth.isSignInWithEmailLink(invalidLink)) + assertTrue(auth.isSignInWithEmailLink(validLink)) + assertFalse(auth.isSignInWithEmailLink(invalidLink)) } @Test @@ -124,7 +116,7 @@ class FirebaseAuthTest { } private suspend fun getTestUid(email: String, password: String): String { - val uid = Firebase.auth.let { + val uid = auth.let { val user = try { it.createUserWithEmailAndPassword(email, password).user } catch (e: FirebaseAuthUserCollisionException) { @@ -134,9 +126,9 @@ class FirebaseAuthTest { user!!.uid } - check(Firebase.auth.currentUser != null) - Firebase.auth.signOut() - check(Firebase.auth.currentUser == null) + check(auth.currentUser != null) + auth.signOut() + check(auth.currentUser == null) return uid } diff --git a/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 717c94d59..84c4fcca7 100644 --- a/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/iosTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -4,24 +4,9 @@ package dev.gitlive.firebase.auth -import kotlinx.coroutines.* -import platform.Foundation.* - actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = runBlocking { - val testRun = MainScope().async { test() } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) - ) - yield() - } - testRun.await() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 6a5057f49..fd47ce8cc 100644 --- a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -11,7 +11,5 @@ actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-auth/src/jvmTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jvmTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 974ba1040..55c7b7cea 100644 --- a/firebase-auth/src/jvmTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jvmTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -9,5 +9,3 @@ package dev.gitlive.firebase.auth actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit - -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } diff --git a/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index d7ab8f5cd..492af89bc 100644 --- a/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -9,7 +9,5 @@ import androidx.test.platform.app.InstrumentationRegistry actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index d30260759..d910d2c12 100644 --- a/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -9,8 +9,6 @@ import org.junit.Ignore actual val context: Any = "" -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } - // Tests are to be run on AndroidInstrumentedTests. // Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest // Therefore we just wont run them diff --git a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 9d62b0253..01059ecc6 100644 --- a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -7,7 +7,9 @@ package dev.gitlive.firebase.remoteconfig import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize +import dev.gitlive.firebase.runTest import kotlinx.coroutines.test.TestResult import kotlin.test.AfterTest import kotlin.test.BeforeTest @@ -16,7 +18,6 @@ import kotlin.test.Test import kotlin.test.assertEquals expect val context: Any -expect fun runTest(test: suspend () -> Unit): TestResult expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest @@ -28,28 +29,21 @@ class FirebaseRemoteConfigTest { "test_default_string" to "Hello World", ) + lateinit var remoteConfig: FirebaseRemoteConfig + @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(context).isEmpty() } - ?.apply { - initialize( - context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - } + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( + context, + firebaseOptions + ) + + remoteConfig = Firebase.remoteConfig(app) } @AfterTest fun tearDown() = runTest { - Firebase.remoteConfig.reset() + remoteConfig.reset() Firebase.apps(context).forEach { it.delete() } @@ -57,7 +51,6 @@ class FirebaseRemoteConfigTest { @Test fun testGettingValues() = runTest { - val remoteConfig = Firebase.remoteConfig remoteConfig.setDefaults(*defaults) assertEquals(true, remoteConfig["test_default_boolean"]) @@ -74,8 +67,8 @@ class FirebaseRemoteConfigTest { @Test fun testGetAll() = runTest { - Firebase.remoteConfig.setDefaults(*defaults) - val all = Firebase.remoteConfig.all + remoteConfig.setDefaults(*defaults) + val all = remoteConfig.all assertEquals(true, all["test_default_boolean"]?.asBoolean()) assertEquals(42.0, all["test_default_double"]?.asDouble()) assertEquals(42L, all["test_default_long"]?.asLong()) @@ -85,8 +78,8 @@ class FirebaseRemoteConfigTest { @Test fun testGetKeysByPrefix() = runTest { - Firebase.remoteConfig.setDefaults(*defaults) - val keys = Firebase.remoteConfig.getKeysByPrefix("test_default") + remoteConfig.setDefaults(*defaults) + val keys = remoteConfig.getKeysByPrefix("test_default") assertEquals( setOf( "test_default_boolean", @@ -106,17 +99,17 @@ class FirebaseRemoteConfigTest { fetchTimeMillis = -1, lastFetchStatus = FetchStatus.NoFetchYet ).toString(), - Firebase.remoteConfig.info.toString() + remoteConfig.info.toString() ) } @Test fun testSetConfigSettings() = runTest { - Firebase.remoteConfig.settings { + remoteConfig.settings { fetchTimeoutInSeconds = 42 minimumFetchIntervalInSeconds = 42 } - val info = Firebase.remoteConfig.info + val info = remoteConfig.info assertEquals(42, info.configSettings.fetchTimeoutInSeconds) assertEquals(42, info.configSettings.minimumFetchIntervalInSeconds) } @@ -127,7 +120,6 @@ class FirebaseRemoteConfigTest { @Test @Ignore fun testFetch() = runTest { - val remoteConfig = Firebase.remoteConfig remoteConfig.settings { minimumFetchIntervalInSeconds = 60 } @@ -143,7 +135,6 @@ class FirebaseRemoteConfigTest { @Test @Ignore fun testFetchAndActivate() = runTest { - val remoteConfig = Firebase.remoteConfig remoteConfig.settings { minimumFetchIntervalInSeconds = 60 } diff --git a/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index c402c6bf2..70ce2965b 100644 --- a/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/iosTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -4,22 +4,7 @@ package dev.gitlive.firebase.remoteconfig -import kotlinx.coroutines.* -import platform.Foundation.* - actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = runBlocking { - val testRun = MainScope().async { test() } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) - ) - yield() - } - testRun.await() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 31ed60491..c6b4ef606 100644 --- a/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/jsTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -1,11 +1,6 @@ package dev.gitlive.firebase.remoteconfig -import kotlin.time.Duration.Companion.minutes - - actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index efb50bde7..5a0333346 100644 --- a/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/jvmTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -7,6 +7,5 @@ package dev.gitlive.firebase.remoteconfig actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index a842a208c..aa0ff306f 100644 --- a/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -6,13 +6,10 @@ package dev.gitlive.firebase.crashlytics import androidx.test.platform.app.InstrumentationRegistry -import kotlinx.coroutines.CoroutineScope actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 3b702ca2a..2535a367a 100644 --- a/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -5,15 +5,12 @@ @file:JvmName("tests") package dev.gitlive.firebase.crashlytics -import kotlinx.coroutines.CoroutineScope import org.junit.Ignore actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } - // Tests are to be run on AndroidInstrumentedTests. // Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest // Therefore we just wont run them diff --git a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index a50585bd0..97f72f1a0 100644 --- a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -7,7 +7,10 @@ package dev.gitlive.firebase.crashlytics import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize +import dev.gitlive.firebase.runBlockingTest +import dev.gitlive.firebase.runTest import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.TestResult import kotlin.test.AfterTest @@ -17,33 +20,25 @@ import kotlin.test.assertFalse expect val emulatorHost: String expect val context: Any -expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseCrashlyticsTest { + lateinit var crashlytics: FirebaseCrashlytics + @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(context).isEmpty() } - ?.apply { - initialize( - context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - } + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( + context, + firebaseOptions + ) + + crashlytics = Firebase.crashlytics(app) } @AfterTest - fun deinitializeFirebase() { + fun deinitializeFirebase() = runBlockingTest { Firebase.apps(context).forEach { it.delete() } @@ -51,55 +46,38 @@ class FirebaseCrashlyticsTest { @Test fun testRecordException() = runTest { - - val crashlytics = Firebase.crashlytics crashlytics.recordException(Exception("Test Exception")) } @Test fun testLog() = runTest { - - val crashlytics = Firebase.crashlytics crashlytics.log("Test Log") } @Test fun testSetUserId() = runTest { - - val crashlytics = Firebase.crashlytics crashlytics.setUserId("Test User Id") } @Test fun testSendUnsentReports() = runTest { - - val crashlytics = Firebase.crashlytics crashlytics.sendUnsentReports() - } @Test fun testDeleteUnsentReports() = runTest { - - val crashlytics = Firebase.crashlytics crashlytics.deleteUnsentReports() - } @Test fun testDidCrashOnPreviousExecution() = runTest { - - val crashlytics = Firebase.crashlytics val didCrash = crashlytics.didCrashOnPreviousExecution() assertFalse { didCrash } } @Test fun testSetCrashlyticsCollectionEnabled() = runTest { - - val crashlytics = Firebase.crashlytics crashlytics.setCrashlyticsCollectionEnabled(true) - } } diff --git a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index c3ca41c03..602cd1be6 100644 --- a/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/iosTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -4,24 +4,9 @@ package dev.gitlive.firebase.crashlytics -import kotlinx.coroutines.* -import platform.Foundation.* - actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { - val testRun = MainScope().async { test() } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) - ) - yield() - } - testRun.await() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt index 03cd9f62e..fb57e4883 100644 --- a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -6,12 +6,10 @@ package dev.gitlive.firebase.database import androidx.test.platform.app.InstrumentationRegistry -import kotlinx.coroutines.test.TestResult actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt index 18841e2dc..475c55e58 100644 --- a/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -11,8 +11,6 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } - // Tests are to be run on AndroidInstrumentedTests. // Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest // Therefore we just wont run them diff --git a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt index 14f921962..e5d295e76 100644 --- a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -1,19 +1,23 @@ package dev.gitlive.firebase.database import dev.gitlive.firebase.* +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first -import kotlinx.coroutines.test.TestResult +import kotlinx.coroutines.withContext +import kotlinx.coroutines.withTimeout import kotlinx.serialization.* import kotlin.test.* +import kotlin.time.Duration.Companion.minutes expect val emulatorHost: String expect val context: Any -expect fun runTest(test: suspend () -> Unit): TestResult expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseDatabaseTest { + lateinit var database: FirebaseDatabase + @Serializable data class FirebaseDatabaseChildTest(val prop1: String? = null, val time: Double = 0.0) @@ -22,26 +26,18 @@ class FirebaseDatabaseTest { @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(context).isEmpty() } - ?.apply { - initialize( - context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "http://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - Firebase.database.useEmulator(emulatorHost, 9000) - } + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( + context, + firebaseOptions + ) + + database = Firebase.database(app).apply { + useEmulator(emulatorHost, 9000) + } } @AfterTest - fun deinitializeFirebase() { + fun deinitializeFirebase() = runBlockingTest { Firebase.apps(context).forEach { it.delete() } @@ -49,8 +45,9 @@ class FirebaseDatabaseTest { @Test fun testSetValue() = runTest { + ensureDatabaseConnected() val testValue = "test" - val testReference = Firebase.database.reference("testPath") + val testReference = database.reference("testPath") testReference.setValue(testValue) @@ -65,7 +62,7 @@ class FirebaseDatabaseTest { @Test fun testChildCount() = runTest { setupRealtimeData() - val dataSnapshot = Firebase.database + val dataSnapshot = database .reference("FirebaseRealtimeDatabaseTest") .valueEvents .first() @@ -77,7 +74,7 @@ class FirebaseDatabaseTest { // @Test // fun testBasicIncrementTransaction() = runTest { // val data = DatabaseTest("PostOne", 2) -// val userRef = Firebase.database.reference("users/user_1/post_id_1") +// val userRef = database.reference("users/user_1/post_id_1") // setupDatabase(userRef, data, DatabaseTest.serializer()) // // // Check database before transaction @@ -100,7 +97,7 @@ class FirebaseDatabaseTest { // @Test // fun testBasicDecrementTransaction() = runTest { // val data = DatabaseTest("PostTwo", 2) -// val userRef = Firebase.database.reference("users/user_1/post_id_2") +// val userRef = database.reference("users/user_1/post_id_2") // setupDatabase(userRef, data, DatabaseTest.serializer()) // // // Check database before transaction @@ -122,7 +119,8 @@ class FirebaseDatabaseTest { @Test fun testSetServerTimestamp() = runTest { - val testReference = Firebase.database.reference("testSetServerTimestamp") + ensureDatabaseConnected() + val testReference = database.reference("testSetServerTimestamp") testReference.setValue(ServerValue.TIMESTAMP) @@ -136,7 +134,8 @@ class FirebaseDatabaseTest { @Test fun testIncrement() = runTest { - val testReference = Firebase.database.reference("testIncrement") + ensureDatabaseConnected() + val testReference = database.reference("testIncrement") testReference.setValue(2.0) @@ -157,7 +156,8 @@ class FirebaseDatabaseTest { } private suspend fun setupRealtimeData() { - val firebaseDatabaseTestReference = Firebase.database + ensureDatabaseConnected() + val firebaseDatabaseTestReference = database .reference("FirebaseRealtimeDatabaseTest") val firebaseDatabaseChildTest1 = FirebaseDatabaseChildTest("aaa") @@ -169,12 +169,6 @@ class FirebaseDatabaseTest { firebaseDatabaseTestReference.child("3").setValue(firebaseDatabaseChildTest3) } - private fun cleanUp() { - Firebase - .takeIf { Firebase.apps(context).isNotEmpty() } - ?.apply { app.delete() } - } - private suspend fun setupDatabase(ref: DatabaseReference, data: T, strategy: SerializationStrategy) { try { ref.setValue(strategy, data) @@ -183,4 +177,10 @@ class FirebaseDatabaseTest { throw err } } + + private suspend fun ensureDatabaseConnected() = withContext(Dispatchers.Default.limitedParallelism(1)) { + withTimeout(2.minutes) { + database.reference(".info/connected").valueEvents.first { it.value() } + } + } } diff --git a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt index f6bc3beb6..410cf18bb 100644 --- a/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/iosTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -4,24 +4,9 @@ package dev.gitlive.firebase.database -import kotlinx.coroutines.* -import platform.Foundation.* - actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = runBlocking { - val testRun = MainScope().async { test() } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) - ) - yield() - } - testRun.await() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt index 7102c1a8e..48e4649bb 100644 --- a/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jsTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -1,30 +1,8 @@ package dev.gitlive.firebase.database -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.database.externals.getDatabase -import dev.gitlive.firebase.database.externals.goOffline -import dev.gitlive.firebase.database.externals.goOnline -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.flow.first -import kotlinx.coroutines.withContext -import kotlinx.coroutines.withTimeout -import kotlin.time.Duration.Companion.minutes -import kotlin.time.Duration.Companion.seconds - actual val emulatorHost: String = "127.0.0.1" // in JS tests connection is refused if we use localhost actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { - // in JS tests we need to wait for the database to be connected - awaitDatabaseConnection() - test() -} @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest - -private suspend fun awaitDatabaseConnection() = withContext(Dispatchers.Default) { - withTimeout(2.minutes) { - Firebase.database.reference(".info/connected").valueEvents.first { it.value() } - } -} diff --git a/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt index a9757da98..27668d277 100644 --- a/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/jvmTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -10,6 +10,5 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit -actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index aeb178a5f..cf185f630 100644 --- a/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -6,14 +6,10 @@ package dev.gitlive.firebase.firestore import androidx.test.platform.app.InstrumentationRegistry -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.runBlocking actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 6279a50d7..da0c6a584 100644 --- a/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidUnitTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -12,8 +12,6 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } - // Tests are to be run on AndroidInstrumentedTests. // Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest // Therefore we just wont run them diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt index d2c147eb3..6dc5fa45f 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt @@ -1,5 +1,6 @@ package dev.gitlive.firebase.firestore +import dev.gitlive.firebase.runTest import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertNotEquals diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/GeoPointTests.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/GeoPointTests.kt index 6ec7ee545..45457040c 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/GeoPointTests.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/GeoPointTests.kt @@ -4,6 +4,7 @@ import dev.gitlive.firebase.decode import dev.gitlive.firebase.encode import dev.gitlive.firebase.nativeAssertEquals import dev.gitlive.firebase.nativeMapOf +import dev.gitlive.firebase.runTest import kotlinx.serialization.Serializable import kotlin.test.Test import kotlin.test.assertEquals diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TimestampTests.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TimestampTests.kt index 21ceaf2e4..98292048a 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TimestampTests.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/TimestampTests.kt @@ -5,6 +5,7 @@ import dev.gitlive.firebase.encode import dev.gitlive.firebase.firebaseSerializer import dev.gitlive.firebase.nativeAssertEquals import dev.gitlive.firebase.nativeMapOf +import dev.gitlive.firebase.runTest import kotlinx.serialization.Serializable import kotlin.test.* import kotlin.time.Duration.Companion.milliseconds diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index e7b0fd106..72489fa3b 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -7,7 +7,10 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize +import dev.gitlive.firebase.runBlockingTest +import dev.gitlive.firebase.runTest import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.async @@ -30,7 +33,6 @@ import kotlin.test.assertTrue expect val emulatorHost: String expect val context: Any -expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest @@ -50,28 +52,22 @@ class FirebaseFirestoreTest { val time: BaseTimestamp? ) + lateinit var firestore: FirebaseFirestore + @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(context).isEmpty() } - ?.apply { - initialize( - context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - Firebase.firestore.useEmulator(emulatorHost, 8080) - } + val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( + context, + firebaseOptions + ) + + firestore = Firebase.firestore(app).apply { + useEmulator(emulatorHost, 8080) + } } @AfterTest - fun deinitializeFirebase() { + fun deinitializeFirebase() = runBlockingTest { Firebase.apps(context).forEach { it.delete() } @@ -80,7 +76,7 @@ class FirebaseFirestoreTest { @Test fun testStringOrderBy() = runTest { setupFirestoreData() - val resultDocs = Firebase.firestore + val resultDocs = firestore .collection("testFirestoreQuerying") .orderBy("prop1") .get() @@ -95,7 +91,7 @@ class FirebaseFirestoreTest { fun testFieldOrderBy() = runTest { setupFirestoreData() - val resultDocs = Firebase.firestore.collection("testFirestoreQuerying") + val resultDocs = firestore.collection("testFirestoreQuerying") .orderBy(FieldPath("prop1")).get().documents assertEquals(3, resultDocs.size) assertEquals("aaa", resultDocs[0].get("prop1")) @@ -107,7 +103,7 @@ class FirebaseFirestoreTest { fun testStringOrderByAscending() = runTest { setupFirestoreData() - val resultDocs = Firebase.firestore.collection("testFirestoreQuerying") + val resultDocs = firestore.collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING).get().documents assertEquals(3, resultDocs.size) assertEquals("aaa", resultDocs[0].get("prop1")) @@ -119,7 +115,7 @@ class FirebaseFirestoreTest { fun testFieldOrderByAscending() = runTest { setupFirestoreData() - val resultDocs = Firebase.firestore.collection("testFirestoreQuerying") + val resultDocs = firestore.collection("testFirestoreQuerying") .orderBy(FieldPath("prop1"), Direction.ASCENDING).get().documents assertEquals(3, resultDocs.size) assertEquals("aaa", resultDocs[0].get("prop1")) @@ -131,7 +127,7 @@ class FirebaseFirestoreTest { fun testStringOrderByDescending() = runTest { setupFirestoreData() - val resultDocs = Firebase.firestore.collection("testFirestoreQuerying") + val resultDocs = firestore.collection("testFirestoreQuerying") .orderBy("prop1", Direction.DESCENDING).get().documents assertEquals(3, resultDocs.size) assertEquals("ccc", resultDocs[0].get("prop1")) @@ -143,7 +139,7 @@ class FirebaseFirestoreTest { fun testFieldOrderByDescending() = runTest { setupFirestoreData() - val resultDocs = Firebase.firestore.collection("testFirestoreQuerying") + val resultDocs = firestore.collection("testFirestoreQuerying") .orderBy(FieldPath("prop1"), Direction.DESCENDING).get().documents assertEquals(3, resultDocs.size) assertEquals("ccc", resultDocs[0].get("prop1")) @@ -153,7 +149,7 @@ class FirebaseFirestoreTest { @Test fun testServerTimestampFieldValue() = runTest { - val doc = Firebase.firestore + val doc = firestore .collection("testServerTimestampFieldValue") .document("test") @@ -165,7 +161,7 @@ class FirebaseFirestoreTest { @Test fun testServerTimestampBehaviorNone() = runTest { - val doc = Firebase.firestore + val doc = firestore .collection("testServerTimestampBehaviorNone") .document("test${Random.nextInt()}") @@ -186,7 +182,7 @@ class FirebaseFirestoreTest { @Test fun testServerTimestampBehaviorEstimate() = runTest { - val doc = Firebase.firestore + val doc = firestore .collection("testServerTimestampBehaviorEstimate") .document("test${Random.nextInt()}") @@ -205,7 +201,7 @@ class FirebaseFirestoreTest { @Test fun testServerTimestampBehaviorPrevious() = runTest { - val doc = Firebase.firestore + val doc = firestore .collection("testServerTimestampBehaviorPrevious") .document("test${Random.nextInt()}") @@ -223,13 +219,13 @@ class FirebaseFirestoreTest { @Test fun testDocumentAutoId() = runTest { - val doc = Firebase.firestore + val doc = firestore .collection("testDocumentAutoId") .document doc.set(FirestoreTest.serializer(), FirestoreTest("AutoId")) - val resultDoc = Firebase.firestore + val resultDoc = firestore .collection("testDocumentAutoId") .document(doc.id) .get() @@ -241,7 +237,7 @@ class FirebaseFirestoreTest { @Test fun testStartAfterDocumentSnapshot() = runTest { setupFirestoreData() - val query = Firebase.firestore + val query = firestore .collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING) @@ -261,7 +257,7 @@ class FirebaseFirestoreTest { @Test fun testStartAfterFieldValues() = runTest { setupFirestoreData() - val query = Firebase.firestore + val query = firestore .collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING) @@ -279,7 +275,7 @@ class FirebaseFirestoreTest { @Test fun testStartAtDocumentSnapshot() = runTest { setupFirestoreData() - val query = Firebase.firestore + val query = firestore .collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING) @@ -300,7 +296,7 @@ class FirebaseFirestoreTest { @Test fun testStartAtFieldValues() = runTest { setupFirestoreData() - val query = Firebase.firestore + val query = firestore .collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING) @@ -319,7 +315,7 @@ class FirebaseFirestoreTest { @Test fun testEndBeforeDocumentSnapshot() = runTest { setupFirestoreData() - val query = Firebase.firestore + val query = firestore .collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING) @@ -339,7 +335,7 @@ class FirebaseFirestoreTest { @Test fun testEndBeforeFieldValues() = runTest { setupFirestoreData() - val query = Firebase.firestore + val query = firestore .collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING) @@ -357,7 +353,7 @@ class FirebaseFirestoreTest { @Test fun testEndAtDocumentSnapshot() = runTest { setupFirestoreData() - val query = Firebase.firestore + val query = firestore .collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING) @@ -378,7 +374,7 @@ class FirebaseFirestoreTest { @Test fun testEndAtFieldValues() = runTest { setupFirestoreData() - val query = Firebase.firestore + val query = firestore .collection("testFirestoreQuerying") .orderBy("prop1", Direction.ASCENDING) @@ -396,7 +392,7 @@ class FirebaseFirestoreTest { @Test fun testIncrementFieldValue() = runTest { - val doc = Firebase.firestore + val doc = firestore .collection("testFirestoreIncrementFieldValue") .document("test1") @@ -411,7 +407,7 @@ class FirebaseFirestoreTest { @Test fun testArrayUnion() = runTest { - val doc = Firebase.firestore + val doc = firestore .collection("testFirestoreArrayUnion") .document("test1") @@ -426,7 +422,7 @@ class FirebaseFirestoreTest { @Test fun testArrayRemove() = runTest { - val doc = Firebase.firestore + val doc = firestore .collection("testFirestoreArrayRemove") .document("test1") @@ -447,7 +443,7 @@ class FirebaseFirestoreTest { val time: Double? ) - val doc = Firebase.firestore + val doc = firestore .collection("testLegacyDoubleTimestamp") .document("test${Random.nextInt()}") @@ -477,7 +473,7 @@ class FirebaseFirestoreTest { val time: Timestamp ) - val doc = Firebase.firestore + val doc = firestore .collection("testLegacyDoubleTimestampEncodeDecode") .document("testLegacy") @@ -496,7 +492,7 @@ class FirebaseFirestoreTest { val time: Timestamp ) - val collection = Firebase.firestore + val collection = firestore .collection("testQueryByTimestamp") val timestamp = Timestamp.fromMilliseconds(1693262549000.0) @@ -523,13 +519,13 @@ class FirebaseFirestoreTest { } private suspend fun setupFirestoreData() { - Firebase.firestore.collection("testFirestoreQuerying") + firestore.collection("testFirestoreQuerying") .document("one") .set(FirestoreTest.serializer(), FirestoreTest("aaa")) - Firebase.firestore.collection("testFirestoreQuerying") + firestore.collection("testFirestoreQuerying") .document("two") .set(FirestoreTest.serializer(), FirestoreTest("bbb")) - Firebase.firestore.collection("testFirestoreQuerying") + firestore.collection("testFirestoreQuerying") .document("three") .set(FirestoreTest.serializer(), FirestoreTest("ccc")) } diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 847d16ead..f28d93276 100644 --- a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -4,24 +4,9 @@ package dev.gitlive.firebase.firestore -import kotlinx.coroutines.* -import platform.Foundation.* - actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { - val testRun = MainScope().async { test() } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) - ) - yield() - } - testRun.await() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 3c75398d3..f28d93276 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -4,15 +4,9 @@ package dev.gitlive.firebase.firestore -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.test.runTest -import kotlin.time.Duration.Companion.minutes - actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runTest(timeout = 5.minutes) { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index dfed2844a..6eb9f93a2 100644 --- a/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jvmTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -5,13 +5,9 @@ @file:JvmName("tests") package dev.gitlive.firebase.firestore -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.runBlocking - actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index a99532882..2beec7188 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,12 +3,20 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.perf.FirebasePerformance +import dev.gitlive.firebase.perf.context import dev.gitlive.firebase.perf.performance +import dev.gitlive.firebase.runBlockingTest +import kotlinx.coroutines.delay +import kotlinx.coroutines.test.runTest +import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.time.Duration.Companion.milliseconds +import kotlin.time.Duration.Companion.seconds class AndroidTraceTest { @@ -16,29 +24,25 @@ class AndroidTraceTest { @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(dev.gitlive.firebase.perf.context).isEmpty() } - ?.apply { - initialize( - dev.gitlive.firebase.perf.context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - } - - performance = Firebase.performance + val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( + dev.gitlive.firebase.perf.context, + firebaseOptions + ) + performance = Firebase.performance(app) + } + @AfterTest + fun deinitializeFirebase() = runBlockingTest { + // Performance runs installation in the background, which crashes if the app is deleted before completion + delay(1.seconds) + Firebase.apps(context).forEach { + it.delete() + } } @Test - fun testGetAttributes() { + fun testGetAttributes() = runTest { val trace = performance.newTrace("testGetAttributes") trace.start() val values = listOf(1, 2, 3) @@ -60,7 +64,7 @@ class AndroidTraceTest { } @Test - fun testGetAttribute() { + fun testGetAttribute() = runTest { val trace = performance.newTrace("testGetAttribute") trace.start() trace.putAttribute("Test_Get_Attribute", "Test Get Attribute Value") @@ -70,7 +74,7 @@ class AndroidTraceTest { } @Test - fun testPutAttribute() { + fun testPutAttribute() = runTest { val trace = performance.newTrace("testPutAttribute") trace.start() trace.putAttribute("Test_Put_Attribute", "Test Put Attribute Value") diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 9f588d89c..045b947fe 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -6,13 +6,10 @@ package dev.gitlive.firebase.perf import androidx.test.platform.app.InstrumentationRegistry -import kotlinx.coroutines.CoroutineScope actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 7fa4328ed..0ab0e47da 100644 --- a/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -12,8 +12,6 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } - // Tests are to be run on AndroidInstrumentedTests. // Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest // Therefore we just wont run them diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 6fac9d3dd..cb984af80 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -1,15 +1,21 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.perf.FirebasePerformance import dev.gitlive.firebase.perf.IgnoreForAndroidUnitTest +import dev.gitlive.firebase.perf.context import dev.gitlive.firebase.perf.performance +import dev.gitlive.firebase.runBlockingTest +import dev.gitlive.firebase.runTest +import kotlinx.coroutines.delay +import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.time.Duration.Companion.seconds @IgnoreForAndroidUnitTest class TraceTest { @@ -18,29 +24,24 @@ class TraceTest { @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(dev.gitlive.firebase.perf.context).isEmpty() } - ?.apply { - initialize( + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( dev.gitlive.firebase.perf.context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + firebaseOptions ) - } - - performance = Firebase.performance - + performance = Firebase.performance(app) + } + @AfterTest + fun deinitializeFirebase() = runBlockingTest { + // Performance runs installation in the background, which crashes if the app is deleted before completion + delay(1.seconds) + Firebase.apps(context).forEach { + it.delete() + } } @Test - fun testGetLongMetric() { + fun testGetLongMetric() = runTest { val trace = performance.newTrace("testGetLongMetric") trace.start() trace.putMetric("Get Long Metric Test", 1L) @@ -50,7 +51,7 @@ class TraceTest { } @Test - fun testIncrementMetric() { + fun testIncrementMetric() = runTest { val trace = performance.newTrace("testIncrementMetric") trace.start() trace.putMetric("Get Increment Metric Test", 1L) diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt index f2ef6ae2a..dd075b21e 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -7,40 +7,34 @@ package dev.gitlive.firebase.perf import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize +import dev.gitlive.firebase.runBlockingTest +import dev.gitlive.firebase.runTest import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.test.TestResult import kotlin.test.* expect val emulatorHost: String expect val context: Any -expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebasePerformanceTest { + lateinit var performance: FirebasePerformance + @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(context).isEmpty() } - ?.apply { - initialize( + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) + firebaseOptions ) - } + performance = Firebase.performance(app) } @AfterTest - fun deinitializeFirebase() { + fun deinitializeFirebase() = runBlockingTest { Firebase.apps(context).forEach { it.delete() } @@ -49,8 +43,6 @@ class FirebasePerformanceTest { @Test fun testNewTrace() = runTest { - val performance = Firebase.performance - val trace = performance.newTrace("Test Trace") assertNotNull(trace) @@ -59,8 +51,6 @@ class FirebasePerformanceTest { @Test fun testPerformanceCollectionEnabled() = runTest { - val performance = Firebase.performance - performance.setPerformanceCollectionEnabled(false) assertFalse(performance.isPerformanceCollectionEnabled()) diff --git a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 23657fe4c..67cfa78ac 100644 --- a/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/iosTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -4,24 +4,9 @@ package dev.gitlive.firebase.perf -import kotlinx.coroutines.* -import platform.Foundation.* - actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { - val testRun = MainScope().async { test() } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) - ) - yield() - } - testRun.await() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index dc36d0f7b..f58fa33c7 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,9 +3,13 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.perf.FirebasePerformance +import dev.gitlive.firebase.perf.context import dev.gitlive.firebase.perf.performance +import dev.gitlive.firebase.runBlockingTest +import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals @@ -16,25 +20,19 @@ class JsTraceTest { @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(dev.gitlive.firebase.perf.context).isEmpty() } - ?.apply { - initialize( - dev.gitlive.firebase.perf.context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - } - - performance = Firebase.performance + val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( + dev.gitlive.firebase.perf.context, + firebaseOptions + ) + performance = Firebase.performance(app) + } + @AfterTest + fun deinitializeFirebase() = runBlockingTest { + Firebase.apps(context).forEach { + it.delete() + } } @Test diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 8a71f4902..9e3c5ecc1 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -7,19 +7,15 @@ package dev.gitlive.firebase.perf import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize -import kotlinx.coroutines.CoroutineScope +import dev.gitlive.firebase.runTest import kotlin.test.* -import kotlin.time.Duration.Companion.minutes actual val emulatorHost: String = "localhost" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { - test() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest @@ -29,25 +25,12 @@ class JsPerformanceTest { @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(context).isEmpty() } - ?.apply { - initialize( - context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - } - - performance = Firebase.performance - + val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( + context, + firebaseOptions + ) + performance = Firebase.performance(app) } @Test diff --git a/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 8fcbdfbd0..f8134eecb 100644 --- a/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jvmTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -5,12 +5,9 @@ @file:JvmName("tests") package dev.gitlive.firebase.perf -import kotlinx.coroutines.CoroutineScope - actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt index f726d3c13..67a1affe0 100644 --- a/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -6,13 +6,10 @@ package dev.gitlive.firebase.storage import androidx.test.platform.app.InstrumentationRegistry -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.runBlocking actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 94430eadc..bb42eb2f7 100644 --- a/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/androidUnitTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -1,12 +1,9 @@ package dev.gitlive.firebase.storage -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.runBlocking import org.junit.Ignore actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 895c2f586..7c0354e67 100644 --- a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -7,36 +7,30 @@ package dev.gitlive.firebase.storage import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps +import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import kotlinx.coroutines.CoroutineScope import kotlin.test.BeforeTest expect val emulatorHost: String expect val context: Any -expect fun runTest(test: suspend CoroutineScope.() -> Unit) expect annotation class IgnoreForAndroidUnitTest() @IgnoreForAndroidUnitTest class FirebaseStorageTest { + lateinit var storage: FirebaseStorage + @BeforeTest fun initializeFirebase() { - Firebase - .takeIf { Firebase.apps(context).isEmpty() } - ?.apply { - initialize( - context, - FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" - ) - ) - Firebase.storage.useEmulator(emulatorHost, 9199) - } + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( + context, + firebaseOptions + ) + + storage = Firebase.storage(app).apply { + useEmulator(emulatorHost, 9199) + } } } \ No newline at end of file diff --git a/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 164a0fecc..7b3541194 100644 --- a/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/iosTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -4,32 +4,9 @@ package dev.gitlive.firebase.storage -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.MainScope -import kotlinx.coroutines.async -import kotlinx.coroutines.runBlocking -import kotlinx.coroutines.yield -import platform.Foundation.NSDate -import platform.Foundation.NSDefaultRunLoopMode -import platform.Foundation.NSRunLoop -import platform.Foundation.create -import platform.Foundation.runMode - actual val emulatorHost: String = "127.0.0.1" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { - val testRun = MainScope().async { test() } - while (testRun.isActive) { - NSRunLoop.mainRunLoop.runMode( - NSDefaultRunLoopMode, - beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) - ) - yield() - } - testRun.await() -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 96e9365c3..7b3541194 100644 --- a/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jsTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -4,16 +4,9 @@ package dev.gitlive.firebase.storage -import kotlinx.coroutines.CoroutineScope -import kotlin.time.Duration.Companion.minutes - actual val emulatorHost: String = "127.0.0.1" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) { - kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } -} - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt index c358bc6e7..a030f38bd 100644 --- a/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/jvmTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -5,14 +5,9 @@ @file:JvmName("tests") package dev.gitlive.firebase.storage -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.runBlocking - actual val emulatorHost: String = "10.0.2.2" actual val context: Any = Unit -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { test() } - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 285cfdcac..8c7e66a73 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -88,7 +88,11 @@ kotlin { getByName("commonMain") { dependencies { + val coroutinesVersion: String by project + implementation(project(":firebase-app")) api(kotlin("test")) + api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") + api("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") } } diff --git a/test-utils/src/androidMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/androidMain/kotlin/dev/gitlive/firebase/TestUtils.kt index 90f236dee..c72c78980 100644 --- a/test-utils/src/androidMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/androidMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -1,9 +1,16 @@ +@file:JvmName("TestUtilsAndroid") /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ package dev.gitlive.firebase +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.runBlocking + +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } +actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) = runBlocking(block = action) + actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) actual fun nativeListOf(vararg elements: Any): Any = listOf(*elements) actual fun nativeAssertEquals(expected: Any?, actual: Any?) { diff --git a/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt index ee6a2fe7a..bb9c85d98 100644 --- a/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -1,9 +1,26 @@ +@file:JvmName("TestUtilsJVM") /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ package dev.gitlive.firebase +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.test.TestResult +import kotlin.jvm.JvmName + +expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult +expect fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) + expect fun nativeMapOf(vararg pairs: Pair): Any expect fun nativeListOf(vararg elements: Any): Any expect fun nativeAssertEquals(expected: Any?, actual: Any?) + +val firebaseOptions = FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" +) diff --git a/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt index 90f236dee..eaea5f84d 100644 --- a/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -4,6 +4,30 @@ package dev.gitlive.firebase +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.async +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.yield +import platform.Foundation.NSDate +import platform.Foundation.NSDefaultRunLoopMode +import platform.Foundation.NSRunLoop +import platform.Foundation.create +import platform.Foundation.runMode + +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { + val testRun = MainScope().async { test() } + while (testRun.isActive) { + NSRunLoop.mainRunLoop.runMode( + NSDefaultRunLoopMode, + beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) + ) + yield() + } + testRun.await() +} +actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) = runBlocking(block = action) + actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) actual fun nativeListOf(vararg elements: Any): Any = listOf(*elements) actual fun nativeAssertEquals(expected: Any?, actual: Any?) { diff --git a/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt index 258541dd5..f3e60277a 100644 --- a/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -4,7 +4,15 @@ package dev.gitlive.firebase +import kotlinx.coroutines.CoroutineScope import kotlin.js.json +import kotlin.time.Duration.Companion.minutes + +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = + kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } +actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) { + kotlinx.coroutines.test.runTest { action() } +} actual fun nativeMapOf(vararg pairs: Pair): Any = json(*pairs) actual fun nativeListOf(vararg elements: Any): Any = elements diff --git a/test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt new file mode 100644 index 000000000..67528d98f --- /dev/null +++ b/test-utils/src/jvmMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. + */package dev.gitlive.firebase + +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.runBlocking + +package dev.gitlive.firebase + +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } +actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) = runBlocking(block = action) + +actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) +actual fun nativeListOf(vararg elements: Any): Any = listOf(*elements) +actual fun nativeAssertEquals(expected: Any?, actual: Any?) { + kotlin.test.assertEquals(expected, actual) +} From 5dd614531b24e0f066f642de7d3fce3cf21ac1b6 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Thu, 28 Sep 2023 00:12:14 +0200 Subject: [PATCH 24/29] Fix for ios tests --- .../kotlin/dev/gitlive/firebase/firebase.kt | 9 ++++++++- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 9 ++++++++- firebase-config/build.gradle.kts | 1 + .../remoteconfig/FirebaseRemoteConfig.kt | 11 ++++++++--- .../gitlive/firebase/crashlytics/crashlytics.kt | 12 ++++++++---- .../dev/gitlive/firebase/database/database.kt | 9 ++++++++- .../dev/gitlive/firebase/firestore/firestore.kt | 10 ++++++++-- .../dev/gitlive/firebase/perf/metrics/Trace.kt | 11 ++++++++--- .../dev/gitlive/firebase/perf/metrics/Trace.kt | 16 ++++++++++++---- .../dev/gitlive/firebase/perf/performance.kt | 17 +++++++++++------ .../dev/gitlive/firebase/perf/metrics/Trace.kt | 10 ++++++++-- .../dev/gitlive/firebase/perf/performance.kt | 10 ++++++++-- .../dev/gitlive/firebase/storage/storage.kt | 11 ++++++++--- test-utils/build.gradle.kts | 6 +++++- .../kotlin/dev/gitlive/firebase/TestUtils.kt | 9 --------- 15 files changed, 109 insertions(+), 42 deletions(-) diff --git a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt index 568946990..9c49761f6 100644 --- a/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt +++ b/firebase-app/src/commonTest/kotlin/dev/gitlive/firebase/firebase.kt @@ -12,7 +12,14 @@ class FirebaseAppTest { fun testInitialize() = runTest { Firebase.initialize( context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) assertEquals(1, Firebase.apps(context).size) diff --git a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt index 9adf6d569..ceaf34929 100644 --- a/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/commonTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -21,7 +21,14 @@ class FirebaseAuthTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) auth = Firebase.auth(app).apply { diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index 4290f8cbd..5b846789e 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -121,6 +121,7 @@ kotlin { optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") if (name.lowercase().contains("ios")) { optIn("kotlinx.cinterop.ExperimentalForeignApi") + optIn("kotlinx.cinterop.BetaInteropApi") } } } diff --git a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt index 01059ecc6..426a7f23e 100644 --- a/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt +++ b/firebase-config/src/commonTest/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt @@ -7,10 +7,8 @@ package dev.gitlive.firebase.remoteconfig import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.runTest -import kotlinx.coroutines.test.TestResult import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Ignore @@ -35,7 +33,14 @@ class FirebaseRemoteConfigTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) remoteConfig = Firebase.remoteConfig(app) diff --git a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 97f72f1a0..8c1933846 100644 --- a/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/commonTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -7,12 +7,9 @@ package dev.gitlive.firebase.crashlytics import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.runBlockingTest import dev.gitlive.firebase.runTest -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.test.TestResult import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test @@ -31,7 +28,14 @@ class FirebaseCrashlyticsTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) crashlytics = Firebase.crashlytics(app) diff --git a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt index e5d295e76..66706aa1c 100644 --- a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -28,7 +28,14 @@ class FirebaseDatabaseTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) database = Firebase.database(app).apply { diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 72489fa3b..a567c8cd2 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -7,7 +7,6 @@ package dev.gitlive.firebase.firestore import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.runBlockingTest import dev.gitlive.firebase.runTest @@ -58,7 +57,14 @@ class FirebaseFirestoreTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) firestore = Firebase.firestore(app).apply { diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 2beec7188..4bed80ff9 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,7 +3,6 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.perf.FirebasePerformance import dev.gitlive.firebase.perf.context @@ -15,7 +14,6 @@ import kotlin.test.AfterTest import kotlin.test.BeforeTest import kotlin.test.Test import kotlin.test.assertEquals -import kotlin.time.Duration.Companion.milliseconds import kotlin.time.Duration.Companion.seconds class AndroidTraceTest { @@ -26,7 +24,14 @@ class AndroidTraceTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( dev.gitlive.firebase.perf.context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) performance = Firebase.performance(app) diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index cb984af80..2cee8d86f 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -1,8 +1,8 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.Firebase +import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.perf.FirebasePerformance import dev.gitlive.firebase.perf.IgnoreForAndroidUnitTest @@ -25,9 +25,17 @@ class TraceTest { @BeforeTest fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( - dev.gitlive.firebase.perf.context, - firebaseOptions - ) + dev.gitlive.firebase.perf.context, + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) + ) + performance = Firebase.performance(app) } diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt index dd075b21e..171754b4d 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -7,12 +7,9 @@ package dev.gitlive.firebase.perf import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.runBlockingTest import dev.gitlive.firebase.runTest -import kotlinx.coroutines.CoroutineScope -import kotlinx.coroutines.test.TestResult import kotlin.test.* expect val emulatorHost: String @@ -27,9 +24,17 @@ class FirebasePerformanceTest { @BeforeTest fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( - context, - firebaseOptions - ) + context, + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) + ) + performance = Firebase.performance(app) } diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index f58fa33c7..1cdb6f57b 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -3,7 +3,6 @@ package dev.gitlive.firebase.perf.metrics import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.perf.FirebasePerformance import dev.gitlive.firebase.perf.context @@ -22,7 +21,14 @@ class JsTraceTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( dev.gitlive.firebase.perf.context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) performance = Firebase.performance(app) diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 9e3c5ecc1..d5c91ca0c 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -7,7 +7,6 @@ package dev.gitlive.firebase.perf import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize import dev.gitlive.firebase.runTest import kotlin.test.* @@ -27,7 +26,14 @@ class JsPerformanceTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) performance = Firebase.performance(app) diff --git a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt index 7c0354e67..d517e9949 100644 --- a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -7,9 +7,7 @@ package dev.gitlive.firebase.storage import dev.gitlive.firebase.Firebase import dev.gitlive.firebase.FirebaseOptions import dev.gitlive.firebase.apps -import dev.gitlive.firebase.firebaseOptions import dev.gitlive.firebase.initialize -import kotlinx.coroutines.CoroutineScope import kotlin.test.BeforeTest expect val emulatorHost: String @@ -25,7 +23,14 @@ class FirebaseStorageTest { fun initializeFirebase() { val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( context, - firebaseOptions + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) ) storage = Firebase.storage(app).apply { diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index 8c7e66a73..a3b1a0558 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -83,16 +83,20 @@ kotlin { this.apiVersion = apiVersion this.languageVersion = languageVersion progressiveMode = true + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + optIn("kotlinx.cinterop.BetaInteropApi") + } } } getByName("commonMain") { dependencies { val coroutinesVersion: String by project - implementation(project(":firebase-app")) api(kotlin("test")) api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") api("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") + } } diff --git a/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt index bb9c85d98..02d5f6873 100644 --- a/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -15,12 +15,3 @@ expect fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) expect fun nativeMapOf(vararg pairs: Pair): Any expect fun nativeListOf(vararg elements: Any): Any expect fun nativeAssertEquals(expected: Any?, actual: Any?) - -val firebaseOptions = FirebaseOptions( - applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", - apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", - databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", - storageBucket = "fir-kotlin-sdk.appspot.com", - projectId = "fir-kotlin-sdk", - gcmSenderId = "846484016111" -) From 69848e51586c66f20f571d4646d5781cb9a96f07 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Fri, 17 Nov 2023 16:49:15 +0100 Subject: [PATCH 25/29] Merge pull request #64 from splendo/feature/kotlin-1.9.20 Support Kotlin 1.9.20 --- .github/actions/setup_test_action/action.yml | 30 ++++ .github/workflows/pull_request.yml | 117 ++++++++------ README.md | 24 +-- build.gradle.kts | 6 +- firebase-app/build.gradle.kts | 35 +++-- firebase-app/package.json | 4 +- .../kotlin/dev/gitlive/firebase/firebase.kt | 4 +- .../kotlin/dev/gitlive/firebase/firebase.kt | 4 - firebase-auth/build.gradle.kts | 31 ++-- firebase-auth/package.json | 4 +- .../kotlin/dev/gitlive/firebase/auth/auth.kt | 4 - .../kotlin/dev/gitlive/firebase/auth/auth.kt | 1 + .../kotlin/dev/gitlive/firebase/auth/auth.kt | 2 - firebase-common/build.gradle.kts | 33 ++-- firebase-common/package.json | 2 +- firebase-config/build.gradle.kts | 31 ++-- firebase-config/package.json | 4 +- .../firebase/remoteconfig/RemoteConfig.kt | 4 - firebase-crashlytics/build.gradle.kts | 35 ++--- firebase-crashlytics/package.json | 4 +- .../firebase/crashlytics/crashlytics.kt | 4 - .../firebase/crashlytics/crashlytics.jvm.kt | 2 +- firebase-database/build.gradle.kts | 35 +++-- firebase-database/package.json | 4 +- .../dev/gitlive/firebase/database/database.kt | 1 - .../dev/gitlive/firebase/database/database.kt | 2 +- .../dev/gitlive/firebase/database/database.kt | 5 - .../dev/gitlive/firebase/database/database.kt | 3 +- firebase-firestore/build.gradle.kts | 36 ++--- firebase-firestore/package.json | 4 +- .../gitlive/firebase/firestore/firestore.kt | 5 +- .../firebase/firestore/FieldValueTests.kt | 1 + .../gitlive/firebase/firestore/firestore.kt | 5 +- .../firebase/firestore/ContextSwitchTest.kt | 145 ++++++++++++++++++ .../gitlive/firebase/firestore/firestore.kt | 1 + firebase-functions/build.gradle.kts | 35 +++-- firebase-functions/package.json | 4 +- .../gitlive/firebase/functions/functions.kt | 7 + .../gitlive/firebase/functions/functions.kt | 26 ++++ .../gitlive/firebase/functions/functions.kt | 66 ++++++-- .../gitlive/firebase/functions/functions.kt | 57 ++++++- firebase-installations/build.gradle.kts | 34 ++-- firebase-installations/package.json | 4 +- firebase-perf/build.gradle.kts | 35 ++--- firebase-perf/package.json | 4 +- .../gitlive/firebase/perf/metrics/Trace.kt | 9 +- .../dev/gitlive/firebase/perf/performance.kt | 5 - .../gitlive/firebase/perf/metrics/Trace.kt | 7 +- .../dev/gitlive/firebase/perf/performance.kt | 15 +- .../gitlive/firebase/perf/metrics/Trace.kt | 13 +- .../dev/gitlive/firebase/perf/performance.kt | 5 +- .../gitlive/firebase/perf/performance.jvm.kt | 2 +- firebase-storage/build.gradle.kts | 35 +++-- firebase-storage/package.json | 4 +- .../dev/gitlive/firebase/storage/storage.kt | 1 - .../gitlive/firebase/storage/storage.jvm.kt | 2 +- gradle.properties | 30 ++-- gradle/wrapper/gradle-wrapper.properties | 2 +- test-utils/build.gradle.kts | 21 ++- .../kotlin/dev/gitlive/firebase/TestUtils.kt | 5 +- .../kotlin/dev/gitlive/firebase/TestUtils.kt | 2 +- .../kotlin/dev/gitlive/firebase/TestUtils.kt | 3 +- .../kotlin/dev/gitlive/firebase/TestUtils.kt | 2 +- 63 files changed, 675 insertions(+), 392 deletions(-) create mode 100644 .github/actions/setup_test_action/action.yml create mode 100644 firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt diff --git a/.github/actions/setup_test_action/action.yml b/.github/actions/setup_test_action/action.yml new file mode 100644 index 000000000..1b18c9db4 --- /dev/null +++ b/.github/actions/setup_test_action/action.yml @@ -0,0 +1,30 @@ +name: 'Setup Tests' +description: 'Prepares to run tests on Firebase emulator' + +runs: + using: "composite" + steps: + - name: Set up JDK + uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '17' + cache: gradle + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '21.x' + - name: Upgrade packages + shell: bash + run: npm update + - name: Gradle cache + uses: gradle/gradle-build-action@v2 + - name: Grant execute permission for gradlew + shell: bash + run: chmod +x gradlew + - name: Install Firebase tools + shell: bash + run: npm install -g firebase-tools + - name: Start Firebase emulator + shell: bash + run: "firebase emulators:start --config=./test/firebase.json &" \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 158b8ab6c..b6147715a 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -8,56 +8,20 @@ on: branches: [ master ] jobs: - build: - runs-on: macos-13 + build-android: + runs-on: 4-core-ubuntu strategy: matrix: api-level: [ 34 ] steps: - uses: actions/checkout@v3 - - name: Cocoapods cache - uses: actions/cache@v3 - id: cocoapods-cache - with: - path: | - ~/.cocoapods - ~/Library/Caches/CocoaPods - */build/cocoapods - */build/classes - key: cocoapods-cache - - name: Set up JDK - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: '17' - cache: gradle - - name: Gradle cache - uses: gradle/gradle-build-action@v2 - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Install Firebase tools - run: npm install -g firebase-tools - - name: Start Firebase emulator - run: "firebase emulators:start --config=./test/firebase.json &" - - name: Run JS Tests - run: ./gradlew cleanTest jsTest - - name: Upload JS test artifact - uses: actions/upload-artifact@v3 - if: failure() - with: - name: "JS Test Report HTML" - path: | - **/build/reports/tests/jsTest/ - **/build/reports/tests/jsBrowserTest/ - **/build/reports/tests/jsNodeTest/ - - name: Run iOS Tests - run: ./gradlew cleanTest iosX64Test - - name: Upload iOS test artifact - uses: actions/upload-artifact@v3 - if: failure() - with: - name: "iOS Test Report HTML" - path: "**/build/reports/tests/iosX64Test/" + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm + - name: Setup test environment + uses: ./.github/actions/setup_test_action - name: AVD cache uses: actions/cache@v3 id: avd-cache @@ -65,7 +29,7 @@ jobs: path: | ~/.android/avd/* ~/.android/adb* - key: avd-${{ matrix.api-level }} + key: avd-${{ matrix.api-level }}-${{ runner.os }}-${{ runner.arch }} - name: create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@v2 @@ -73,6 +37,7 @@ jobs: api-level: ${{ matrix.api-level }} arch: x86_64 target: google_apis + avd-name: pixel6_API${{ matrix.api-level }} force-avd-creation: false emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false @@ -83,6 +48,7 @@ jobs: api-level: ${{ matrix.api-level }} arch: x86_64 target: google_apis + avd-name: pixel6_API${{ 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 @@ -93,3 +59,62 @@ jobs: with: name: "Android Test Report HTML" path: "**/build/reports/androidTests/" + - name: Upload Firebase Debug Log + uses: actions/upload-artifact@v3 + if: failure() + with: + name: "Firebase Debug Log" + path: "**/firebase-debug.log" + build-js: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup test environment + uses: ./.github/actions/setup_test_action + - name: Run JS Tests + run: ./gradlew cleanTest jsTest + - name: Upload JS test artifact + uses: actions/upload-artifact@v3 + if: failure() + with: + name: "JS Test Report HTML" + path: | + **/build/reports/tests/jsTest/ + **/build/reports/tests/jsBrowserTest/ + **/build/reports/tests/jsNodeTest/ + - name: Upload Firebase Debug Log + uses: actions/upload-artifact@v3 + if: failure() + with: + name: "Firebase Debug Log" + path: "**/firebase-debug.log" + build-ios: + runs-on: macos-13 + steps: + - uses: actions/checkout@v3 + - name: Cocoapods cache + uses: actions/cache@v3 + id: cocoapods-cache + with: + path: | + ~/.cocoapods + ~/Library/Caches/CocoaPods + */build/cocoapods + */build/classes + key: cocoapods-cache + - name: Setup test environment + uses: ./.github/actions/setup_test_action + - name: Run iOS Tests + run: ./gradlew cleanTest iosX64Test + - name: Upload iOS test artifact + uses: actions/upload-artifact@v3 + if: failure() + with: + name: "iOS Test Report HTML" + path: "**/build/reports/tests/iosX64Test/" + - name: Upload Firebase Debug Log + uses: actions/upload-artifact@v3 + if: failure() + with: + name: "Firebase Debug Log" + path: "**/firebase-debug.log" diff --git a/README.md b/README.md index 913a34b7d..0f7c6ec41 100644 --- a/README.md +++ b/README.md @@ -14,18 +14,18 @@ Firebase as a backend for FirebaseAuthInvalidCredentialsException(toString()) FIRAuthErrorCodeWeakPassword -> FirebaseAuthWeakPasswordException(toString()) diff --git a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt index fd47ce8cc..832712901 100644 --- a/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt +++ b/firebase-auth/src/jsTest/kotlin/dev/gitlive/firebase/auth/auth.kt @@ -4,8 +4,6 @@ package dev.gitlive.firebase.auth -import kotlin.time.Duration.Companion.minutes - actual val emulatorHost: String = "localhost" diff --git a/firebase-common/build.gradle.kts b/firebase-common/build.gradle.kts index 2c33fb0ab..0586bfd3f 100644 --- a/firebase-common/build.gradle.kts +++ b/firebase-common/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -44,7 +46,16 @@ android { kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -69,7 +80,8 @@ kotlin { val supportIosTarget = project.property("skipIosTarget") != "true" if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() } @@ -117,7 +129,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -129,24 +141,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } - getByName("jsMain") { dependencies { - api(npm("firebase", "10.4.0")) + api(npm("firebase", "10.6.0")) } } diff --git a/firebase-common/package.json b/firebase-common/package.json index 7e9e38f26..163d7ec0f 100644 --- a/firebase-common/package.json +++ b/firebase-common/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-common", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-common.js", "scripts": { diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index 5b846789e..30dd776c3 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -60,7 +62,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -83,7 +94,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -133,7 +145,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -145,24 +157,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-config/package.json b/firebase-config/package.json index bac1afa9f..78d6c9b43 100644 --- a/firebase-config/package.json +++ b/firebase-config/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-config", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-config.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt b/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt index d910d2c12..19d69bba3 100644 --- a/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt +++ b/firebase-config/src/androidUnitTest/kotlin/dev/gitlive/firebase/remoteconfig/RemoteConfig.kt @@ -9,8 +9,4 @@ import org.junit.Ignore actual val context: Any = "" -// Tests are to be run on AndroidInstrumentedTests. -// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest -// Therefore we just wont run them -// Kotlin 1.9 will introduce methods for disabling tests properly actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index 4e7e4587f..eba332d66 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -47,7 +49,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -70,7 +81,8 @@ kotlin { // } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -93,6 +105,9 @@ kotlin { this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -103,7 +118,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -115,24 +130,8 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - // getByName("jvmMain") { // } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by sourceSets.getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-crashlytics/package.json b/firebase-crashlytics/package.json index a2528a17f..845bef8a8 100644 --- a/firebase-crashlytics/package.json +++ b/firebase-crashlytics/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-crashlytics", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-crashlytics.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt b/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt index 2535a367a..413cecca5 100644 --- a/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt +++ b/firebase-crashlytics/src/androidUnitTest/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt @@ -11,8 +11,4 @@ actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" -// Tests are to be run on AndroidInstrumentedTests. -// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest -// Therefore we just wont run them -// Kotlin 1.9 will introduce methods for disabling tests properly actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-crashlytics/src/jvmMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.jvm.kt b/firebase-crashlytics/src/jvmMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.jvm.kt index 36d363bba..92aba8ea9 100644 --- a/firebase-crashlytics/src/jvmMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.jvm.kt +++ b/firebase-crashlytics/src/jvmMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.jvm.kt @@ -58,4 +58,4 @@ actual class FirebaseCrashlytics { } } -actual open class FirebaseCrashlyticsException : FirebaseException() \ No newline at end of file +actual open class FirebaseCrashlyticsException internal constructor(message: String) : FirebaseException(message) \ No newline at end of file diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index acdc0f213..1d010fb8a 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -52,7 +54,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -75,7 +86,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -122,6 +134,9 @@ kotlin { optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.coroutines.FlowPreview") optIn("kotlinx.serialization.InternalSerializationApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -132,7 +147,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -147,20 +162,8 @@ kotlin { api("com.google.firebase:firebase-database-ktx") } } - - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) + getByName("jvmMain") { + kotlin.srcDir("src/androidMain/kotlin") } } } diff --git a/firebase-database/package.json b/firebase-database/package.json index c72c583fb..2251ea0f5 100644 --- a/firebase-database/package.json +++ b/firebase-database/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-database", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-database.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt index fb57e4883..d0b8ea390 100644 --- a/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -10,6 +10,5 @@ import androidx.test.platform.app.InstrumentationRegistry actual val emulatorHost: String = "10.0.2.2" actual val context: Any = InstrumentationRegistry.getInstrumentation().targetContext - @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest diff --git a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt index e586ccf99..0ce0e0d12 100644 --- a/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidMain/kotlin/dev/gitlive/firebase/database/database.kt @@ -30,7 +30,7 @@ suspend fun Task.awaitWhileOnline(): T = .reference(".info/connected") .valueEvents .debounce(2.seconds) - .filter { !it.value() } + .filterNot { it.value() } .map { throw DatabaseException("Database not connected", null) } ) .first() diff --git a/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt index 475c55e58..b0fbae1d3 100644 --- a/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/androidUnitTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -10,9 +10,4 @@ import org.junit.Ignore actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" - -// Tests are to be run on AndroidInstrumentedTests. -// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest -// Therefore we just wont run them -// Kotlin 1.9 will introduce methods for disabling tests properly actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt index 66706aa1c..00a8f85dc 100644 --- a/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt +++ b/firebase-database/src/commonTest/kotlin/dev/gitlive/firebase/database/database.kt @@ -5,7 +5,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.first import kotlinx.coroutines.withContext import kotlinx.coroutines.withTimeout -import kotlinx.serialization.* +import kotlinx.serialization.Serializable +import kotlinx.serialization.SerializationStrategy import kotlin.test.* import kotlin.time.Duration.Companion.minutes diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 976c5bc98..41ae04f24 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -49,7 +51,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -72,10 +83,11 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { - ios.deploymentTarget = "11.0" + ios.deploymentTarget = "12.0" framework { baseName = "FirebaseFirestore" } @@ -141,7 +153,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -149,29 +161,13 @@ kotlin { getByName("androidMain") { dependencies { - api("com.google.firebase:firebase-firestore-ktx") - } - } - - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) + api("com.google.firebase:firebase-firestore") } } getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-firestore/package.json b/firebase-firestore/package.json index 9ad0a0155..02a96298c 100644 --- a/firebase-firestore/package.json +++ b/firebase-firestore/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-firestore", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-firestore.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 3801a31ce..dcc6a2ebc 100644 --- a/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/androidMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -5,9 +5,8 @@ @file:JvmName("android") package dev.gitlive.firebase.firestore -import com.google.firebase.Timestamp -import com.google.firebase.firestore.MetadataChanges -import com.google.firebase.firestore.SetOptions +import com.google.android.gms.tasks.Task +import com.google.firebase.firestore.* import dev.gitlive.firebase.* import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.Flow diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt index 6dc5fa45f..9ed088172 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/FieldValueTests.kt @@ -1,5 +1,6 @@ package dev.gitlive.firebase.firestore +import dev.gitlive.firebase.firebaseSerializer import dev.gitlive.firebase.runTest import kotlin.test.Test import kotlin.test.assertEquals diff --git a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index a567c8cd2..8b2956682 100644 --- a/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/commonTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -55,7 +55,7 @@ class FirebaseFirestoreTest { @BeforeTest fun initializeFirebase() { - val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( context, FirebaseOptions( applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", @@ -69,6 +69,7 @@ class FirebaseFirestoreTest { firestore = Firebase.firestore(app).apply { useEmulator(emulatorHost, 8080) + setSettings(persistenceEnabled = false) } } @@ -535,7 +536,7 @@ class FirebaseFirestoreTest { .document("three") .set(FirestoreTest.serializer(), FirestoreTest("ccc")) } - + private suspend fun nonSkippedDelay(timeout: Long) = withContext(Dispatchers.Default) { delay(timeout) } diff --git a/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt new file mode 100644 index 000000000..ac4e668eb --- /dev/null +++ b/firebase-firestore/src/iosTest/kotlin/dev/gitlive/firebase/firestore/ContextSwitchTest.kt @@ -0,0 +1,145 @@ +package dev.gitlive.firebase.firestore + +import dev.gitlive.firebase.* +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.MainScope +import kotlinx.coroutines.async +import kotlinx.coroutines.newSingleThreadContext +import kotlinx.coroutines.runBlocking +import kotlinx.coroutines.withContext +import kotlinx.coroutines.yield +import kotlinx.serialization.Serializable +import kotlinx.serialization.builtins.ListSerializer +import kotlinx.serialization.builtins.nullable +import kotlinx.serialization.builtins.serializer +import platform.Foundation.NSDate +import platform.Foundation.NSDefaultRunLoopMode +import platform.Foundation.NSRunLoop +import platform.Foundation.create +import platform.Foundation.runMode +import kotlin.test.AfterTest +import kotlin.test.BeforeTest +import kotlin.test.Test +import kotlin.test.assertEquals + + +private val backgroundContext = newSingleThreadContext("background") +/** + * This function performs is intended to test object sharing across several threads. + * @param create a block for object creation + * @param test a block to perform test on a thread different from the one used in [create] + */ +fun runTestWithContextSwitch(create: suspend CoroutineScope.() -> T, test: suspend CoroutineScope.(T) -> Unit) = + runBlocking { + val testRun = MainScope().async { + val objMain = create() + withContext(backgroundContext) { + test(objMain) + } + val objBcg = withContext(backgroundContext) { + create() + } + test(objBcg) + } + while (testRun.isActive) { + NSRunLoop.mainRunLoop.runMode( + NSDefaultRunLoopMode, + beforeDate = NSDate.create(timeInterval = 1.0, sinceDate = NSDate()) + ) + yield() + } + testRun.await() + } + + +class ContextSwitchTest { + + lateinit var firestore: FirebaseFirestore + + @BeforeTest + fun initializeFirebase() { + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( + context, + FirebaseOptions( + applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", + apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", + databaseUrl = "https://fir-kotlin-sdk.firebaseio.com", + storageBucket = "fir-kotlin-sdk.appspot.com", + projectId = "fir-kotlin-sdk", + gcmSenderId = "846484016111" + ) + ) + + firestore = Firebase.firestore(app).apply { + useEmulator(emulatorHost, 8080) + } + } + + @AfterTest + fun deinitializeFirebase() = runBlockingTest { + Firebase.apps(context).forEach { + it.delete() + } + } + + private data class TestFieldValuesOps( + val initial: List, + val updates: List + ) { + data class Update( + val op: Pair, + val expected: List? + ) + } + + @Serializable + data class TestData(val values: List) + + @Test + fun testFieldValuesOps() = runTestWithContextSwitch( + create = { + TestFieldValuesOps( + initial = listOf(1), + updates = listOf( + TestFieldValuesOps.Update( + FieldPath(TestData::values.name) to FieldValue.arrayUnion(2), + listOf(1, 2) + ), + TestFieldValuesOps.Update( + FieldPath(TestData::values.name) to FieldValue.arrayRemove(1), + listOf(2) + ), + TestFieldValuesOps.Update( + FieldPath(TestData::values.name) to FieldValue.delete, + null + ) + ) + ) + } + ) { data -> + + fun getDocument() = firestore.collection("fieldValuesOps") + .document("fieldValuesOps") + + // store + getDocument().set(strategy = TestData.serializer(), data = TestData(data.initial), merge = false) + + // append & verify + getDocument().update(data.updates[0].op) + + var savedData = getDocument().get().data(TestData.serializer()) + assertEquals(data.updates[0].expected, savedData.values) + + // remove & verify + getDocument().update(data.updates[1].op) + savedData = getDocument().get().data(TestData.serializer()) + assertEquals(data.updates[1].expected, savedData.values) + + val list = getDocument().get().get(TestData::values.name, ListSerializer(Int.serializer()).nullable) + assertEquals(data.updates[1].expected, list) + // delete & verify + getDocument().update(data.updates[2].op) + val deletedList = getDocument().get().get(TestData::values.name, ListSerializer(Int.serializer()).nullable) + assertEquals(data.updates[2].expected, deletedList) + } +} \ No newline at end of file diff --git a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt index f28d93276..52e53d749 100644 --- a/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/jsTest/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -10,3 +10,4 @@ actual val context: Any = Unit @Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION) actual annotation class IgnoreForAndroidUnitTest + diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 3d4902db9..5b0ba1531 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -46,7 +48,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -56,7 +67,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -66,6 +78,7 @@ kotlin { noPodspec() pod("FirebaseFunctions") { version = "10.15.0" + extraOpts += listOf("-compiler-option", "-fmodules") } } } @@ -110,6 +123,9 @@ kotlin { progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") optIn("kotlinx.serialization.InternalSerializationApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -120,7 +136,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -132,24 +148,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-functions/package.json b/firebase-functions/package.json index a11c484e1..c18b774e4 100644 --- a/firebase-functions/package.json +++ b/firebase-functions/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-functions", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-functions.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt index 16acdc7a1..10ddc4821 100644 --- a/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/androidMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -52,3 +52,10 @@ actual class HttpsCallableResult constructor(val android: com.google.firebase.fu } actual typealias FirebaseFunctionsException = com.google.firebase.functions.FirebaseFunctionsException + +actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code + +actual val FirebaseFunctionsException.details: Any? get() = details + +actual typealias FunctionsExceptionCode = com.google.firebase.functions.FirebaseFunctionsException.Code + diff --git a/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt index f1f3a225a..300c66726 100644 --- a/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -39,3 +39,29 @@ expect fun Firebase.functions(app: FirebaseApp): FirebaseFunctions expect fun Firebase.functions(app: FirebaseApp, region: String): FirebaseFunctions expect class FirebaseFunctionsException: FirebaseException + +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") +expect val FirebaseFunctionsException.code: FunctionsExceptionCode + +@Suppress("EXTENSION_SHADOWED_BY_MEMBER") +expect val FirebaseFunctionsException.details: Any? + +expect enum class FunctionsExceptionCode { + OK, + CANCELLED, + UNKNOWN, + INVALID_ARGUMENT, + DEADLINE_EXCEEDED, + NOT_FOUND, + ALREADY_EXISTS, + PERMISSION_DENIED, + RESOURCE_EXHAUSTED, + FAILED_PRECONDITION, + ABORTED, + OUT_OF_RANGE, + UNIMPLEMENTED, + INTERNAL, + UNAVAILABLE, + DATA_LOSS, + UNAUTHENTICATED +} diff --git a/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt index e705ca9ab..8ff0a5e11 100644 --- a/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/iosMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -4,16 +4,14 @@ package dev.gitlive.firebase.functions -import cocoapods.FirebaseFunctions.* -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseApp -import dev.gitlive.firebase.FirebaseException -import dev.gitlive.firebase.decode -import dev.gitlive.firebase.encode +import cocoapods.FirebaseFunctions.FIRFunctions +import cocoapods.FirebaseFunctions.FIRHTTPSCallable +import cocoapods.FirebaseFunctions.FIRHTTPSCallableResult +import dev.gitlive.firebase.* import kotlinx.coroutines.CompletableDeferred import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.SerializationStrategy -import platform.Foundation.* +import platform.Foundation.NSError actual val Firebase.functions get() = FirebaseFunctions(FIRFunctions.functions()) @@ -58,7 +56,55 @@ actual class HttpsCallableResult constructor(val ios: FIRHTTPSCallableResult) { decode(strategy, ios.data()) } -actual class FirebaseFunctionsException(message: String): FirebaseException(message) +actual class FirebaseFunctionsException(message: String, val code: FunctionsExceptionCode, val details: Any?) : FirebaseException(message) + +actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code + +actual val FirebaseFunctionsException.details: Any? get() = details + +actual enum class FunctionsExceptionCode { + OK, + CANCELLED, + UNKNOWN, + INVALID_ARGUMENT, + DEADLINE_EXCEEDED, + NOT_FOUND, + ALREADY_EXISTS, + PERMISSION_DENIED, + RESOURCE_EXHAUSTED, + FAILED_PRECONDITION, + ABORTED, + OUT_OF_RANGE, + UNIMPLEMENTED, + INTERNAL, + UNAVAILABLE, + DATA_LOSS, + UNAUTHENTICATED +} +//todo uncomment once https://github.com/firebase/firebase-ios-sdk/issues/11862 fixed +fun NSError.toException() = when(domain) { +// FIRFunctionsErrorDomain -> when(code) { +// FIRFunctionsErrorCodeOK -> FunctionsExceptionCode.OK +// FIRFunctionsErrorCodeCancelled -> FunctionsExceptionCode.CANCELLED +// FIRFunctionsErrorCodeUnknown -> FunctionsExceptionCode.UNKNOWN +// FIRFunctionsErrorCodeInvalidArgument -> FunctionsExceptionCode.INVALID_ARGUMENT +// FIRFunctionsErrorCodeDeadlineExceeded -> FunctionsExceptionCode.DEADLINE_EXCEEDED +// FIRFunctionsErrorCodeNotFound -> FunctionsExceptionCode.NOT_FOUND +// FIRFunctionsErrorCodeAlreadyExists -> FunctionsExceptionCode.ALREADY_EXISTS +// FIRFunctionsErrorCodePermissionDenied -> FunctionsExceptionCode.PERMISSION_DENIED +// FIRFunctionsErrorCodeResourceExhausted -> FunctionsExceptionCode.RESOURCE_EXHAUSTED +// FIRFunctionsErrorCodeFailedPrecondition -> FunctionsExceptionCode.FAILED_PRECONDITION +// FIRFunctionsErrorCodeAborted -> FunctionsExceptionCode.ABORTED +// FIRFunctionsErrorCodeOutOfRange -> FunctionsExceptionCode.OUT_OF_RANGE +// FIRFunctionsErrorCodeUnimplemented -> FunctionsExceptionCode.UNIMPLEMENTED +// FIRFunctionsErrorCodeInternal -> FunctionsExceptionCode.INTERNAL +// FIRFunctionsErrorCodeUnavailable -> FunctionsExceptionCode.UNAVAILABLE +// FIRFunctionsErrorCodeDataLoss -> FunctionsExceptionCode.DATA_LOSS +// FIRFunctionsErrorCodeUnauthenticated -> FunctionsExceptionCode.UNAUTHENTICATED +// else -> FunctionsExceptionCode.UNKNOWN +// } + else -> FunctionsExceptionCode.UNKNOWN +}.let { FirebaseFunctionsException(description!!, it, null/*userInfo[FIRFunctionsErrorDetails]*/) } suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Unit) { val job = CompletableDeferred() @@ -66,7 +112,7 @@ suspend inline fun T.await(function: T.(callback: (NSError?) -> Unit) -> Uni if(error == null) { job.complete(Unit) } else { - job.completeExceptionally(FirebaseFunctionsException(error.localizedDescription)) + job.completeExceptionally(error.toException()) } } job.await() @@ -78,7 +124,7 @@ suspend inline fun T.awaitResult(function: T.(callback: (R?, NSEr if(error == null) { job.complete(result) } else { - job.completeExceptionally(FirebaseFunctionsException(error.localizedDescription)) + job.completeExceptionally(error.toException()) } } return job.await() as R diff --git a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt index 419deb7ce..1e06a16c5 100644 --- a/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt +++ b/firebase-functions/src/jsMain/kotlin/dev/gitlive/firebase/functions/functions.kt @@ -9,7 +9,6 @@ import dev.gitlive.firebase.functions.externals.* import kotlinx.coroutines.await import kotlinx.serialization.DeserializationStrategy import kotlinx.serialization.SerializationStrategy -import org.w3c.dom.url.URL import kotlin.js.json import dev.gitlive.firebase.functions.externals.HttpsCallableResult as JsHttpsCallableResult @@ -55,7 +54,31 @@ actual class HttpsCallableResult constructor(val js: JsHttpsCallableResult) { } -actual open class FirebaseFunctionsException(code: String?, cause: Throwable): FirebaseException(code, cause) +actual class FirebaseFunctionsException(cause: Throwable, val code: FunctionsExceptionCode, val details: Any?) : FirebaseException(cause.message, cause) + +actual val FirebaseFunctionsException.code: FunctionsExceptionCode get() = code + +actual val FirebaseFunctionsException.details: Any? get() = details + +actual enum class FunctionsExceptionCode { + OK, + CANCELLED, + UNKNOWN, + INVALID_ARGUMENT, + DEADLINE_EXCEEDED, + NOT_FOUND, + ALREADY_EXISTS, + PERMISSION_DENIED, + RESOURCE_EXHAUSTED, + FAILED_PRECONDITION, + ABORTED, + OUT_OF_RANGE, + UNIMPLEMENTED, + INTERNAL, + UNAVAILABLE, + DATA_LOSS, + UNAUTHENTICATED +} inline fun T.rethrow(function: T.() -> R): R = dev.gitlive.firebase.functions.rethrow { function() } @@ -65,6 +88,34 @@ inline fun rethrow(function: () -> R): R { } catch (e: Exception) { throw e } catch(e: dynamic) { - throw FirebaseFunctionsException(e.code as String?, e) + throw errorToException(e) } } + +fun errorToException(e: dynamic) = (e?.code ?: e?.message ?: "") + .toString() + .lowercase() + .let { + when { + "cancelled" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.CANCELLED, e.details) + "invalid-argument" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.INVALID_ARGUMENT, e.details) + "deadline-exceeded" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.DEADLINE_EXCEEDED, e.details) + "not-found" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.NOT_FOUND, e.details) + "already-exists" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.ALREADY_EXISTS, e.details) + "permission-denied" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.PERMISSION_DENIED, e.details) + "resource-exhausted" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.RESOURCE_EXHAUSTED, e.details) + "failed-precondition" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.FAILED_PRECONDITION, e.details) + "aborted" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.ABORTED, e.details) + "out-of-range" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.OUT_OF_RANGE, e.details) + "unimplemented" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNIMPLEMENTED, e.details) + "internal" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.INTERNAL, e.details) + "unavailable" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNAVAILABLE, e.details) + "data-loss" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.DATA_LOSS, e.details) + "unauthenticated" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNAUTHENTICATED, e.details) + "unknown" in it -> FirebaseFunctionsException(e, FunctionsExceptionCode.UNKNOWN, e.details) + else -> { + println("Unknown error code in ${JSON.stringify(e)}") + FirebaseFunctionsException(e, FunctionsExceptionCode.UNKNOWN, e.details) + } + } + } diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index 858a4bf9b..f0d5c0cc2 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -46,7 +48,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -69,7 +80,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -113,6 +125,9 @@ kotlin { this.apiVersion = apiVersion this.languageVersion = languageVersion progressiveMode = true + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -123,7 +138,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -135,24 +150,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - getByName("jvmMain") { kotlin.srcDir("src/androidMain/kotlin") } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-installations/package.json b/firebase-installations/package.json index ecdc9e65a..af5d99226 100644 --- a/firebase-installations/package.json +++ b/firebase-installations/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-installations", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-installations.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.8.20", "kotlinx-coroutines-core": "1.6.4" diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index fd57f9bc5..e79a99ded 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2020 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -47,7 +49,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -70,7 +81,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -106,6 +118,9 @@ kotlin { this.languageVersion = languageVersion progressiveMode = true optIn("kotlinx.coroutines.ExperimentalCoroutinesApi") + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -116,7 +131,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -128,25 +143,9 @@ kotlin { } } - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - // getByName("jvmMain") { // kotlin.srcDir("src/androidMain/kotlin") // } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by sourceSets.getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-perf/package.json b/firebase-perf/package.json index 29798b347..e53193deb 100644 --- a/firebase-perf/package.json +++ b/firebase-perf/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-perf", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-perf.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 4bed80ff9..6768f9247 100644 --- a/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/androidInstrumentedTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -1,9 +1,6 @@ package dev.gitlive.firebase.perf.metrics -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseOptions -import dev.gitlive.firebase.apps -import dev.gitlive.firebase.initialize +import dev.gitlive.firebase.* import dev.gitlive.firebase.perf.FirebasePerformance import dev.gitlive.firebase.perf.context import dev.gitlive.firebase.perf.performance @@ -22,7 +19,7 @@ class AndroidTraceTest { @BeforeTest fun initializeFirebase() { - val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( dev.gitlive.firebase.perf.context, FirebaseOptions( applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", @@ -40,7 +37,7 @@ class AndroidTraceTest { @AfterTest fun deinitializeFirebase() = runBlockingTest { // Performance runs installation in the background, which crashes if the app is deleted before completion - delay(1.seconds) + delay(5.seconds) Firebase.apps(context).forEach { it.delete() } diff --git a/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 0ab0e47da..a69661aac 100644 --- a/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/androidUnitTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -5,15 +5,10 @@ @file:JvmName("tests") package dev.gitlive.firebase.perf -import kotlinx.coroutines.CoroutineScope import org.junit.Ignore actual val emulatorHost: String = "10.0.2.2" actual val context: Any = "" -// Tests are to be run on AndroidInstrumentedTests. -// Kotlin 1.8 does not allow us to remove the commonTest dependency from AndroidUnitTest -// Therefore we just wont run them -// Kotlin 1.9 will introduce methods for disabling tests properly actual typealias IgnoreForAndroidUnitTest = Ignore diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 2cee8d86f..65ccafb65 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -1,9 +1,6 @@ package dev.gitlive.firebase.perf.metrics -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseOptions -import dev.gitlive.firebase.apps -import dev.gitlive.firebase.initialize +import dev.gitlive.firebase.* import dev.gitlive.firebase.perf.FirebasePerformance import dev.gitlive.firebase.perf.IgnoreForAndroidUnitTest import dev.gitlive.firebase.perf.context @@ -71,7 +68,7 @@ class TraceTest { } @Test - fun testPutMetric() { + fun testPutMetric() = runTest { val trace = performance.newTrace("testPutMetric") trace.start() trace.putMetric("Get Put Metric Test", 1L) diff --git a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt index 171754b4d..fae090c5c 100644 --- a/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/commonTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -4,13 +4,12 @@ package dev.gitlive.firebase.perf -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseOptions -import dev.gitlive.firebase.apps -import dev.gitlive.firebase.initialize -import dev.gitlive.firebase.runBlockingTest -import dev.gitlive.firebase.runTest +import dev.gitlive.firebase.* +import kotlinx.coroutines.CoroutineScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.test.TestResult import kotlin.test.* +import kotlin.time.Duration.Companion.seconds expect val emulatorHost: String expect val context: Any @@ -40,6 +39,8 @@ class FirebasePerformanceTest { @AfterTest fun deinitializeFirebase() = runBlockingTest { + // Performance runs installation in the background, which crashes if the app is deleted before completion + delay(5.seconds) Firebase.apps(context).forEach { it.delete() } @@ -47,7 +48,6 @@ class FirebasePerformanceTest { @Test fun testNewTrace() = runTest { - val trace = performance.newTrace("Test Trace") assertNotNull(trace) @@ -55,7 +55,6 @@ class FirebasePerformanceTest { @Test fun testPerformanceCollectionEnabled() = runTest { - performance.setPerformanceCollectionEnabled(false) assertFalse(performance.isPerformanceCollectionEnabled()) diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt index 1cdb6f57b..c732a4a82 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/metrics/Trace.kt @@ -1,9 +1,6 @@ package dev.gitlive.firebase.perf.metrics -import dev.gitlive.firebase.Firebase -import dev.gitlive.firebase.FirebaseOptions -import dev.gitlive.firebase.apps -import dev.gitlive.firebase.initialize +import dev.gitlive.firebase.* import dev.gitlive.firebase.perf.FirebasePerformance import dev.gitlive.firebase.perf.context import dev.gitlive.firebase.perf.performance @@ -19,8 +16,8 @@ class JsTraceTest { @BeforeTest fun initializeFirebase() { - val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( - dev.gitlive.firebase.perf.context, + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( + context, FirebaseOptions( applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", apiKey = "AIzaSyCK87dcMFhzCz_kJVs2cT2AVlqOTLuyWV0", @@ -42,7 +39,7 @@ class JsTraceTest { } @Test - fun testGetAttribute() { + fun testGetAttribute() = runTest { val trace = performance.newTrace("testGetAttribute") trace.start() trace.putAttribute("Test_Get_Attribute", "Test Get Attribute Value") @@ -52,7 +49,7 @@ class JsTraceTest { } @Test - fun testPutAttribute() { + fun testPutAttribute() = runTest { val trace = performance.newTrace("testPutAttribute") trace.start() trace.putAttribute("Test_Put_Attribute", "Test Put Attribute Value") diff --git a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt index d5c91ca0c..20df3778f 100644 --- a/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt +++ b/firebase-perf/src/jsTest/kotlin/dev/gitlive/firebase/perf/performance.kt @@ -24,7 +24,7 @@ class JsPerformanceTest { @BeforeTest fun initializeFirebase() { - val app = Firebase.apps(context).firstOrNull() ?:Firebase.initialize( + val app = Firebase.apps(context).firstOrNull() ?: Firebase.initialize( context, FirebaseOptions( applicationId = "1:846484016111:ios:dd1f6688bad7af768c841a", @@ -41,9 +41,6 @@ class JsPerformanceTest { @Test fun testInstrumentationEnabled() = runTest { - - val performance = Firebase.performance - performance.setInstrumentationEnabled(false) assertFalse(performance.isInstrumentationEnabled()) diff --git a/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt b/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt index f77c9e0cb..941a3bd8a 100644 --- a/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt +++ b/firebase-perf/src/jvmMain/kotlin/dev/gitlive/firebase/perf/performance.jvm.kt @@ -28,4 +28,4 @@ actual class FirebasePerformance { } -actual open class FirebasePerformanceException : FirebaseException() \ No newline at end of file +actual open class FirebasePerformanceException internal constructor(message: String) : FirebaseException(message) \ No newline at end of file diff --git a/firebase-storage/build.gradle.kts b/firebase-storage/build.gradle.kts index bd183e6e5..1afcfefdb 100644 --- a/firebase-storage/build.gradle.kts +++ b/firebase-storage/build.gradle.kts @@ -1,3 +1,5 @@ +import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSetTree + /* * Copyright (c) 2023 GitLive Ltd. Use of this source code is governed by the Apache 2.0 license. */ @@ -46,7 +48,16 @@ val supportIosTarget = project.property("skipIosTarget") != "true" kotlin { + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { + instrumentedTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) + unitTestVariant.sourceSetTree.set(KotlinSourceSetTree.test) publishAllLibraryVariants() compilations.configureEach { kotlinOptions { @@ -69,7 +80,8 @@ kotlin { } if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() cocoapods { ios.deploymentTarget = "11.0" @@ -79,6 +91,7 @@ kotlin { noPodspec() pod("FirebaseStorage") { version = "10.15.0" + extraOpts += listOf("-compiler-option", "-fmodules") } } } @@ -113,6 +126,9 @@ kotlin { this.apiVersion = apiVersion this.languageVersion = languageVersion progressiveMode = true + if (name.lowercase().contains("ios")) { + optIn("kotlinx.cinterop.ExperimentalForeignApi") + } } } @@ -123,7 +139,7 @@ kotlin { } } - val commonTest by getting { + getByName("commonTest") { dependencies { implementation(project(":test-utils")) } @@ -134,21 +150,6 @@ kotlin { api("com.google.firebase:firebase-storage") } } - - getByName("androidInstrumentedTest") { - dependencies { - dependsOn(commonTest) - } - } - - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } } } diff --git a/firebase-storage/package.json b/firebase-storage/package.json index b48bc7b14..92ff99ae6 100644 --- a/firebase-storage/package.json +++ b/firebase-storage/package.json @@ -1,6 +1,6 @@ { "name": "@gitlive/firebase-storage", - "version": "1.10.1", + "version": "1.10.4", "description": "Wrapper around firebase for usage in Kotlin Multiplatform projects", "main": "firebase-storage.js", "scripts": { @@ -23,7 +23,7 @@ }, "homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk", "dependencies": { - "@gitlive/firebase-app": "1.10.1", + "@gitlive/firebase-app": "1.10.4", "firebase": "9.19.1", "kotlin": "1.6.10", "kotlinx-coroutines-core": "1.6.1-native-mt" diff --git a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt index d517e9949..0b96512af 100644 --- a/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt +++ b/firebase-storage/src/commonTest/kotlin/dev/gitlive/firebase/storage/storage.kt @@ -37,5 +37,4 @@ class FirebaseStorageTest { useEmulator(emulatorHost, 9199) } } - } \ No newline at end of file diff --git a/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt b/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt index 2d1f07ca4..cc61e378b 100644 --- a/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt +++ b/firebase-storage/src/jvmMain/kotlin/dev/gitlive/firebase/storage/storage.jvm.kt @@ -85,4 +85,4 @@ actual class ListResult { } actual class File -actual class FirebaseStorageException : FirebaseException() \ No newline at end of file +actual class FirebaseStorageException internal constructor(message: String) : FirebaseException(message) \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ab4e01cb9..b6c72a41e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,8 +11,6 @@ kotlin.mpp.stability.nowarn=true #kotlin.native.enableDependencyPropagation=false kotlin.native.enableParallelExecutionCheck=false kotlin.setJvmTargetFromAndroidCompileOptions=true -kotlin.native.binary.memoryModel=experimental -kotlin.native.binary.freezing=disabled org.gradle.jvmargs=-Xmx8G -Dfile.encoding\=UTF-8 -XX:MaxMetaspaceSize=512m -Dkotlin.daemon.jvm.options\=-Xmx8G,-XX:MaxMetaspaceSize=512m org.gradle.parallel=true systemProp.org.gradle.internal.publish.checksums.insecure=true @@ -49,23 +47,23 @@ firebase-perf.skipJsTests=false firebase-storage.skipJsTests=false # Versions: -firebase-app.version=1.10.1 -firebase-auth.version=1.10.1 -firebase-common.version=1.10.1 -firebase-config.version=1.10.1 -firebase-database.version=1.10.1 -firebase-firestore.version=1.10.1 -firebase-functions.version=1.10.1 -firebase-installations.version=1.10.1 -firebase-perf.version=1.10.1 -firebase-crashlytics.version=1.10.1 -firebase-storage.version=1.10.1 +firebase-app.version=1.10.4 +firebase-auth.version=1.10.4 +firebase-common.version=1.10.4 +firebase-config.version=1.10.4 +firebase-database.version=1.10.4 +firebase-firestore.version=1.10.4 +firebase-functions.version=1.10.4 +firebase-installations.version=1.10.4 +firebase-perf.version=1.10.4 +firebase-crashlytics.version=1.10.4 +firebase-storage.version=1.10.4 # Dependencies Versions: -gradlePluginVersion=8.1.1 -kotlinVersion=1.9.10 +gradlePluginVersion=8.1.3 +kotlinVersion=1.9.20 coroutinesVersion=1.7.3 serializationVersion=1.6.0 -firebaseBoMVersion=32.2.3 +firebaseBoMVersion=32.5.0 apiVersion=1.8 languageVersion=1.9 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fae08049a..e411586a5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/test-utils/build.gradle.kts b/test-utils/build.gradle.kts index a3b1a0558..d8f7ea223 100644 --- a/test-utils/build.gradle.kts +++ b/test-utils/build.gradle.kts @@ -40,6 +40,14 @@ android { } kotlin { + + targets.configureEach { + compilations.configureEach { + kotlinOptions.freeCompilerArgs += "-Xexpect-actual-classes" + } + } + + @Suppress("OPT_IN_USAGE") androidTarget { publishAllLibraryVariants() compilations.configureEach { @@ -65,7 +73,8 @@ kotlin { val supportIosTarget = project.property("skipIosTarget") != "true" if (supportIosTarget) { - ios() + iosArm64() + iosX64() iosSimulatorArm64() } @@ -96,7 +105,6 @@ kotlin { api(kotlin("test")) api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") api("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") - } } @@ -104,15 +112,6 @@ kotlin { kotlin.srcDir("src/androidMain/kotlin") } - if (supportIosTarget) { - val iosMain by getting - val iosSimulatorArm64Main by getting - iosSimulatorArm64Main.dependsOn(iosMain) - val iosTest by sourceSets.getting - val iosSimulatorArm64Test by getting - iosSimulatorArm64Test.dependsOn(iosTest) - } - getByName("jsMain") { dependencies { implementation(kotlin("test-js")) diff --git a/test-utils/src/androidMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/androidMain/kotlin/dev/gitlive/firebase/TestUtils.kt index c72c78980..1a4635f85 100644 --- a/test-utils/src/androidMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/androidMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -7,11 +7,12 @@ package dev.gitlive.firebase import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.runBlocking +import kotlin.time.Duration.Companion.minutes -actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest { test() } +actual fun runTest(test: suspend CoroutineScope.() -> Unit) = kotlinx.coroutines.test.runTest(timeout = 5.minutes) { test() } actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) = runBlocking(block = action) -actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) +actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) actual fun nativeListOf(vararg elements: Any): Any = listOf(*elements) actual fun nativeAssertEquals(expected: Any?, actual: Any?) { kotlin.test.assertEquals(expected, actual) diff --git a/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt index 02d5f6873..bf9fcdc19 100644 --- a/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/commonMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -12,6 +12,6 @@ import kotlin.jvm.JvmName expect fun runTest(test: suspend CoroutineScope.() -> Unit): TestResult expect fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) -expect fun nativeMapOf(vararg pairs: Pair): Any +expect fun nativeMapOf(vararg pairs: Pair): Any expect fun nativeListOf(vararg elements: Any): Any expect fun nativeAssertEquals(expected: Any?, actual: Any?) diff --git a/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt index eaea5f84d..6ba4248a4 100644 --- a/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/iosMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -27,8 +27,7 @@ actual fun runTest(test: suspend CoroutineScope.() -> Unit) = runBlocking { testRun.await() } actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) = runBlocking(block = action) - -actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) +actual fun nativeMapOf(vararg pairs: Pair): Any = mapOf(*pairs) actual fun nativeListOf(vararg elements: Any): Any = listOf(*elements) actual fun nativeAssertEquals(expected: Any?, actual: Any?) { kotlin.test.assertEquals(expected, actual) diff --git a/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt b/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt index f3e60277a..eac94efcf 100644 --- a/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt +++ b/test-utils/src/jsMain/kotlin/dev/gitlive/firebase/TestUtils.kt @@ -14,7 +14,7 @@ actual fun runBlockingTest(action: suspend CoroutineScope.() -> Unit) { kotlinx.coroutines.test.runTest { action() } } -actual fun nativeMapOf(vararg pairs: Pair): Any = json(*pairs) +actual fun nativeMapOf(vararg pairs: Pair): Any = json(*pairs.map { (key, value) -> ((key as? String) ?: JSON.stringify(key)) to value }.toTypedArray()) actual fun nativeListOf(vararg elements: Any): Any = elements actual fun nativeAssertEquals(expected: Any?, actual: Any?) { kotlin.test.assertEquals(JSON.stringify(expected), JSON.stringify(actual)) From ad0ea3913a21c278912e2ec766419125cd05f7c1 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Mon, 20 Nov 2023 10:41:27 +0100 Subject: [PATCH 26/29] Use Firebase 10.17 --- firebase-app/build.gradle.kts | 2 +- firebase-auth/build.gradle.kts | 2 +- firebase-config/build.gradle.kts | 2 +- firebase-crashlytics/build.gradle.kts | 2 +- firebase-database/build.gradle.kts | 2 +- firebase-firestore/build.gradle.kts | 8 +++++++- .../kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt | 2 +- .../kotlin/dev/gitlive/firebase/firestore/Timestamp.kt | 2 +- .../kotlin/dev/gitlive/firebase/firestore/firestore.kt | 4 ++-- firebase-functions/build.gradle.kts | 2 +- firebase-installations/build.gradle.kts | 2 +- firebase-perf/build.gradle.kts | 2 +- firebase-storage/build.gradle.kts | 2 +- 13 files changed, 20 insertions(+), 14 deletions(-) diff --git a/firebase-app/build.gradle.kts b/firebase-app/build.gradle.kts index 084431b7e..e670990de 100644 --- a/firebase-app/build.gradle.kts +++ b/firebase-app/build.gradle.kts @@ -87,7 +87,7 @@ kotlin { } noPodspec() pod("FirebaseCore") { - version = "10.15.0" + version = "10.17.0" } } } diff --git a/firebase-auth/build.gradle.kts b/firebase-auth/build.gradle.kts index 07f2f9fce..f6be71ed4 100644 --- a/firebase-auth/build.gradle.kts +++ b/firebase-auth/build.gradle.kts @@ -91,7 +91,7 @@ kotlin { } noPodspec() pod("FirebaseAuth") { - version = "10.15.0" + version = "10.17.0" } } } diff --git a/firebase-config/build.gradle.kts b/firebase-config/build.gradle.kts index 30dd776c3..f483faf1f 100644 --- a/firebase-config/build.gradle.kts +++ b/firebase-config/build.gradle.kts @@ -104,7 +104,7 @@ kotlin { } noPodspec() pod("FirebaseRemoteConfig") { - version = "10.15.0" + version = "10.17.0" } } } diff --git a/firebase-crashlytics/build.gradle.kts b/firebase-crashlytics/build.gradle.kts index eba332d66..8bbd2bb44 100644 --- a/firebase-crashlytics/build.gradle.kts +++ b/firebase-crashlytics/build.gradle.kts @@ -91,7 +91,7 @@ kotlin { } noPodspec() pod("FirebaseCrashlytics") { - version = "10.15.0" + version = "10.17.0" } } } diff --git a/firebase-database/build.gradle.kts b/firebase-database/build.gradle.kts index 1d010fb8a..2a4b21154 100644 --- a/firebase-database/build.gradle.kts +++ b/firebase-database/build.gradle.kts @@ -96,7 +96,7 @@ kotlin { } noPodspec() pod("FirebaseDatabase") { - version = "10.15.0" + version = "10.17.0" } } } diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 41ae04f24..79c5b3788 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -93,7 +93,13 @@ kotlin { } noPodspec() pod("FirebaseFirestore") { - version = "10.15.0" + version = "10.17.0" + extraOpts += listOf("-compiler-option", "-fmodules") + } + // As of Firebase 10.17 Firestore has moved all ObjC headers to FirebaseFirestoreInternal and the kotlin cocoapods plugin does not handle this well + // Adding it manually seems to resolve the issue + pod("FirebaseFirestoreInternal") { + version = "10.17.0" } } } diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt index d4c0aa98f..7e54257da 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/GeoPoint.kt @@ -1,6 +1,6 @@ package dev.gitlive.firebase.firestore -import cocoapods.FirebaseFirestore.FIRGeoPoint +import cocoapods.FirebaseFirestoreInternal.FIRGeoPoint import kotlinx.serialization.Serializable diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt index 926fdd819..aeedf8d01 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/Timestamp.kt @@ -1,6 +1,6 @@ package dev.gitlive.firebase.firestore -import cocoapods.FirebaseFirestore.FIRTimestamp +import cocoapods.FirebaseFirestoreInternal.FIRTimestamp import kotlinx.serialization.Serializable /** A class representing a platform specific Firebase Timestamp. */ diff --git a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt index 2709c9e37..e7baf2583 100644 --- a/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt +++ b/firebase-firestore/src/iosMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt @@ -4,8 +4,8 @@ package dev.gitlive.firebase.firestore -import cocoapods.FirebaseFirestore.* -import cocoapods.FirebaseFirestore.FIRDocumentChangeType.* +import cocoapods.FirebaseFirestoreInternal.* +import cocoapods.FirebaseFirestoreInternal.FIRDocumentChangeType.* import dev.gitlive.firebase.* import kotlinx.cinterop.* import kotlinx.coroutines.CompletableDeferred diff --git a/firebase-functions/build.gradle.kts b/firebase-functions/build.gradle.kts index 5b0ba1531..e06ddf2a0 100644 --- a/firebase-functions/build.gradle.kts +++ b/firebase-functions/build.gradle.kts @@ -77,7 +77,7 @@ kotlin { } noPodspec() pod("FirebaseFunctions") { - version = "10.15.0" + version = "10.17.0" extraOpts += listOf("-compiler-option", "-fmodules") } } diff --git a/firebase-installations/build.gradle.kts b/firebase-installations/build.gradle.kts index f0d5c0cc2..13795a81e 100644 --- a/firebase-installations/build.gradle.kts +++ b/firebase-installations/build.gradle.kts @@ -90,7 +90,7 @@ kotlin { } noPodspec() pod("FirebaseInstallations") { - version = "10.15.0" + version = "10.17.0" } } } diff --git a/firebase-perf/build.gradle.kts b/firebase-perf/build.gradle.kts index e79a99ded..e970ed7a9 100644 --- a/firebase-perf/build.gradle.kts +++ b/firebase-perf/build.gradle.kts @@ -91,7 +91,7 @@ kotlin { } noPodspec() pod("FirebasePerformance") { - version = "10.15.0" + version = "10.17.0" } } } diff --git a/firebase-storage/build.gradle.kts b/firebase-storage/build.gradle.kts index 1afcfefdb..fa7de3b91 100644 --- a/firebase-storage/build.gradle.kts +++ b/firebase-storage/build.gradle.kts @@ -90,7 +90,7 @@ kotlin { } noPodspec() pod("FirebaseStorage") { - version = "10.15.0" + version = "10.17.0" extraOpts += listOf("-compiler-option", "-fmodules") } } From 299ab6618249f1e62be48cdf3a944ddb59b3d6cd Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Mon, 20 Nov 2023 10:58:52 +0100 Subject: [PATCH 27/29] Explicit linking to prevent some issues --- firebase-firestore/build.gradle.kts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/firebase-firestore/build.gradle.kts b/firebase-firestore/build.gradle.kts index 79c5b3788..64e0c5ea3 100644 --- a/firebase-firestore/build.gradle.kts +++ b/firebase-firestore/build.gradle.kts @@ -92,15 +92,16 @@ kotlin { baseName = "FirebaseFirestore" } noPodspec() - pod("FirebaseFirestore") { - version = "10.17.0" - extraOpts += listOf("-compiler-option", "-fmodules") - } // As of Firebase 10.17 Firestore has moved all ObjC headers to FirebaseFirestoreInternal and the kotlin cocoapods plugin does not handle this well // Adding it manually seems to resolve the issue pod("FirebaseFirestoreInternal") { version = "10.17.0" } + pod("FirebaseFirestore") { + version = "10.17.0" + extraOpts += listOf("-compiler-option", "-fmodules") + useInteropBindingFrom("FirebaseFirestoreInternal") + } } } From cdf4a0c93a80f5ba124c69aee7b7cfa1046b9692 Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Tue, 5 Dec 2023 13:37:19 +0100 Subject: [PATCH 28/29] Try ubuntu latest + upgrade to kotlin 1.9.21 --- .github/workflows/pull_request.yml | 7 +------ gradle.properties | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index b6147715a..1ce55d416 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,17 +9,12 @@ on: jobs: build-android: - runs-on: 4-core-ubuntu + runs-on: ubuntu-latest strategy: matrix: api-level: [ 34 ] steps: - uses: actions/checkout@v3 - - name: Enable KVM group perms - run: | - echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules - sudo udevadm control --reload-rules - sudo udevadm trigger --name-match=kvm - name: Setup test environment uses: ./.github/actions/setup_test_action - name: AVD cache diff --git a/gradle.properties b/gradle.properties index b6c72a41e..a4ff5b364 100644 --- a/gradle.properties +++ b/gradle.properties @@ -61,7 +61,7 @@ firebase-storage.version=1.10.4 # Dependencies Versions: gradlePluginVersion=8.1.3 -kotlinVersion=1.9.20 +kotlinVersion=1.9.21 coroutinesVersion=1.7.3 serializationVersion=1.6.0 firebaseBoMVersion=32.5.0 From c04da65d32e4e260948d519b4981160085a9874f Mon Sep 17 00:00:00 2001 From: Gijs van Veen Date: Mon, 11 Dec 2023 08:13:41 +0100 Subject: [PATCH 29/29] Android on MacOS 13 --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1ce55d416..31d9d58e2 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -9,7 +9,7 @@ on: jobs: build-android: - runs-on: ubuntu-latest + runs-on: macos-13 strategy: matrix: api-level: [ 34 ]