Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Daeda88 committed Nov 17, 2023
2 parents 5d04273 + 1a2facb commit 7a59d7e
Show file tree
Hide file tree
Showing 103 changed files with 970 additions and 961 deletions.
30 changes: 30 additions & 0 deletions .github/actions/setup_test_action/action.yml
Original file line number Diff line number Diff line change
@@ -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 &"
111 changes: 65 additions & 46 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,71 +8,36 @@ on:
branches: [ master, prerelease ]

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
with:
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
with:
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
Expand All @@ -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
Expand All @@ -99,4 +65,57 @@ jobs:
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"

20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ The following libraries are available for the various Firebase products.

| Service or Product | Gradle Dependency | API Coverage |
|---------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.10.0/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) |
| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.10.0/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) |
| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.10.0/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) |
| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.10.0/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) |
| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.10.0/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.10.0/pom) | [![40%](https://img.shields.io/badge/-40%25-orange?style=flat-square)](/firebase-storage/src/commonMain/kotlin/dev/gitlive/firebase/storage/storage.kt) |
| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.10.0/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) |
| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.10.0/pom) | [![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square)](/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt) |
| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.10.0/pom) | [![1%](https://img.shields.io/badge/-1%25-orange?style=flat-square)](/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/performance.kt) |
| [Crashlytics](https://firebase.google.com/docs/crashlytics) | [`dev.gitlive:firebase-crashlytics:1.10.0`](https://search.maven.org/artifact/dev.gitlive/firebase-crashlytics/1.10.0/pom) | [![80%](https://img.shields.io/badge/-1%25-orange?style=flat-square)](/firebase-crashlytics/src/commonMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt) |
| [Authentication](https://firebase.google.com/docs/auth) | [`dev.gitlive:firebase-auth:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-auth/1.10.4/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-auth/src/commonMain/kotlin/dev/gitlive/firebase/auth/auth.kt) |
| [Realtime Database](https://firebase.google.com/docs/database) | [`dev.gitlive:firebase-database:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-database/1.10.4/pom) | [![70%](https://img.shields.io/badge/-70%25-orange?style=flat-square)](/firebase-database/src/commonMain/kotlin/dev/gitlive/firebase/database/database.kt) |
| [Cloud Firestore](https://firebase.google.com/docs/firestore) | [`dev.gitlive:firebase-firestore:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-firestore/1.10.4/pom) | [![60%](https://img.shields.io/badge/-60%25-orange?style=flat-square)](/firebase-firestore/src/commonMain/kotlin/dev/gitlive/firebase/firestore/firestore.kt) |
| [Cloud Functions](https://firebase.google.com/docs/functions) | [`dev.gitlive:firebase-functions:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-functions/1.10.4/pom) | [![80%](https://img.shields.io/badge/-80%25-green?style=flat-square)](/firebase-functions/src/commonMain/kotlin/dev/gitlive/firebase/functions/functions.kt) |
| [Cloud Messaging](https://firebase.google.com/docs/cloud-messaging) | [`dev.gitlive:firebase-messaging:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-messaging/1.10.4/pom) | ![0%](https://img.shields.io/badge/-0%25-lightgrey?style=flat-square) |
| [Cloud Storage](https://firebase.google.com/docs/storage) | [`dev.gitlive:firebase-storage:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-storage/1.10.4/pom) | [![40%](https://img.shields.io/badge/-40%25-orange?style=flat-square)](/firebase-storage/src/commonMain/kotlin/dev/gitlive/firebase/storage/storage.kt) |
| [Installations](https://firebase.google.com/docs/projects/manage-installations) | [`dev.gitlive:firebase-installations:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-installations/1.10.4/pom) | [![90%](https://img.shields.io/badge/-90%25-green?style=flat-square)](/firebase-installations/src/commonMain/kotlin/dev/gitlive/firebase/installations/installations.kt) |
| [Remote Config](https://firebase.google.com/docs/remote-config) | [`dev.gitlive:firebase-config:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-config/1.10.4/pom) | [![20%](https://img.shields.io/badge/-20%25-orange?style=flat-square)](/firebase-config/src/commonMain/kotlin/dev/gitlive/firebase/remoteconfig/FirebaseRemoteConfig.kt) |
| [Performance](https://firebase.google.com/docs/perf-mon) | [`dev.gitlive:firebase-perf:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-perf/1.10.4/pom) | [![1%](https://img.shields.io/badge/-1%25-orange?style=flat-square)](/firebase-perf/src/commonMain/kotlin/dev/gitlive/firebase/perf/performance.kt) |
| [Crashlytics](https://firebase.google.com/docs/crashlytics) | [`dev.gitlive:firebase-crashlytics:1.10.4`](https://search.maven.org/artifact/dev.gitlive/firebase-crashlytics/1.10.4/pom) | [![80%](https://img.shields.io/badge/-1%25-orange?style=flat-square)](/firebase-crashlytics/src/commonMain/kotlin/dev/gitlive/firebase/crashlytics/crashlytics.kt) |

Is the Firebase library or API you need missing? [Create an issue](https://github.com/GitLiveApp/firebase-kotlin-sdk/issues/new?labels=API+coverage&template=increase-api-coverage.md&title=Add+%5Bclass+name%5D.%5Bfunction+name%5D+to+%5Blibrary+name%5D+for+%5Bplatform+names%5D) to request additional API coverage or be awesome and [submit a PR](https://github.com/GitLiveApp/firebase-kotlin-sdk/fork)

Expand Down
5 changes: 3 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

repositories {
google()
Expand Down Expand Up @@ -120,7 +121,7 @@ subprojects {
"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"("dev.gitlive:firebase-java-sdk:0.1.2")
"jvmMainApi"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") {
exclude("com.google.android.gms")
}
Expand Down Expand Up @@ -152,7 +153,7 @@ subprojects {
maven {
//// do not upstream ////
this.name = "snapshot"
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
//// /////////////// ////

credentials {
Expand Down
35 changes: 18 additions & 17 deletions firebase-app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
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.
*/
Expand Down Expand Up @@ -46,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 {
Expand All @@ -64,7 +76,8 @@ kotlin {
}

if (supportIosTarget) {
ios()
iosArm64()
iosX64()
iosSimulatorArm64()

cocoapods {
Expand Down Expand Up @@ -109,6 +122,9 @@ kotlin {
this.apiVersion = apiVersion
this.languageVersion = languageVersion
progressiveMode = true
if (name.lowercase().contains("ios")) {
optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
}
}

Expand All @@ -118,7 +134,7 @@ kotlin {
}
}

val commonTest by getting {
getByName("commonTest") {
dependencies {
implementation(project(":test-utils"))
}
Expand All @@ -130,24 +146,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)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions firebase-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gitlive/firebase-app",
"version": "1.10.1-SNAPSHOT",
"version": "1.10.4",
"description": "Wrapper around firebase for usage in Kotlin Multiplatform projects",
"main": "firebase-app.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
},
"homepage": "https://github.com/GitLiveApp/firebase-kotlin-sdk",
"dependencies": {
"@gitlive/firebase-common": "1.10.1-SNAPSHOT",
"@gitlive/firebase-common": "1.10.4",
"firebase": "9.19.1",
"kotlin": "1.8.20",
"kotlinx-coroutines-core": "1.6.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ actual data class FirebaseApp internal constructor(val android: com.google.fireb
actual val options: FirebaseOptions
get() = android.options.run { FirebaseOptions(applicationId, apiKey, databaseUrl, gaTrackingId, storageBucket, projectId, gcmSenderId) }

actual suspend fun delete() = android.delete()
actual suspend fun delete() {
android.delete()
}
}

actual fun Firebase.apps(context: Any?) = com.google.firebase.FirebaseApp.getApps(context as Context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ import org.junit.Ignore

actual val context: Any = ""

actual fun runTest(test: suspend () -> Unit) = kotlinx.coroutines.test.runTest { test() }
actual typealias IgnoreForAndroidUnitTest = Ignore
Loading

0 comments on commit 7a59d7e

Please sign in to comment.