From 7b9e681fcc445c6417b0fb4149a509095d8d64ac Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Fri, 24 Oct 2025 07:35:13 +0100 Subject: [PATCH 01/14] Bump to Kotlin 2.1.0 --- buildSrc/src/main/kotlin/Config.kt | 22 +++++++-------- packages/cinterop/build.gradle.kts | 28 +++++++++++++++++++ packages/gradle.properties | 1 - .../gradle/wrapper/gradle-wrapper.properties | 2 +- packages/jni-swig-stub/build.gradle.kts | 2 +- .../io/realm/kotlin/compiler/IrUtils.kt | 9 +++--- .../RealmModelDefaultMethodGeneration.kt | 9 ++---- .../compiler/RealmModelLoweringExtension.kt | 11 ++++++-- ...RealmModelSyntheticPropertiesGeneration.kt | 20 ++++++------- .../kotlin/compiler/SyncLoweringExtension.kt | 1 - .../compiler/fir/model/CompanionExtension.kt | 6 ++-- .../compiler/fir/model/ObjectExtension.kt | 8 +++--- 12 files changed, 73 insertions(+), 46 deletions(-) diff --git a/buildSrc/src/main/kotlin/Config.kt b/buildSrc/src/main/kotlin/Config.kt index 9ed4352d36..a3f6f529bd 100644 --- a/buildSrc/src/main/kotlin/Config.kt +++ b/buildSrc/src/main/kotlin/Config.kt @@ -62,7 +62,7 @@ val HOST_OS: OperatingSystem = findHostOs() object Realm { val ciBuild = (System.getenv("CI") != null) - const val version = "2.3.0" + const val version = "2.4.0-SNAPSHOT" const val group = "io.realm.kotlin" const val projectUrl = "https://realm.io" const val pluginPortalId = "io.realm.kotlin" @@ -98,10 +98,10 @@ object Realm { object Versions { object Android { const val minSdk = 16 - const val targetSdk = 33 - const val compileSdkVersion = 33 - const val buildToolsVersion = "33.0.0" - const val buildTools = "7.3.1" // https://maven.google.com/web/index.html?q=gradle#com.android.tools.build:gradle + const val targetSdk = 35 + const val compileSdkVersion = 35 + const val buildToolsVersion = "35.0.0" + const val buildTools = "8.7.3" // https://maven.google.com/web/index.html?q=gradle#com.android.tools.build:gradle const val ndkVersion = "23.2.8568313" const val r8 = "8.3.37" // See https://developer.android.com/build/kotlin-support } @@ -123,9 +123,9 @@ object Versions { const val junit = "4.13.2" // https://mvnrepository.com/artifact/junit/junit const val kbson = "0.4.0" // https://github.com/mongodb/kbson // When updating the Kotlin version, also remember to update /examples/min-android-sample/build.gradle.kts - const val kotlin = "2.0.20" // https://github.com/JetBrains/kotlin and https://kotlinlang.org/docs/releases.html#release-details - const val kotlinJvmTarget = "1.8" // Which JVM bytecode version is kotlin compiled to. - const val latestKotlin = "2.0.20" // https://kotlinlang.org/docs/eap.html#build-details + const val kotlin = "2.1.0" // https://github.com/JetBrains/kotlin and https://kotlinlang.org/docs/releases.html#release-details + const val kotlinJvmTarget = "11" // Which JVM bytecode version is kotlin compiled to. + const val latestKotlin = "2.1.0" // https://kotlinlang.org/docs/eap.html#build-details const val kotlinCompileTesting = "0.5.1" // https://github.com/zacsweers/kotlin-compile-testing const val ktlint = "0.45.2" // https://github.com/pinterest/ktlint const val ktor = "2.3.12" // https://github.com/ktorio/ktor @@ -134,10 +134,10 @@ object Versions { const val okio = "3.9.0" // https://square.github.io/okio/#releases const val relinker = "1.4.5" // https://github.com/KeepSafe/ReLinker const val serialization = "1.7.1" // https://kotlinlang.org/docs/releases.html#release-details - const val shadowJar = "6.1.0" // https://mvnrepository.com/artifact/com.github.johnrengelman.shadow/com.github.johnrengelman.shadow.gradle.plugin?repo=gradle-plugins + const val shadowJar = "8.1.0" // https://mvnrepository.com/artifact/com.github.johnrengelman.shadow/com.github.johnrengelman.shadow.gradle.plugin?repo=gradle-plugins const val snakeYaml = "1.33" // https://github.com/snakeyaml/snakeyaml - val sourceCompatibilityVersion = JavaVersion.VERSION_1_8 // Language level of any Java source code. - val targetCompatibilityVersion = JavaVersion.VERSION_1_8 // Version of generated JVM bytecode from Java files. + val sourceCompatibilityVersion = JavaVersion.VERSION_11 // Language level of any Java source code. + val targetCompatibilityVersion = JavaVersion.VERSION_11 // Version of generated JVM bytecode from Java files. } // Could be actual Dependency objects diff --git a/packages/cinterop/build.gradle.kts b/packages/cinterop/build.gradle.kts index 32a61dd7ca..52b089a962 100644 --- a/packages/cinterop/build.gradle.kts +++ b/packages/cinterop/build.gradle.kts @@ -714,6 +714,9 @@ afterEvaluate { tasks.named("generateJsonModelRelease") { inputs.files(tasks.getByPath(":jni-swig-stub:realmWrapperJvm").outputs) } + tasks.named("buildCMakeRelWithDebInfo") { + inputs.files(tasks.getByPath(":jni-swig-stub:realmWrapperJvm").outputs) + } } tasks.named("jvmMainClasses") { @@ -817,4 +820,29 @@ abstract class CmakeVersionProvider : ValueSource.isBaseRealmObject: Boolean ) } // After SUPERTYPES stage - is FirResolvedTypeRef -> typeRef.type.classId in realmObjectClassIds + is FirResolvedTypeRef -> typeRef.coneType.classId in realmObjectClassIds else -> false } } @@ -424,7 +425,7 @@ data class SchemaProperty( companion object { fun getPersistedName(declaration: IrProperty): String { @Suppress("UNCHECKED_CAST") - return (declaration.getAnnotation(PERSISTED_NAME_ANNOTATION.asSingleFqName()).getValueArgument(0)!! as IrConstImpl).value + return (declaration.getAnnotation(PERSISTED_NAME_ANNOTATION.asSingleFqName()).getValueArgument(0)!! as IrConstImpl).value?.toString() ?: "" } } } @@ -446,7 +447,6 @@ internal fun buildOf( type = containerType.typeWith(elementType), symbol = function, typeArgumentsCount = 1, - valueArgumentsCount = 1, origin = null, superQualifierSymbol = null ).apply { @@ -595,7 +595,6 @@ fun IrBlockBuilder.createSafeCallConstruction( val condition = IrCallImpl( startOffset, endOffset, context.irBuiltIns.booleanType, context.irBuiltIns.eqeqSymbol, - valueArgumentsCount = 2, typeArgumentsCount = 0, origin = IrStatementOrigin.EQEQ ).apply { @@ -684,7 +683,7 @@ fun getLinkingObjectPropertyName(backingField: IrField): String { fun getSchemaClassName(clazz: IrClass): String { return if (clazz.hasAnnotation(PERSISTED_NAME_ANNOTATION)) { @Suppress("UNCHECKED_CAST") - return (clazz.getAnnotation(PERSISTED_NAME_ANNOTATION.asSingleFqName()).getValueArgument(0)!! as IrConstImpl).value + return (clazz.getAnnotation(PERSISTED_NAME_ANNOTATION.asSingleFqName()).getValueArgument(0)!! as IrConstImpl).value?.toString() ?: "" } else { clazz.name.identifier } diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelDefaultMethodGeneration.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelDefaultMethodGeneration.kt index 71b741a572..a431bc8151 100644 --- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelDefaultMethodGeneration.kt +++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelDefaultMethodGeneration.kt @@ -75,8 +75,7 @@ class RealmModelDefaultMethodGeneration(private val pluginContext: IrPluginConte endOffset = endOffset, type = pluginContext.irBuiltIns.booleanType, symbol = realmEquals.symbol, - typeArgumentsCount = 0, - valueArgumentsCount = 2 + typeArgumentsCount = 0 ).apply { dispatchReceiver = irGetObject(realmObjectHelper.symbol) putValueArgument(0, irGet(function.dispatchReceiverParameter!!.type, function.dispatchReceiverParameter!!.symbol)) @@ -95,8 +94,7 @@ class RealmModelDefaultMethodGeneration(private val pluginContext: IrPluginConte endOffset = endOffset, type = pluginContext.irBuiltIns.intType, symbol = realmHashCode.symbol, - typeArgumentsCount = 0, - valueArgumentsCount = 1 + typeArgumentsCount = 0 ).apply { dispatchReceiver = irGetObject(realmObjectHelper.symbol) putValueArgument(0, irGet(function.dispatchReceiverParameter!!.type, function.dispatchReceiverParameter!!.symbol)) @@ -114,8 +112,7 @@ class RealmModelDefaultMethodGeneration(private val pluginContext: IrPluginConte endOffset = endOffset, type = pluginContext.irBuiltIns.stringType, symbol = realmToString.symbol, - typeArgumentsCount = 0, - valueArgumentsCount = 1 + typeArgumentsCount = 0 ).apply { dispatchReceiver = irGetObject(realmObjectHelper.symbol) putValueArgument(0, irGet(function.dispatchReceiverParameter!!.type, function.dispatchReceiverParameter!!.symbol)) diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelLoweringExtension.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelLoweringExtension.kt index 91e726f159..f7280f7e7c 100644 --- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelLoweringExtension.kt +++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelLoweringExtension.kt @@ -32,10 +32,13 @@ import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.fromSymbolOwner import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI import org.jetbrains.kotlin.ir.types.defaultType import org.jetbrains.kotlin.ir.types.starProjectedType +import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.util.companionObject import org.jetbrains.kotlin.ir.util.defaultType import org.jetbrains.kotlin.ir.util.isAnonymousObject @@ -118,11 +121,15 @@ private class RealmModelLowering(private val pluginContext: IrPluginContext) : C // able to resolve the companion object during runtime due to absence of // kotlin.reflect.full.companionObjectInstance if (pluginContext.platform.isNative()) { + val type = modelObjectAnnotationClass.defaultType as? IrType ?: throw IllegalStateException("defaultType is not an IrType") + val primaryConstructor = modelObjectAnnotationClass.primaryConstructor ?: throw IllegalStateException("primaryConstructor is null") + val constructorSymbol = primaryConstructor.symbol as? IrConstructorSymbol ?: throw IllegalStateException("symbol is not an IrConstructorSymbol") + val modelObjectAnnotation = IrConstructorCallImpl.fromSymbolOwner( startOffset = UNDEFINED_OFFSET, endOffset = UNDEFINED_OFFSET, - type = modelObjectAnnotationClass.defaultType, - constructorSymbol = modelObjectAnnotationClass.primaryConstructor!!.symbol + type = type, + constructorSymbol = constructorSymbol ).apply { putValueArgument( 0, diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelSyntheticPropertiesGeneration.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelSyntheticPropertiesGeneration.kt index 0ce7399497..3cec5bd921 100644 --- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelSyntheticPropertiesGeneration.kt +++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/RealmModelSyntheticPropertiesGeneration.kt @@ -93,6 +93,7 @@ import org.jetbrains.kotlin.ir.expressions.impl.IrGetEnumValueImpl import org.jetbrains.kotlin.ir.expressions.impl.IrPropertyReferenceImpl import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl import org.jetbrains.kotlin.ir.symbols.UnsafeDuringIrConstructionAPI +import org.jetbrains.kotlin.ir.expressions.impl.fromSymbolOwner import org.jetbrains.kotlin.ir.types.IrSimpleType import org.jetbrains.kotlin.ir.types.IrType import org.jetbrains.kotlin.ir.types.classFqName @@ -115,7 +116,7 @@ import org.jetbrains.kotlin.ir.util.isVararg import org.jetbrains.kotlin.ir.util.parentAsClass import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly - +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol /** * Helper to assisting in modifying classes marked with the [RealmObject] interface according to our * needs: @@ -303,7 +304,6 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi type = companionFieldsType, symbol = mapOf, typeArgumentsCount = 2, - valueArgumentsCount = 1, origin = null, superQualifierSymbol = null ).apply { @@ -340,8 +340,8 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi IrConstructorCallImpl.fromSymbolOwner( startOffset = startOffset, endOffset = endOffset, - type = elementType, - constructorSymbol = pairCtor + type = elementType as IrType, + constructorSymbol = pairCtor as IrConstructorSymbol ).apply { putTypeArgument(0, pluginContext.irBuiltIns.stringType) putTypeArgument(1, elementType) @@ -359,8 +359,8 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi IrConstructorCallImpl.fromSymbolOwner( startOffset = startOffset, endOffset = endOffset, - type = elementType, - constructorSymbol = pairCtor + type = elementType as IrType, + constructorSymbol = pairCtor as IrConstructorSymbol ).apply { putTypeArgument( 0, @@ -506,8 +506,7 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi endOffset, type = classInfoClass.defaultType, symbol = classInfoCreateMethod.symbol, - typeArgumentsCount = 0, - valueArgumentsCount = 5 + typeArgumentsCount = 0 ).apply { dispatchReceiver = irGetObject(classInfoClass.companionObject()!!.symbol) var arg = 0 @@ -714,7 +713,7 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi } ?: irNull(pluginContext.irBuiltIns.kClassClass.typeWith(typedRealmObjectInterface.defaultType).makeNullable()) // Define the link target. Empty string if there is none. - val linkPropertyName: IrConst = if (type == linkingObjectType) { + val linkPropertyName: IrConst = if (type == linkingObjectType) { val targetPropertyName = getLinkingObjectPropertyName(backingField) irString(targetPropertyName) } else { @@ -726,8 +725,7 @@ class RealmModelSyntheticPropertiesGeneration(private val pluginContext: IrPlugi endOffset, type = propertyClass.defaultType, symbol = propertyCreateMethod, - typeArgumentsCount = 0, - valueArgumentsCount = 10 + typeArgumentsCount = 0 ).apply { var arg = 0 // Persisted name diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/SyncLoweringExtension.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/SyncLoweringExtension.kt index d5a11767f2..35b1c3dd8e 100644 --- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/SyncLoweringExtension.kt +++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/SyncLoweringExtension.kt @@ -140,7 +140,6 @@ private class SyncLowering(private val pluginContext: IrPluginContext, private v type = expression.type, symbol = target.symbol, typeArgumentsCount = 0, - valueArgumentsCount = target.valueParameters.size, origin = null, superQualifierSymbol = null ).apply { diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/fir/model/CompanionExtension.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/fir/model/CompanionExtension.kt index 0ec41e8eb7..0e5b672285 100644 --- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/fir/model/CompanionExtension.kt +++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/fir/model/CompanionExtension.kt @@ -66,7 +66,7 @@ class CompanionExtension(session: FirSession) : FirDeclarationGenerationExtensio classSymbol: FirClassSymbol<*>, context: MemberGenerationContext ): Set { - if (classSymbol.isCompanion && (classSymbol.getContainingClassSymbol(session) as? FirClassSymbol<*>)?.isBaseRealmObject == true) { + if (classSymbol.isCompanion && (classSymbol.getContainingClassSymbol() as? FirClassSymbol<*>)?.isBaseRealmObject == true) { return setOf( Names.REALM_OBJECT_COMPANION_SCHEMA_METHOD, Names.REALM_OBJECT_COMPANION_NEW_INSTANCE_METHOD, @@ -88,7 +88,7 @@ class CompanionExtension(session: FirSession) : FirDeclarationGenerationExtensio owner, RealmPluginGeneratorKey, callableId.callableName, - session.builtinTypes.anyType.type, + session.builtinTypes.anyType.coneType, ).symbol ) @@ -98,7 +98,7 @@ class CompanionExtension(session: FirSession) : FirDeclarationGenerationExtensio owner, RealmPluginGeneratorKey, callableId.callableName, - session.builtinTypes.anyType.type + session.builtinTypes.anyType.coneType ).symbol ) diff --git a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/fir/model/ObjectExtension.kt b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/fir/model/ObjectExtension.kt index 6869c6243f..358b8bcfda 100644 --- a/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/fir/model/ObjectExtension.kt +++ b/packages/plugin-compiler/src/main/kotlin/io/realm/kotlin/compiler/fir/model/ObjectExtension.kt @@ -67,7 +67,7 @@ class ObjectExtension(session: FirSession) : FirDeclarationGenerationExtension(s owner, RealmPluginGeneratorKey, callableId.callableName, - session.builtinTypes.stringType.type, + session.builtinTypes.stringType.coneType, ) { modality = Modality.OPEN }.symbol @@ -78,10 +78,10 @@ class ObjectExtension(session: FirSession) : FirDeclarationGenerationExtension(s owner, RealmPluginGeneratorKey, callableId.callableName, - session.builtinTypes.booleanType.type, + session.builtinTypes.booleanType.coneType, ) { modality = Modality.OPEN - valueParameter(Name.identifier("other"), session.builtinTypes.nullableAnyType.type) + valueParameter(Name.identifier("other"), session.builtinTypes.nullableAnyType.coneType) }.symbol ) Names.REALM_OBJECT_HASH_CODE -> @@ -90,7 +90,7 @@ class ObjectExtension(session: FirSession) : FirDeclarationGenerationExtension(s owner, RealmPluginGeneratorKey, callableId.callableName, - session.builtinTypes.intType.type, + session.builtinTypes.intType.coneType, ) { modality = Modality.OPEN }.symbol From bca80694c767a203df18ea64ebe54b336586c230 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Fri, 24 Oct 2025 07:53:53 +0100 Subject: [PATCH 02/14] Fix runner & swig version for CI --- .github/workflows/include-deploy-release.yml | 11 +- .../workflows/include-integration-tests.yml | 40 +-- .github/workflows/pr.yml | 302 +++++++++--------- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 176 insertions(+), 179 deletions(-) diff --git a/.github/workflows/include-deploy-release.yml b/.github/workflows/include-deploy-release.yml index 7afc19995c..2d58be01db 100644 --- a/.github/workflows/include-deploy-release.yml +++ b/.github/workflows/include-deploy-release.yml @@ -13,8 +13,8 @@ on: jobs: deploy: - runs-on: macos-12 - name: Deploy release + runs-on: macos-13 + name: Deploy release steps: - name: git checkout @@ -60,10 +60,10 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - # TODO This matches 23.2.8568313, but what happens if we define specific ndk version in our build? + # TODO This matches 23.2.8568313, but what happens if we define specific ndk version in our build? - name: Setup NDK uses: nttld/setup-ndk@v1 with: @@ -109,4 +109,3 @@ jobs: "${{ secrets.SLACK_URL_RELEASE }}" "${{ secrets.SLACK_URL_CI }}" \ "${{ secrets.GRADLE_PORTAL_KEY }}" "${{ secrets.GRADLE_PORTAL_SECRET }}" \ '-PsignBuild=true -PsignSecretRingFileKotlin="${{ secrets.GPG_SIGNING_KEY_BASE_64_DBG }}" -PsignPasswordKotlin=${{ secrets.GPG_PASS_PHRASE_DBG }} -Prealm.kotlin.copyNativeJvmLibs=linux,windows' - diff --git a/.github/workflows/include-integration-tests.yml b/.github/workflows/include-integration-tests.yml index 2d3349ec8e..390ea48613 100644 --- a/.github/workflows/include-integration-tests.yml +++ b/.github/workflows/include-integration-tests.yml @@ -1,4 +1,4 @@ -name: Gradle Project Integration Tests +name: Gradle Project Integration Tests on: workflow_call: @@ -36,10 +36,10 @@ jobs: # uses: actions/download-artifact@v4 # with: # name: all-packages-${{ needs.check-cache.outputs.version-label }} - # path: ./packages/build/m2-buildrepo + # path: ./packages/build/m2-buildrepo # # TODO Can we read api level from Config.kt - # - name: Run Monkey on Android Sample + # - name: Run Monkey on Android Sample # env: # SSH_AUTH_SOCK: /tmp/ssh_agent.sock # uses: reactivecircus/android-emulator-runner@v2 @@ -77,17 +77,17 @@ jobs: uses: actions/download-artifact@v4 with: name: all-packages-${{ inputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo # TODO Can we read api level from Config.kt - - name: Build Android on minimum versions + - name: Build Android on minimum versions working-directory: examples/min-android-sample run: | java --version ./gradlew assembleDebug jvmJar realm-java-compatibiliy: - runs-on: macos-12 + runs-on: macos-13 steps: - name: Checkout code uses: actions/checkout@v4 @@ -107,7 +107,7 @@ jobs: uses: actions/download-artifact@v4 with: name: all-packages-${{ inputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo # - name: AVD cache # uses: actions/cache@v4 @@ -125,7 +125,7 @@ jobs: # api-level: 33 # target: default # # target: aosp_atd - # arch: x86_64 + # arch: x86_64 # disk-size: 4096M # ram-size: 2048M # heap-size: 1024M @@ -147,7 +147,7 @@ jobs: api-level: ${{ vars.VERSION_ANDROID_EMULATOR_API_LEVEL }} target: default # target: aosp_atd - arch: x86_64 + arch: x86_64 # profile: Nexus 6 disk-size: 4096M ram-size: 2048M @@ -191,7 +191,7 @@ jobs: uses: actions/download-artifact@v4 with: name: all-packages-${{ inputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Build benchmarks working-directory: benchmarks @@ -211,7 +211,7 @@ jobs: - type: gradle75 path: integration-tests/gradle/gradle75-test arguments: integrationTest - runs-on: macos-12 + runs-on: macos-13 steps: - uses: actions/checkout@v4 @@ -233,7 +233,7 @@ jobs: uses: actions/download-artifact@v4 with: name: all-packages-${{ inputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo # - name: AVD cache # uses: actions/cache@v4 @@ -251,7 +251,7 @@ jobs: # api-level: 33 # target: default # # target: aosp_atd - # arch: x86_64 + # arch: x86_64 # disk-size: 4096M # ram-size: 2048M # heap-size: 1024M @@ -273,13 +273,13 @@ jobs: api-level: ${{ vars.VERSION_ANDROID_EMULATOR_API_LEVEL }} target: default # target: aosp_atd - arch: x86_64 + arch: x86_64 # profile: Nexus 6 disk-size: 4096M ram-size: 2048M heap-size: 1024M channel: canary - script: cd ${{ matrix.path }} && ./gradlew ${{ matrix.arguments }} --info + script: cd ${{ matrix.path }} && ./gradlew ${{ matrix.arguments }} --info gradle-plugin-integration-java-17: strategy: @@ -292,7 +292,7 @@ jobs: - type: gradle85 path: integration-tests/gradle/gradle85-test arguments: integrationTest - runs-on: macos-12 + runs-on: macos-13 steps: - uses: actions/checkout@v4 @@ -314,7 +314,7 @@ jobs: uses: actions/download-artifact@v4 with: name: all-packages-${{ inputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo # - name: AVD cache # uses: actions/cache@v4 @@ -332,7 +332,7 @@ jobs: # api-level: 33 # target: default # # target: aosp_atd - # arch: x86_64 + # arch: x86_64 # disk-size: 4096M # ram-size: 2048M # heap-size: 1024M @@ -354,10 +354,10 @@ jobs: api-level: ${{ vars.VERSION_ANDROID_EMULATOR_API_LEVEL }} target: default # target: aosp_atd - arch: x86_64 + arch: x86_64 # profile: Nexus 6 disk-size: 4096M ram-size: 2048M heap-size: 1024M channel: canary - script: cd ${{ matrix.path }} && ./gradlew ${{ matrix.arguments }} --info + script: cd ${{ matrix.path }} && ./gradlew ${{ matrix.arguments }} --info diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index bf138c4591..5a31a17da2 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -20,17 +20,17 @@ env: CMAKE_CXX_COMPILER: /usr/local/bin/ccache-clang++ # Workflow environment variables are not available in Job if statements: https://github.com/actions/runner/issues/1661 # For now move this check to the `deploy-snapshot` job and figure out if there is a better way to do this. - # IS_RELEASE_BRANCH: "${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' }}" + # IS_RELEASE_BRANCH: "${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' }}" jobs: static-analysis: uses: ./.github/workflows/include-static-analysis.yml - + check-cache: uses: ./.github/workflows/include-check-cache.yml # We build the same JNI SWIG stub once and re-use it across platforms to ensure any problems - # with SWIG if we compile on each seperate platform. + # with SWIG if we compile on each seperate platform. build-jni-swig-stub: runs-on: ubuntu-latest needs: check-cache @@ -82,7 +82,6 @@ jobs: echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH cd ~ - curl -L ${{ vars.VERSION_SWIG}} > swig.rb && HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=true brew install swig.rb - name: Build JNI Stub working-directory: ./packages @@ -99,9 +98,9 @@ jobs: runs-on: ubuntu-22.04 needs: [check-cache, build-jni-swig-stub] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && needs.check-cache.outputs.jni-linux-lib-cache-hit != 'true' @@ -160,16 +159,16 @@ jobs: uses: actions/upload-artifact@v4 with: name: jni-linux-lib-${{ needs.check-cache.outputs.version-label }} - path: ./packages/cinterop/build/realmLinuxBuild/librealmc.so + path: ./packages/cinterop/build/realmLinuxBuild/librealmc.so retention-days: 1 build-jvm-windows-native-lib: runs-on: windows-latest needs: [check-cache, build-jni-swig-stub] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && needs.check-cache.outputs.jni-windows-lib-cache-hit != 'true' @@ -185,7 +184,7 @@ jobs: # error: tar failed with exit code: (128). # fatal: not a tree object: 7e4d802e3bde4154c227c0dd1da75c719be9f07a # TODO Implement better work-around here: https://mongodb.slack.com/archives/C017MBM0A30/p1661889411467029?thread_ts=1661888738.117769&cid=C017MBM0A30 - fetch-depth: 0 + fetch-depth: 0 submodules: "recursive" - name: Setup build cache @@ -211,7 +210,7 @@ jobs: working-directory: packages run: | cd cinterop - mkdir build + mkdir build cd build Remove-Item -Path realmWindowsBuild -Force -Recurse -ErrorAction Ignore mkdir realmWindowsBuild @@ -284,8 +283,8 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Debug environment run: | @@ -306,7 +305,7 @@ jobs: uses: actions/download-artifact@v4 with: name: jni-stub-${{ needs.check-cache.outputs.version-label }} - path: ${{ github.workspace }}/packages/jni-swig-stub/build/generated/sources/jni + path: ${{ github.workspace }}/packages/jni-swig-stub/build/generated/sources/jni - name: Build packages working-directory: packages @@ -321,7 +320,7 @@ jobs: with: name: jni-macos-lib-${{ needs.check-cache.outputs.version-label }} path: ./packages/cinterop/build/realmMacOsBuild/librealmc.dylib - retention-days: 1 + retention-days: 1 build-kotlin-metadata-package: runs-on: ubuntu-latest @@ -329,9 +328,9 @@ jobs: env: NDK_VERSION: 23.2.8568313 if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && needs.check-cache.outputs.packages-metadata-cache-hit != 'true' @@ -380,10 +379,10 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - # This matches 23.2.8568313, but what happens if we a define specific ndk version in our build? + # This matches 23.2.8568313, but what happens if we a define specific ndk version in our build? - name: Setup NDK uses: nttld/setup-ndk@v1 with: @@ -394,7 +393,7 @@ jobs: with: path: ./packages/build/m2-buildrepo key: packages-m2-metadata-${{ needs.check-cache.outputs.packages-sha }} - + - name: Build Kotlin Metadata and Gradle and Compiler Plugin working-directory: packages run: ./gradlew publishCIPackages -Prealm.kotlin.targets=gradlePlugin,compilerPlugin -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=true @@ -403,11 +402,11 @@ jobs: uses: actions/upload-artifact@v4 with: name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* + path: ./packages/build/m2-buildrepo/**/* retention-days: 1 - # This task is also responsible for creating the Gradle and Compiler Plugin as well as + # This task is also responsible for creating the Gradle and Compiler Plugin as well as # all Kotlin Multiplatform Metadata build-jvm-packages: runs-on: macos-14 @@ -415,9 +414,9 @@ jobs: env: NDK_VERSION: 23.2.8568313 if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && needs.check-cache.outputs.packages-jvm-cache-hit != 'true' @@ -439,7 +438,7 @@ jobs: # Last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}' java-version: | 17 - ${{ vars.VERSION_JAVA }} + ${{ vars.VERSION_JAVA }} - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -473,8 +472,8 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Setup Android SDK env: @@ -510,7 +509,7 @@ jobs: with: name: jni-macos-lib-${{ needs.check-cache.outputs.version-label }} path: ./packages/cinterop/build/realmMacOsBuild - + - name: Build JVM Package working-directory: packages run: ./gradlew publishCIPackages -Prealm.kotlin.targets=jvm -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.copyNativeJvmLibs=linux,windows,macos -Prealm.kotlin.mainHost=false @@ -523,7 +522,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: packages-jvm-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* + path: ./packages/build/m2-buildrepo/**/* retention-days: 1 @@ -581,7 +580,6 @@ jobs: echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH cd ~ - curl -L ${{ vars.VERSION_SWIG}} > swig.rb && HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=true brew install swig.rb - name: Install JSON parser run: brew install jq @@ -595,7 +593,7 @@ jobs: uses: clementetb/setup-ninja@master with: version: ${{ vars.VERSION_NINJA }} - + - name: Install ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: @@ -610,8 +608,8 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Setup Android SDK uses: android-actions/setup-android@v3 @@ -662,7 +660,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: packages-android-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* + path: ./packages/build/m2-buildrepo/**/* retention-days: 1 - name: Upload Android Base Test APK @@ -714,7 +712,7 @@ jobs: uses: clementetb/setup-ninja@master with: version: ${{ vars.VERSION_NINJA }} - + - name: Install ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: @@ -732,8 +730,8 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Build packages working-directory: packages @@ -755,7 +753,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: packages-macos-x64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* + path: ./packages/build/m2-buildrepo/**/* retention-days: 1 build-macos-arm64-packages: @@ -790,7 +788,7 @@ jobs: uses: clementetb/setup-ninja@master with: version: ${{ vars.VERSION_NINJA }} - + - name: Install ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: @@ -808,8 +806,8 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Build packages working-directory: packages @@ -826,7 +824,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: packages-macos-arm64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* + path: ./packages/build/m2-buildrepo/**/* retention-days: 1 build-ios-x64-packages: @@ -861,7 +859,7 @@ jobs: uses: clementetb/setup-ninja@master with: version: ${{ vars.VERSION_NINJA }} - + - name: Install ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: @@ -879,8 +877,8 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Build packages working-directory: packages @@ -898,7 +896,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: packages-ios-x64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* + path: ./packages/build/m2-buildrepo/**/* retention-days: 1 build-ios-arm64-packages: @@ -933,7 +931,7 @@ jobs: uses: clementetb/setup-ninja@master with: version: ${{ vars.VERSION_NINJA }} - + - name: Install ccache uses: hendrikmuhs/ccache-action@v1.2.13 with: @@ -951,8 +949,8 @@ jobs: run: | ccache --set-config="compiler_check=content" ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - name: Build packages working-directory: packages @@ -970,7 +968,7 @@ jobs: uses: actions/upload-artifact@v4 with: name: packages-ios-arm64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* + path: ./packages/build/m2-buildrepo/**/* retention-days: 1 @@ -992,13 +990,13 @@ jobs: test-title: Unit Test Results - Android Base (Emulator) - type: sync test-title: Unit Test Results - Android Sync (Emulator) - - runs-on: macos-12 # android emulator does not run on arm64 - https://github.com/ReactiveCircus/android-emulator-runner/issues/350 + + runs-on: macos-13 # android emulator does not run on arm64 - https://github.com/ReactiveCircus/android-emulator-runner/issues/350 needs: [check-cache, build-android-packages, build-jvm-packages, build-kotlin-metadata-package] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') steps: @@ -1028,11 +1026,11 @@ jobs: OUTPUT=$(bash cli.sh start | jq -r '.id') echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 17 + java-version: 'temurin' - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -1043,19 +1041,19 @@ jobs: uses: actions/download-artifact@v4 with: name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore m2-buildrepo (Android) uses: actions/download-artifact@v4 with: name: packages-android-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore m2-buildrepo (JVM) uses: actions/download-artifact@v4 with: name: packages-jvm-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests - name: Fetching the BAAS CLI hostname @@ -1078,7 +1076,7 @@ jobs: disable-animations: true api-level: ${{ vars.VERSION_ANDROID_EMULATOR_API_LEVEL }} # Must be 30 to support aosp_atd target: default - arch: x86_64 + arch: x86_64 disk-size: 4096M ram-size: 2048M heap-size: 1024M @@ -1093,7 +1091,7 @@ jobs: if: always() || failure() with: name: logcat-${{ matrix.type }}-emulator.txt - path: logcat.txt + path: logcat.txt retention-days: 1 - name: Publish Unit Test Results @@ -1117,17 +1115,17 @@ jobs: bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} fi - # Disable device farm test for Base, because running two in parallel seems to interfer somehow + # Disable device farm test for Base, because running two in parallel seems to interfer somehow test-android-packages-device-farm: name: AWS Device Farm timeout-minutes: 60 runs-on: ubuntu-latest needs: [ check-cache, build-android-packages, build-jvm-packages ] if: | - false && - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + false && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') steps: @@ -1163,9 +1161,9 @@ jobs: runs-on: ubuntu-latest needs: [ check-cache, build-android-packages, build-jvm-packages ] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') @@ -1232,22 +1230,22 @@ jobs: run: | if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} - fi + fi test-macos-packages: timeout-minutes: 60 strategy: fail-fast: false matrix: - os: [macos-12, macos-14] + os: [macos-13, macos-14] type: [base, sync] include: - - os: macos-12 + - os: macos-13 type: base os-id: macos package-prefix: macos-x64 test-title: Unit Test Results - MacOS x64 Base - - os: macos-12 + - os: macos-13 type: sync os-id: macos package-prefix: macos-x64 @@ -1262,15 +1260,15 @@ jobs: os-id: macos package-prefix: macos-arm64 test-title: Unit Test Results - MacOS arm64 Sync - + runs-on: ${{ matrix.os }} # TODO Unclear why MacOS needs the metadata package when the Android Tests do not # Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it. needs: [check-cache, build-kotlin-metadata-package, build-macos-x64-packages, build-macos-arm64-packages] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') steps: @@ -1313,13 +1311,13 @@ jobs: uses: actions/download-artifact@v4 with: name: packages-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore Kotlin metadata artifacts uses: actions/download-artifact@v4 with: name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests @@ -1337,20 +1335,20 @@ jobs: working-directory: packages run: > ./gradlew :test-${{ matrix.type }}:macosTest - -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} - -PincludeSdkModules=false + -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} + -PincludeSdkModules=false --info --no-daemon - name: Publish Unit Test Results uses: dorny/test-reporter@v1 if: always() || failure() with: - name: ${{ matrix.test-title }} + name: ${{ matrix.test-title }} path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml reporter: java-junit list-suites: failed list-tests: failed - fail-on-error: true + fail-on-error: true - name: Stopping the BAAS container if: always() && matrix.type == 'sync' @@ -1368,15 +1366,15 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-12, macos-14] + os: [macos-13, macos-14] type: [base, sync] include: - - os: macos-12 + - os: macos-13 type: base package-prefix: x64 test-title: Unit Test Results - iOS x64 Base test-task: iosTest - - os: macos-12 + - os: macos-13 type: sync package-prefix: x64 test-title: Unit Test Results - iOS x64 Sync @@ -1391,15 +1389,15 @@ jobs: package-prefix: arm64 test-title: Unit Test Results - iOS arm64 Sync test-task: iosTest - + runs-on: ${{ matrix.os }} # TODO Unclear why MacOS needs the metadata package when the Android Tests do not # Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it. needs: [check-cache, build-kotlin-metadata-package, build-ios-x64-packages, build-ios-arm64-packages] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') steps: @@ -1442,13 +1440,13 @@ jobs: uses: actions/download-artifact@v4 with: name: packages-ios-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore Kotlin metadata artifacts uses: actions/download-artifact@v4 with: name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests @@ -1467,15 +1465,15 @@ jobs: working-directory: packages run: > ./gradlew :test-${{ matrix.type }}:${{ matrix.test-task }} - -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} - -PincludeSdkModules=false + -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} + -PincludeSdkModules=false --info --no-daemon - name: Publish Unit Test Results uses: dorny/test-reporter@v1 if: always() || failure() with: - name: ${{ matrix.test-title }} + name: ${{ matrix.test-title }} path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml reporter: java-junit list-suites: failed @@ -1497,10 +1495,10 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-12, macos-14, ubuntu-latest, windows-latest] + os: [macos-13, macos-14, ubuntu-latest, windows-latest] type: [base, sync] include: - - os: macos-12 + - os: macos-13 os-id: mac type: base test-title: Unit Test Results - Base JVM MacOS x64 @@ -1516,7 +1514,7 @@ jobs: os-id: win type: base test-title: Unit Test Results - Base JVM Windows - - os: macos-12 + - os: macos-13 os-id: mac type: sync test-title: Unit Test Results - Sync JVM MacOS x64 @@ -1539,9 +1537,9 @@ jobs: runs-on: ${{ matrix.os }} needs: [check-cache, build-jvm-packages, build-kotlin-metadata-package] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') steps: @@ -1584,13 +1582,13 @@ jobs: uses: actions/download-artifact@v4 with: name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore m2-buildrepo uses: actions/download-artifact@v4 with: name: packages-jvm-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests - name: Fetching the BAAS CLI hostname @@ -1609,15 +1607,15 @@ jobs: run: > ./gradlew :test-${{ matrix.type }}:jvmTest -PsyncUsePlatformNetworking=true - -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} - -PincludeSdkModules=false + -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} + -PincludeSdkModules=false --info --no-daemon - name: Publish Unit Test Results uses: dorny/test-reporter@v1 if: always() || failure() with: - name: ${{ matrix.test-title }} + name: ${{ matrix.test-title }} path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml reporter: java-junit list-suites: failed @@ -1634,62 +1632,62 @@ jobs: bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} fi - package-all-artifacts: + package-all-artifacts: runs-on: ubuntu-latest needs: [check-cache, build-jvm-packages, build-android-packages, build-macos-x64-packages, build-macos-arm64-packages, build-ios-x64-packages, build-ios-arm64-packages, build-kotlin-metadata-package] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') steps: - name: Checkout code uses: actions/checkout@v4 - # The Metadata artifact contain broken JVM publications, so it needs to be + # The Metadata artifact contain broken JVM publications, so it needs to be # restored first, it so they can be overidden with the correct ones. - name: Restore Kotlin metadata artifacts uses: actions/download-artifact@v4 with: name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore Android artifacts uses: actions/download-artifact@v4 with: name: packages-android-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore JVM artifacts uses: actions/download-artifact@v4 with: name: packages-jvm-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore MacOS x64 artifacts uses: actions/download-artifact@v4 with: name: packages-macos-x64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore MacOS arm64 artifacts uses: actions/download-artifact@v4 with: name: packages-macos-arm64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore iOS x64 artifacts uses: actions/download-artifact@v4 with: name: packages-ios-x64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Restore iOS arm64 artifacts uses: actions/download-artifact@v4 with: name: packages-ios-arm64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Upload artifacts bundle uses: actions/upload-artifact@v4 @@ -1702,32 +1700,32 @@ jobs: uses: ./.github/workflows/include-integration-tests.yml needs: [check-cache, package-all-artifacts] if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') with: version-label: ${{ needs.check-cache.outputs.version-label }} deploy-snapshot: uses: ./.github/workflows/include-deploy-snapshot.yml - needs: [ - check-cache, - static-analysis, - integration-tests, - test-jvm-packages, - test-macos-packages, - test-ios-packages, - test-android-packages-emulator, + needs: [ + check-cache, + static-analysis, + integration-tests, + test-jvm-packages, + test-macos-packages, + test-ios-packages, + test-android-packages-emulator, # test-android-packages-device-farm, test-android-packages-device-farm-sync, package-all-artifacts ] if: | - always() && - !cancelled() && + always() && + !cancelled() && endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && - !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') @@ -1739,7 +1737,7 @@ jobs: check-release-build: runs-on: ubuntu-latest needs: [check-cache] - outputs: + outputs: is_publish_build: ${{ steps.check_release.outputs.is_publish_build }} steps: @@ -1765,7 +1763,7 @@ jobs: echo "is_publish_build=true" >> $GITHUB_OUTPUT fi fi - + - name: Print is release build run: | @@ -1773,24 +1771,24 @@ jobs: deploy-release: uses: ./.github/workflows/include-deploy-release.yml - needs: [ + needs: [ check-cache, - check-release-build, - static-analysis, - integration-tests, - test-jvm-packages, - test-macos-packages, - test-ios-packages, - test-android-packages-emulator, + check-release-build, + static-analysis, + integration-tests, + test-jvm-packages, + test-macos-packages, + test-ios-packages, + test-android-packages-emulator, # test-android-packages-device-farm, test-android-packages-device-farm-sync, package-all-artifacts ] if: | - always() && - !cancelled() && + always() && + !cancelled() && !endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && - !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') && (needs.check-release-build.outputs.is_publish_build == 'true') diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index f42e62f372..8357d84852 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.6-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 9f994c07b444b67735852af47e94c6049af823e9 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Fri, 24 Oct 2025 08:07:57 +0100 Subject: [PATCH 03/14] bump Java 17 --- .github/workflows/include-deploy-snapshot.yml | 12 ++-- .../workflows/include-integration-tests.yml | 24 +++---- .github/workflows/pr.yml | 66 +++++++++---------- 3 files changed, 51 insertions(+), 51 deletions(-) diff --git a/.github/workflows/include-deploy-snapshot.yml b/.github/workflows/include-deploy-snapshot.yml index 83dbf0fbd3..9feb85d0a0 100644 --- a/.github/workflows/include-deploy-snapshot.yml +++ b/.github/workflows/include-deploy-snapshot.yml @@ -10,7 +10,7 @@ on: jobs: deploy: runs-on: ubuntu-latest - name: Deploy SNAPSHOT + name: Deploy SNAPSHOT steps: - name: Remove unnecessary files @@ -23,11 +23,11 @@ jobs: with: submodules: "recursive" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Install Kotlin Commandline Tools uses: fwilhe2/setup-kotlin@0.2.0 @@ -38,10 +38,10 @@ jobs: uses: actions/download-artifact@v4 with: name: all-packages-${{ inputs.version-label }} - path: ./packages/build/m2-buildrepo + path: ./packages/build/m2-buildrepo - name: Publish SNAPSHOT to Maven Central - # env: + # env: # GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY_BASE_64 }} # GPG_PASS_PHRASE: ${{ secrets.GPG_PASS_PHRASE }} # MAVEN_CENTRAL_USER: ${{ secrets.MAVEN_CENTRAL_USER }} diff --git a/.github/workflows/include-integration-tests.yml b/.github/workflows/include-integration-tests.yml index 390ea48613..2e9a13e684 100644 --- a/.github/workflows/include-integration-tests.yml +++ b/.github/workflows/include-integration-tests.yml @@ -62,11 +62,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -92,11 +92,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -176,11 +176,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -218,11 +218,11 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 5a31a17da2..46f722017c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -45,11 +45,11 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/kotlin.json" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -120,11 +120,11 @@ jobs: path: ./packages/cinterop/build/realmLinuxBuild key: jni-linux-lib-${{ needs.check-cache.outputs.packages-sha }} - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup cmake uses: jwlawson/actions-setup-cmake@v2.0.2 @@ -248,11 +248,11 @@ jobs: with: submodules: "recursive" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -344,11 +344,11 @@ jobs: run: |- echo "::add-matcher::.github/problem-matchers/kotlin.json" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -692,11 +692,11 @@ jobs: with: submodules: "recursive" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -768,11 +768,11 @@ jobs: with: submodules: "recursive" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -839,11 +839,11 @@ jobs: with: submodules: "recursive" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -911,11 +911,11 @@ jobs: with: submodules: "recursive" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -1296,11 +1296,11 @@ jobs: OUTPUT=$(bash cli.sh start | jq -r '.id') echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -1425,11 +1425,11 @@ jobs: OUTPUT=$(bash cli.sh start | jq -r '.id') echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -1567,11 +1567,11 @@ jobs: OUTPUT=$(bash cli.sh start | jq -r '.id') echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 From 001cc39dd62140322cfa06de31520d3e7dc2e203 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Fri, 24 Oct 2025 08:32:11 +0100 Subject: [PATCH 04/14] Using Java 17 --- .github/workflows/pr.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 46f722017c..50fbde862c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -436,9 +436,7 @@ jobs: distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} # JVM 17 is required for android-actions/setup-android@v3 # Last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}' - java-version: | - 17 - ${{ vars.VERSION_JAVA }} + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -556,9 +554,7 @@ jobs: distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} # JVM 17 is required for android-actions/setup-android@v3 # Last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}' - java-version: | - 17 - ${{ vars.VERSION_JAVA }} + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 @@ -1029,8 +1025,8 @@ jobs: - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: 17 - java-version: 'temurin' + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 From 74da41a73400153c5df1eb494bf1cb213fe45b07 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Fri, 24 Oct 2025 13:41:34 +0100 Subject: [PATCH 05/14] Fixing tests --- buildSrc/src/main/kotlin/Config.kt | 2 +- packages/test-base/build.gradle.kts | 2 +- .../src/jvmMain/kotlin/io/realm/kotlin/test/util/Compiler.kt | 1 + packages/test-sync/build.gradle.kts | 2 +- 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/kotlin/Config.kt b/buildSrc/src/main/kotlin/Config.kt index a3f6f529bd..e14d7dc67b 100644 --- a/buildSrc/src/main/kotlin/Config.kt +++ b/buildSrc/src/main/kotlin/Config.kt @@ -126,7 +126,7 @@ object Versions { const val kotlin = "2.1.0" // https://github.com/JetBrains/kotlin and https://kotlinlang.org/docs/releases.html#release-details const val kotlinJvmTarget = "11" // Which JVM bytecode version is kotlin compiled to. const val latestKotlin = "2.1.0" // https://kotlinlang.org/docs/eap.html#build-details - const val kotlinCompileTesting = "0.5.1" // https://github.com/zacsweers/kotlin-compile-testing + const val kotlinCompileTesting = "0.7.0" // https://github.com/zacsweers/kotlin-compile-testing const val ktlint = "0.45.2" // https://github.com/pinterest/ktlint const val ktor = "2.3.12" // https://github.com/ktorio/ktor const val multidex = "2.0.1" // https://developer.android.com/jetpack/androidx/releases/multidex diff --git a/packages/test-base/build.gradle.kts b/packages/test-base/build.gradle.kts index 3fc4722ce4..d5216fda65 100644 --- a/packages/test-base/build.gradle.kts +++ b/packages/test-base/build.gradle.kts @@ -253,7 +253,7 @@ kotlin { } targets.filterIsInstance().forEach { simulatorTargets -> simulatorTargets.testRuns.forEach { testRun -> - testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 14" + testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 15" } } sourceSets { diff --git a/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/util/Compiler.kt b/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/util/Compiler.kt index 05ca42e215..72521d93fa 100644 --- a/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/util/Compiler.kt +++ b/packages/test-base/src/jvmMain/kotlin/io/realm/kotlin/test/util/Compiler.kt @@ -30,6 +30,7 @@ object Compiler { plugins: List = listOf(Registrar()) ): JvmCompilationResult = KotlinCompilation().apply { + jvmTarget = "11" sources = listOf(source) messageOutputStream = System.out @Suppress("deprecation") diff --git a/packages/test-sync/build.gradle.kts b/packages/test-sync/build.gradle.kts index d8ad09ebe1..ef9deaddf3 100644 --- a/packages/test-sync/build.gradle.kts +++ b/packages/test-sync/build.gradle.kts @@ -263,7 +263,7 @@ kotlin { } targets.filterIsInstance().forEach { simulatorTargets -> simulatorTargets.testRuns.forEach { testRun -> - testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 14" + testRun.deviceId = project.findProperty("iosDevice")?.toString() ?: "iPhone 15" } } sourceSets { From 1301d0d14a833afcf99e970152b8f1d33ca591dc Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Fri, 24 Oct 2025 16:03:25 +0100 Subject: [PATCH 06/14] Testing snapshot --- .github/workflows/pr.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 50fbde862c..ae70ca936f 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1706,24 +1706,24 @@ jobs: deploy-snapshot: uses: ./.github/workflows/include-deploy-snapshot.yml needs: [ - check-cache, - static-analysis, - integration-tests, - test-jvm-packages, - test-macos-packages, - test-ios-packages, - test-android-packages-emulator, + # check-cache, + # static-analysis, + # integration-tests, + # test-jvm-packages, + # test-macos-packages, + # test-ios-packages, + # test-android-packages-emulator, # test-android-packages-device-farm, - test-android-packages-device-farm-sync, + # test-android-packages-device-farm-sync, package-all-artifacts ] - if: | - always() && - !cancelled() && - endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') + # if: | + # always() && + # !cancelled() && + # endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && + # !contains(needs.*.result, 'failure') && + # !contains(needs.*.result, 'cancelled') && + # (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') secrets: inherit with: From b81421e1c826ed1558a6937f38308fc1e154d522 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Fri, 24 Oct 2025 16:28:23 +0100 Subject: [PATCH 07/14] Testing Snapshot --- .github/workflows/pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ae70ca936f..e2036462a8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1717,10 +1717,10 @@ jobs: # test-android-packages-device-farm-sync, package-all-artifacts ] - # if: | - # always() && + if: | + always() && # !cancelled() && - # endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && + endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') # !contains(needs.*.result, 'failure') && # !contains(needs.*.result, 'cancelled') && # (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') From 68d28b67c4b5f40f7e0ae78944c95742ddb1d237 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Sun, 26 Oct 2025 14:00:12 +0000 Subject: [PATCH 08/14] Update pr.yml --- .github/workflows/pr.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index e2036462a8..c7621a42ae 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -980,12 +980,12 @@ jobs: strategy: fail-fast: false matrix: - type: [base, sync] + type: [base] include: - type: base test-title: Unit Test Results - Android Base (Emulator) - - type: sync - test-title: Unit Test Results - Android Sync (Emulator) + # - type: sync + # test-title: Unit Test Results - Android Sync (Emulator) runs-on: macos-13 # android emulator does not run on arm64 - https://github.com/ReactiveCircus/android-emulator-runner/issues/350 needs: [check-cache, build-android-packages, build-jvm-packages, build-kotlin-metadata-package] From 568d0acd9c701b805faa9df8166e61a082c633ea Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Sun, 26 Oct 2025 14:06:28 +0000 Subject: [PATCH 09/14] Update pr.yml --- .github/workflows/pr.yml | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c7621a42ae..3a5a9a0de3 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1705,25 +1705,10 @@ jobs: deploy-snapshot: uses: ./.github/workflows/include-deploy-snapshot.yml - needs: [ - # check-cache, - # static-analysis, - # integration-tests, - # test-jvm-packages, - # test-macos-packages, - # test-ios-packages, - # test-android-packages-emulator, - # test-android-packages-device-farm, - # test-android-packages-device-farm-sync, - package-all-artifacts - ] + needs: [package-all-artifacts] if: | always() && - # !cancelled() && endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') - # !contains(needs.*.result, 'failure') && - # !contains(needs.*.result, 'cancelled') && - # (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') secrets: inherit with: From 1fd11921570518e6f36fc346c47ebc6a3294eeef Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Sun, 26 Oct 2025 14:43:27 +0000 Subject: [PATCH 10/14] manually setting version for include-deploy-snapshot.yml --- .github/workflows/include-deploy-snapshot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/include-deploy-snapshot.yml b/.github/workflows/include-deploy-snapshot.yml index 9feb85d0a0..5e9e478c7f 100644 --- a/.github/workflows/include-deploy-snapshot.yml +++ b/.github/workflows/include-deploy-snapshot.yml @@ -37,7 +37,7 @@ jobs: - name: Restore m2-buildrepo uses: actions/download-artifact@v4 with: - name: all-packages-${{ inputs.version-label }} + name: all-packages-2.4.0-SNAPSHOT path: ./packages/build/m2-buildrepo - name: Publish SNAPSHOT to Maven Central From 48e499fb7802086be34da8956111a11c3bd28252 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Sun, 26 Oct 2025 16:16:04 +0000 Subject: [PATCH 11/14] Update pr.yml --- .github/workflows/pr.yml | 1771 +------------------------------------- 1 file changed, 29 insertions(+), 1742 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 3a5a9a0de3..b92d8cb4aa 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -36,1745 +36,32 @@ jobs: needs: check-cache if: always() && !cancelled() && needs.check-cache.outputs.jni-swig-stub-cache-hit != 'true' steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Register problem matchers - run: |- - echo "::add-matcher::.github/problem-matchers/kotlin.json" - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Load build cache - uses: actions/cache@v4 - with: - path: ./packages/jni-swig-stub/build/generated/sources/jni - key: jni-swig-stubs-${{ needs.check-cache.outputs.packages-sha }} - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - # Manually install SWIG 4.1.1 as only 4.0.2 is pre-installed - # 4.1.1 is not available in apt-get, so use brew instead - # We need to use the formulae directly from GitHub to pin the version as Homebrew does not have - # all versions available. - # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#ubuntu-22041-lts - # It seems to be required to manually add brew dirs to the PATH. This does not happen automatically. - - name: Install SWIG - run: | - test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)" - test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile - echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile - echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH - cd ~ - - - name: Build JNI Stub - working-directory: ./packages - run: ./gradlew :jni-swig-stub:assemble -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: jni-stub-${{ needs.check-cache.outputs.version-label }} - path: ./packages/jni-swig-stub/build/generated/sources/jni/* - retention-days: 1 - - build-jvm-linux-native-lib: - runs-on: ubuntu-22.04 - needs: [check-cache, build-jni-swig-stub] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - needs.check-cache.outputs.jni-linux-lib-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Register problem matchers - run: |- - echo "::add-matcher::.github/problem-matchers/kotlin.json" - - - name: Setup build cache - uses: actions/cache@v4 - with: - path: ./packages/cinterop/build/realmLinuxBuild - key: jni-linux-lib-${{ needs.check-cache.outputs.packages-sha }} - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Restore JNI Swig Stubs - uses: actions/download-artifact@v4 - with: - name: jni-stub-${{ needs.check-cache.outputs.version-label }} - path: ./packages/jni-swig-stub/build/generated/sources/jni - - - name: Build native lib - working-directory: ./packages/cinterop - run: | - mkdir build - cd build - rm -rf realmLinuxBuild - mkdir realmLinuxBuild - cd realmLinuxBuild - cmake -DCMAKE_BUILD_TYPE=Release \ - -DREALM_ENABLE_SYNC=1 \ - -DREALM_NO_TESTS=1 \ - -DREALM_BUILD_LIB_ONLY=true \ - -DCMAKE_CXX_VISIBILITY_PRESET=hidden \ - -DCMAKE_TOOLCHAIN_FILE=../../../external/core/tools/cmake/x86_64-linux-gnu.toolchain.cmake \ - -DJAVA_INCLUDE_PATH=${{ env.JAVA_HOME }}/include/ \ - ../../src/jvm - make -j8 - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: jni-linux-lib-${{ needs.check-cache.outputs.version-label }} - path: ./packages/cinterop/build/realmLinuxBuild/librealmc.so - retention-days: 1 - - build-jvm-windows-native-lib: - runs-on: windows-latest - needs: [check-cache, build-jni-swig-stub] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - needs.check-cache.outputs.jni-windows-lib-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - # TODO See https://github.com/microsoft/vcpkg/issues/25349 which might describe the error here https://github.com/realm/realm-kotlin/runs/8099890473?check_suite_focus=true - # -- Building for: Visual Studio 17 2022 - # -- Running vcpkg install - # Error: while checking out port openssl with git tree 7e4d802e3bde4154c227c0dd1da75c719be9f07a - # Error: Failed to tar port directory - # error: tar failed with exit code: (128). - # fatal: not a tree object: 7e4d802e3bde4154c227c0dd1da75c719be9f07a - # TODO Implement better work-around here: https://mongodb.slack.com/archives/C017MBM0A30/p1661889411467029?thread_ts=1661888738.117769&cid=C017MBM0A30 - fetch-depth: 0 - submodules: "recursive" - - - name: Setup build cache - uses: actions/cache@v4 - with: - path: ./packages/cinterop/build/realmWindowsBuild - key: jni-windows-lib-${{ needs.check-cache.outputs.packages-sha }} - enableCrossOsArchive: true - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Restore JNI Swig Stubs - uses: actions/download-artifact@v4 - with: - name: jni-stub-${{ needs.check-cache.outputs.version-label }} - path: ${{ github.workspace }}/packages/jni-swig-stub/build/generated/sources/jni - - - name: Build native lib - shell: powershell - working-directory: packages - run: | - cd cinterop - mkdir build - cd build - Remove-Item -Path realmWindowsBuild -Force -Recurse -ErrorAction Ignore - mkdir realmWindowsBuild - cd realmWindowsBuild - cmake ` - ..\..\src\jvm ` - -DCMAKE_GENERATOR_PLATFORM=x64 ` - -DCMAKE_BUILD_TYPE=Release ` - -DREALM_ENABLE_SYNC=ON ` - -DREALM_NO_TESTS=1 ` - -DCMAKE_CXX_VISIBILITY_PRESET=hidden ` - -DVCPKG_TARGET_TRIPLET=x64-windows-static - cmake --build . --config Release - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: jni-windows-lib-${{ needs.check-cache.outputs.version-label }} - path: ./packages/cinterop/build/realmWindowsBuild/Release/realmc.dll - retention-days: 1 - - build-jvm-macos-native-lib: - runs-on: macos-14 - needs: [check-cache, build-jni-swig-stub] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - needs.check-cache.outputs.jni-macos-lib-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Setup ninja - uses: clementetb/setup-ninja@master - with: - version: ${{ vars.VERSION_NINJA }} - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.13 - with: - key: 'jvm-macos-native-lib' - max-size: '2.0G' - - - name: Prepend ccache executables to the PATH - run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - - # See https://github.com/hendrikmuhs/ccache-action/issues/94 - - name: Configure ccache - run: | - ccache --set-config="compiler_check=content" - ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - - - name: Debug environment - run: | - env - type cmake - cmake --version - type ninja - ninja --version - - # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. - - name: Setup build cache - uses: actions/cache@v4 - with: - path: ./packages/cinterop/build/realmMacOsBuild - key: jni-macos-lib-${{ needs.check-cache.outputs.packages-sha }} - - - name: Restore JNI Swig Stubs - uses: actions/download-artifact@v4 - with: - name: jni-stub-${{ needs.check-cache.outputs.version-label }} - path: ${{ github.workspace }}/packages/jni-swig-stub/build/generated/sources/jni - - - name: Build packages - working-directory: packages - run: ./gradlew buildJVMSharedLibs -Prealm.kotlin.mainHost=false - - - name: Show ccache size - run: | - echo `du -sh ~/.ccache` - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: jni-macos-lib-${{ needs.check-cache.outputs.version-label }} - path: ./packages/cinterop/build/realmMacOsBuild/librealmc.dylib - retention-days: 1 - - build-kotlin-metadata-package: - runs-on: ubuntu-latest - needs: [check-cache] - env: - NDK_VERSION: 23.2.8568313 - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - needs.check-cache.outputs.packages-metadata-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Register problem matchers - run: |- - echo "::add-matcher::.github/problem-matchers/kotlin.json" - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Setup ninja - uses: clementetb/setup-ninja@master - with: - version: ${{ vars.VERSION_NINJA }} - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.13 - with: - key: 'metadata-package' - max-size: '2.0G' - - - name: Prepend ccache executables to the PATH - run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - - # See https://github.com/hendrikmuhs/ccache-action/issues/94 - - name: Configure ccache - run: | - ccache --set-config="compiler_check=content" - ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - - # This matches 23.2.8568313, but what happens if we a define specific ndk version in our build? - - name: Setup NDK - uses: nttld/setup-ndk@v1 - with: - ndk-version: r23c - - - name: Setup build cache - uses: actions/cache@v4 - with: - path: ./packages/build/m2-buildrepo - key: packages-m2-metadata-${{ needs.check-cache.outputs.packages-sha }} - - - name: Build Kotlin Metadata and Gradle and Compiler Plugin - working-directory: packages - run: ./gradlew publishCIPackages -Prealm.kotlin.targets=gradlePlugin,compilerPlugin -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=true - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* - retention-days: 1 - - - # This task is also responsible for creating the Gradle and Compiler Plugin as well as - # all Kotlin Multiplatform Metadata - build-jvm-packages: - runs-on: macos-14 - needs: [check-cache, build-jvm-linux-native-lib, build-jvm-windows-native-lib, build-jvm-macos-native-lib] - env: - NDK_VERSION: 23.2.8568313 - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - needs.check-cache.outputs.packages-jvm-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Register problem matchers - run: |- - echo "::add-matcher::.github/problem-matchers/kotlin.json" - - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - # JVM 17 is required for android-actions/setup-android@v3 - # Last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Setup ninja - uses: clementetb/setup-ninja@master - with: - version: ${{ vars.VERSION_NINJA }} - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.13 - with: - key: 'jvm-package' - max-size: '2.0G' - - - name: Install SWIG - run: brew install swig - - - name: Prepend ccache executables to the PATH - run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - - # See https://github.com/hendrikmuhs/ccache-action/issues/94 - - name: Configure ccache - run: | - ccache --set-config="compiler_check=content" - ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - - - name: Setup Android SDK - env: - JAVA_HOME: ${{ env.JAVA_HOME_17_ARM64 }} - uses: android-actions/setup-android@v3 - - - name: Install NDK - run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}" - env: - JAVA_HOME: ${{ env.JAVA_HOME_17_ARM64 }} - - # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. - - name: Setup build cache - uses: actions/cache@v4 - with: - path: ./packages/build/m2-buildrepo - key: packages-m2-jvm-sync-${{ needs.check-cache.outputs.packages-sha }} - - - name: Restore Linux JNI lib - uses: actions/download-artifact@v4 - with: - name: jni-linux-lib-${{ needs.check-cache.outputs.version-label }} - path: ./packages/cinterop/build/realmLinuxBuild - - - name: Restore Windows JNI lib - uses: actions/download-artifact@v4 - with: - name: jni-windows-lib-${{ needs.check-cache.outputs.version-label }} - path: ./packages/cinterop/build/realmWindowsBuild/Release - - - name: Restore MacOS JNI lib - uses: actions/download-artifact@v4 - with: - name: jni-macos-lib-${{ needs.check-cache.outputs.version-label }} - path: ./packages/cinterop/build/realmMacOsBuild - - - name: Build JVM Package - working-directory: packages - run: ./gradlew publishCIPackages -Prealm.kotlin.targets=jvm -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.copyNativeJvmLibs=linux,windows,macos -Prealm.kotlin.mainHost=false - - - name: Show ccache size - run: | - echo `du -sh ~/.ccache` - - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-jvm-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* - retention-days: 1 - - - build-android-packages: - runs-on: ubuntu-latest - needs: check-cache - env: - NDK_VERSION: 23.2.8568313 - outputs: - baas-container-id: ${{ steps.baas_cli_start.outputs.baas_container_id }} - if: | - always() && !cancelled() && - (needs.check-cache.outputs.packages-android-cache-hit != 'true' || - needs.check-cache.outputs.android-test-base-apk-cache-hit != 'true' || - needs.check-cache.outputs.android-test-sync-apk-cache-hit != 'true') - - steps: - - name: Remove unnecessary files - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf "$AGENT_TOOLSDIRECTORY" - - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Setup Java - uses: actions/setup-java@v4 - with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - # JVM 17 is required for android-actions/setup-android@v3 - # Last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - # Manually install SWIG 4.1.1 as only 4.0.2 is pre-installed - # 4.1.1 is not available in apt-get, so use brew instead - # We need to use the formulae directly from GitHub to pin the version as Homebrew does not have - # all versions available. - # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#ubuntu-22041-lts - # It seems to be required to manually add brew dirs to the PATH. This does not happen automatically. - - name: Install SWIG - run: | - test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)" - test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" - test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile - echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile - echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH - echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH - cd ~ - - - name: Install JSON parser - run: brew install jq - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Setup ninja - uses: clementetb/setup-ninja@master - with: - version: ${{ vars.VERSION_NINJA }} - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.13 - with: - key: 'android-package' - max-size: '2.0G' - - - name: Prepend ccache executables to the PATH - run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - - # See https://github.com/hendrikmuhs/ccache-action/issues/94 - - name: Configure ccache - run: | - ccache --set-config="compiler_check=content" - ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - - - name: Setup Android SDK - uses: android-actions/setup-android@v3 - env: - JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} - - - name: Install NDK - env: - JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} - run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}" - - - name: Build Android Base Test Apk - working-directory: packages - run: ./gradlew :test-base:assembleAndroidTest -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false - - - name: Build Android Sync Test Apk - working-directory: packages - run: ./gradlew :test-sync:packageDebug :test-sync:assembleAndroidTest -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false - - - name: Build packages - working-directory: packages - run: ./gradlew publishCIPackages -Prealm.kotlin.targets=android -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false - - - name: Store build cache - uses: actions/cache@v4 - with: - path: ./packages/build/m2-buildrepo - key: packages-m2-android-sync-${{ needs.check-cache.outputs.packages-sha }} - - - name: Store build cache for Android Test APK - uses: actions/cache@v4 - with: - path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk - key: android-base-test-apk-key-${{ needs.check-cache.outputs.packages-sha }} - - # Must match naming found in include-check-cache.yml - - name: Store build cache for Android Sync Test APK - uses: actions/cache@v4 - with: - key: android-sync-test-apk-key-${{ needs.check-cache.outputs.packages-sha }} - path: | - ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk - ./packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk - - # Must match naming found in include-check-cache.yml - # Must match naming found in include-check-cache.yml - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-android-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* - retention-days: 1 - - - name: Upload Android Base Test APK - uses: actions/upload-artifact@v4 - with: - name: android-base-test-apk-${{ needs.check-cache.outputs.version-label }} - path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk - retention-days: 1 - - - name: Upload Android Sync Test APK - uses: actions/upload-artifact@v4 - with: - name: android-sync-test-apk-${{ needs.check-cache.outputs.version-label }} - retention-days: 1 - path: | - ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk - ./packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk - - - # TODO: ccache is not being used by this build for some reason - build-macos-x64-packages: - runs-on: macos-14 # x64 builds fine on an arm64 node - needs: check-cache - if: always() && !cancelled() && needs.check-cache.outputs.packages-macos-x64-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Setup ninja - uses: clementetb/setup-ninja@master - with: - version: ${{ vars.VERSION_NINJA }} - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.13 - with: - key: 'macos-x64-package' - max-size: '2.0G' - - - name: Install SWIG - run: brew install swig - - - name: Prepend ccache executables to the PATH - run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - - # See https://github.com/hendrikmuhs/ccache-action/issues/94 - - name: Configure ccache - run: | - ccache --set-config="compiler_check=content" - ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - - - name: Build packages - working-directory: packages - run: ./gradlew publishCIPackages -Prealm.kotlin.targets=macosX64 -Prealm.kotlin.mainHost=false - - - name: Show ccache size - run: | - echo `du -sh ~/.ccache` - - # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. - - name: Store build cache - uses: actions/cache@v4 - with: - path: ./packages/build/m2-buildrepo - key: packages-m2-macos-x64-sync-${{ needs.check-cache.outputs.packages-sha }} - - # Must match naming found in include-check-cache.yml - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-macos-x64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* - retention-days: 1 - - build-macos-arm64-packages: - runs-on: macos-14 - needs: check-cache - # needs: static-analysis - if: always() && !cancelled() && needs.check-cache.outputs.packages-macos-arm64-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Setup ninja - uses: clementetb/setup-ninja@master - with: - version: ${{ vars.VERSION_NINJA }} - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.13 - with: - key: 'macos-arm64-package' - max-size: '2.0G' - - - name: Install SWIG - run: brew install swig - - - name: Prepend ccache executables to the PATH - run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - - # See https://github.com/hendrikmuhs/ccache-action/issues/94 - - name: Configure ccache - run: | - ccache --set-config="compiler_check=content" - ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - - - name: Build packages - working-directory: packages - run: ./gradlew publishCIPackages -Prealm.kotlin.targets=macosArm64 -Prealm.kotlin.mainHost=false - - - name: Store build cache - uses: actions/cache@v4 - with: - path: ./packages/build/m2-buildrepo - key: packages-m2-macos-arm64-sync-${{ needs.check-cache.outputs.packages-sha }} - - # Must match naming found in include-check-cache.yml - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-macos-arm64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* - retention-days: 1 - - build-ios-x64-packages: - runs-on: macos-14 # x64 builds fine on an arm64 node - needs: check-cache - # needs: static-analysis - if: always() && !cancelled() && needs.check-cache.outputs.packages-ios-x64-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Setup ninja - uses: clementetb/setup-ninja@master - with: - version: ${{ vars.VERSION_NINJA }} - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.13 - with: - key: 'ios-x64-package' - max-size: '2.0G' - - - name: Install SWIG - run: brew install swig - - - name: Prepend ccache executables to the PATH - run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - - # See https://github.com/hendrikmuhs/ccache-action/issues/94 - - name: Configure ccache - run: | - ccache --set-config="compiler_check=content" - ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - - - name: Build packages - working-directory: packages - run: ./gradlew publishCIPackages -Prealm.kotlin.targets=iosX64 -Prealm.kotlin.mainHost=false - - # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. - - name: Store build cache - uses: actions/cache@v4 - with: - path: ./packages/build/m2-buildrepo - key: packages-m2-ios-x64-sync-${{ needs.check-cache.outputs.packages-sha }} - - # Must match naming found in include-check-cache.yml - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-ios-x64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* - retention-days: 1 - - build-ios-arm64-packages: - runs-on: macos-14 - needs: check-cache - # needs: static-analysis - if: always() && !cancelled() && needs.check-cache.outputs.packages-ios-arm64-cache-hit != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Setup cmake - uses: jwlawson/actions-setup-cmake@v2.0.2 - with: - cmake-version: ${{ vars.VERSION_CMAKE }} - - - name: Setup ninja - uses: clementetb/setup-ninja@master - with: - version: ${{ vars.VERSION_NINJA }} - - - name: Install ccache - uses: hendrikmuhs/ccache-action@v1.2.13 - with: - key: 'ios-arm64-package' - max-size: '2.0G' - - - name: Install SWIG - run: brew install swig - - - name: Prepend ccache executables to the PATH - run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH - - # See https://github.com/hendrikmuhs/ccache-action/issues/94 - - name: Configure ccache - run: | - ccache --set-config="compiler_check=content" - ccache --show-config - echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang - echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ - - - name: Build packages - working-directory: packages - run: ./gradlew publishCIPackages -Prealm.kotlin.targets=iosArm64 -Prealm.kotlin.mainHost=false - - # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. - - name: Store build cache - uses: actions/cache@v4 - with: - path: ./packages/build/m2-buildrepo - key: packages-m2-ios-arm64-sync-${{ needs.check-cache.outputs.packages-sha }} - - # Must match naming found in include-check-cache.yml - - name: Upload artifacts - uses: actions/upload-artifact@v4 - with: - name: packages-ios-arm64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo/**/* - retention-days: 1 - - - # TODO Split into base and sync tests - # TODO If we hook up to Device Farm we can use ubuntu runners instead - # TODO Compare speed between emulator and Device Farm - # TODO We should be able to move this into a reusable work-flow - - # TODO Compare speed between emulator and Device Farm - # TODO We should be able to move this into a reusable work-flow - test-android-packages-emulator: - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - type: [base] - include: - - type: base - test-title: Unit Test Results - Android Base (Emulator) - # - type: sync - # test-title: Unit Test Results - Android Sync (Emulator) - - runs-on: macos-13 # android emulator does not run on arm64 - https://github.com/ReactiveCircus/android-emulator-runner/issues/350 - needs: [check-cache, build-android-packages, build-jvm-packages, build-kotlin-metadata-package] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - submodules: "recursive" - - # checkout BAAS CLI repo - - name: Checkout BAAS repo - if: matrix.type == 'sync' - run: | - echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token - gh repo clone 10gen/baasaas - - # Start BAAS instance in the background - # We save the container id to poll against and get the hostname info later - - name: Start Baas instance in the background - id: baas_cli_start - if: matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner - # curl: option --data: error encountered when reading a file - OUTPUT=$(bash cli.sh start | jq -r '.id') - echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Restore Kotlin metadata artifacts - uses: actions/download-artifact@v4 - with: - name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore m2-buildrepo (Android) - uses: actions/download-artifact@v4 - with: - name: packages-android-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore m2-buildrepo (JVM) - uses: actions/download-artifact@v4 - with: - name: packages-jvm-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests - - name: Fetching the BAAS CLI hostname - id: baas_cli_poll - if: matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') - echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT - - # TODO This action does not support using `\` to split multiline scripts. - - name: Run Integration Tests - env: - SSH_AUTH_SOCK: /tmp/ssh_agent.sock - uses: reactivecircus/android-emulator-runner@v2 - with: - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: true - api-level: ${{ vars.VERSION_ANDROID_EMULATOR_API_LEVEL }} # Must be 30 to support aosp_atd - target: default - arch: x86_64 - disk-size: 4096M - ram-size: 2048M - heap-size: 1024M - channel: canary - script: | - adb logcat -c - adb logcat > logcat.txt & - cd packages && ./gradlew :test-${{ matrix.type }}:connectedCheck -PsyncUsePlatformNetworking=true -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} -PincludeSdkModules=false --info --no-daemon - - - name: Archive LogCat data - uses: actions/upload-artifact@v4 - if: always() || failure() - with: - name: logcat-${{ matrix.type }}-emulator.txt - path: logcat.txt - retention-days: 1 - - - name: Publish Unit Test Results - uses: dorny/test-reporter@v1 - if: always() || failure() - with: - name: ${{ matrix.test-title }} - path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml - reporter: java-junit - list-suites: failed - list-tests: failed - fail-on-error: true - - - name: Stopping the BAAS container - if: always() && matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then - bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} - fi - - # Disable device farm test for Base, because running two in parallel seems to interfer somehow - test-android-packages-device-farm: - name: AWS Device Farm - timeout-minutes: 60 - runs-on: ubuntu-latest - needs: [ check-cache, build-android-packages, build-jvm-packages ] - if: | - false && - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Restore Android Test APK - uses: actions/download-artifact@v4 - with: - name: android-base-test-apk-${{ needs.check-cache.outputs.version-label }} - path: ./packages/test-base/build/outputs/apk/androidTest/debug - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - - name: Run the tests - uses: ./.github/actions/run-android-device-farm-test - id: run_android_tests - with: - apk-path: ${{ github.workspace }}/packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk - app-id: io.realm.testapp - project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} - device-pool-arn: ${{ secrets.DEVICEFARM_POOL_ARN }} - - - test-android-packages-device-farm-sync: - name: AWS Device Farm Sync Tests - timeout-minutes: 60 - runs-on: ubuntu-latest - needs: [ check-cache, build-android-packages, build-jvm-packages ] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && - (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') - steps: - - name: Checkout code - uses: actions/checkout@v4 - - # checkout BAAS CLI repo - - name: Checkout BAAS repo - run: | - echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token - gh repo clone 10gen/baasaas - - # Start BAAS instance in the background - # We save the container id to poll against and get the hostname info later - - name: Start Baas instance in the background - id: baas_cli_start - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - OUTPUT=$(bash cli.sh start | jq -r '.id') - echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - - name: Restore Android Sync Test APK - uses: actions/download-artifact@v4 - with: - name: android-sync-test-apk-${{ needs.check-cache.outputs.version-label }} - path: ./packages/test-sync/build/outputs/apk/ - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - - # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests - - name: Fetching the BAAS CLI hostname - id: baas_cli_poll - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') - echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT - - - name: Run the Sync tests - uses: ./.github/actions/run-android-device-farm-test - id: run_android_tests - with: - apk-path: ${{ github.workspace }}/packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk - apk-auxiliary-path: ${{ github.workspace }}/packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk - baas_url: ${{ steps.baas_cli_poll.outputs.baas_container_hostname }} - app-id: io.realm.sync.testapp.test - project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} - device-pool-arn: ${{ secrets.DEVICEFARM_POOL_ARN }} - - - name: Stopping the BAAS container - if: always() - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then - bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} - fi - - test-macos-packages: - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - os: [macos-13, macos-14] - type: [base, sync] - include: - - os: macos-13 - type: base - os-id: macos - package-prefix: macos-x64 - test-title: Unit Test Results - MacOS x64 Base - - os: macos-13 - type: sync - os-id: macos - package-prefix: macos-x64 - test-title: Unit Test Results - MacOS x64 Sync - - os: macos-14 - type: base - os-id: macos - package-prefix: macos-arm64 - test-title: Unit Test Results - MacOS arm64 Base - - os: macos-14 - type: sync - os-id: macos - package-prefix: macos-arm64 - test-title: Unit Test Results - MacOS arm64 Sync - - runs-on: ${{ matrix.os }} - # TODO Unclear why MacOS needs the metadata package when the Android Tests do not - # Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it. - needs: [check-cache, build-kotlin-metadata-package, build-macos-x64-packages, build-macos-arm64-packages] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - # checkout BAAS CLI repo - - name: Checkout BAAS repo - if: matrix.type == 'sync' - run: | - echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token - gh repo clone 10gen/baasaas - - # Start BAAS instance in the background - # We save the container id to poll against and get the hostname info later - - name: Start Baas instance in the background - id: baas_cli_start - if: matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner - # curl: option --data: error encountered when reading a file - OUTPUT=$(bash cli.sh start | jq -r '.id') - echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Restore m2-buildrepo - uses: actions/download-artifact@v4 - with: - name: packages-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore Kotlin metadata artifacts - uses: actions/download-artifact@v4 - with: - name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests - - name: Fetching the BAAS CLI hostname - id: baas_cli_poll - if: matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') - echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT - - - name: Run tests - working-directory: packages - run: > - ./gradlew :test-${{ matrix.type }}:macosTest - -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} - -PincludeSdkModules=false - --info --no-daemon - - - name: Publish Unit Test Results - uses: dorny/test-reporter@v1 - if: always() || failure() - with: - name: ${{ matrix.test-title }} - path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml - reporter: java-junit - list-suites: failed - list-tests: failed - fail-on-error: true - - - name: Stopping the BAAS container - if: always() && matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then - bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} - fi - - - test-ios-packages: - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - os: [macos-13, macos-14] - type: [base, sync] - include: - - os: macos-13 - type: base - package-prefix: x64 - test-title: Unit Test Results - iOS x64 Base - test-task: iosTest - - os: macos-13 - type: sync - package-prefix: x64 - test-title: Unit Test Results - iOS x64 Sync - test-task: iosTest - - os: macos-14 - type: base - package-prefix: arm64 - test-title: Unit Test Results - iOS arm64 Base - test-task: iosTest - - os: macos-14 - type: sync - package-prefix: arm64 - test-title: Unit Test Results - iOS arm64 Sync - test-task: iosTest - - runs-on: ${{ matrix.os }} - # TODO Unclear why MacOS needs the metadata package when the Android Tests do not - # Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it. - needs: [check-cache, build-kotlin-metadata-package, build-ios-x64-packages, build-ios-arm64-packages] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - # checkout BAAS CLI repo - - name: Checkout BAAS repo - if: matrix.type == 'sync' - run: | - echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token - gh repo clone 10gen/baasaas - - # Start BAAS instance in the background - # We save the container id to poll against and get the hostname info later - - name: Start Baas instance in the background - id: baas_cli_start - if: matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner - # curl: option --data: error encountered when reading a file - OUTPUT=$(bash cli.sh start | jq -r '.id') - echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Restore m2-buildrepo (ios) - uses: actions/download-artifact@v4 - with: - name: packages-ios-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore Kotlin metadata artifacts - uses: actions/download-artifact@v4 - with: - name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests - - name: Fetching the BAAS CLI hostname - id: baas_cli_poll - if: matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') - echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT - - # App names are limited to 32 characters, so the appNamePrefix should not exceed 22 characters. - - name: Run tests - working-directory: packages - run: > - ./gradlew :test-${{ matrix.type }}:${{ matrix.test-task }} - -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} - -PincludeSdkModules=false - --info --no-daemon - - - name: Publish Unit Test Results - uses: dorny/test-reporter@v1 - if: always() || failure() - with: - name: ${{ matrix.test-title }} - path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml - reporter: java-junit - list-suites: failed - list-tests: failed - fail-on-error: true - - - name: Stopping the BAAS container - if: always() && matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then - bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} - fi - - test-jvm-packages: - timeout-minutes: 60 - strategy: - fail-fast: false - matrix: - os: [macos-13, macos-14, ubuntu-latest, windows-latest] - type: [base, sync] - include: - - os: macos-13 - os-id: mac - type: base - test-title: Unit Test Results - Base JVM MacOS x64 - - os: macos-14 - os-id: mac - type: base - test-title: Unit Test Results - Base JVM MacOS arm64 - - os: ubuntu-latest - os-id: ubu - type: base - test-title: Unit Test Results - Base JVM Linux - - os: windows-latest - os-id: win - type: base - test-title: Unit Test Results - Base JVM Windows - - os: macos-13 - os-id: mac - type: sync - test-title: Unit Test Results - Sync JVM MacOS x64 - - os: macos-14 - os-id: mac - type: sync - test-title: Unit Test Results - Sync JVM MacOS arm64 - - os: ubuntu-latest - os-id: ubu - type: sync - test-title: Unit Test Results - Sync JVM Linux - exclude: - # Do not run Windows Sync Tests, because the bash script for - # starting the BAAS container doesn not work on Windows. - - os: windows-latest - #os-id: win - type: sync - #test-title: Unit Test Results - Sync JVM Windows - - runs-on: ${{ matrix.os }} - needs: [check-cache, build-jvm-packages, build-kotlin-metadata-package] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - # checkout BAAS CLI repo - - name: Checkout BAAS repo - if: matrix.type == 'sync' - run: | - echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token - gh repo clone 10gen/baasaas - - # Start BAAS instance in the background - # We save the container id to poll against and get the hostname info later - - name: Start Baas instance in the background - id: baas_cli_start - if: matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner - # curl: option --data: error encountered when reading a file - OUTPUT=$(bash cli.sh start | jq -r '.id') - echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT - - - name: Setup Java 17 - uses: actions/setup-java@v4 - with: - distribution: 'temurin' - java-version: 17 - - - name: Setup Gradle and task/dependency caching - uses: gradle/actions/setup-gradle@v3 - with: - cache-read-only: false - - - name: Restore Kotlin metadata artifacts - uses: actions/download-artifact@v4 - with: - name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore m2-buildrepo - uses: actions/download-artifact@v4 - with: - name: packages-jvm-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests - - name: Fetching the BAAS CLI hostname - id: baas_cli_poll - if: matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') - echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT - - # App names are limited to 32 characters, so the appNamePrefix should not exceed 22 characters. - - name: Run tests - working-directory: packages - run: > - ./gradlew :test-${{ matrix.type }}:jvmTest - -PsyncUsePlatformNetworking=true - -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} - -PincludeSdkModules=false - --info --no-daemon - - - name: Publish Unit Test Results - uses: dorny/test-reporter@v1 - if: always() || failure() - with: - name: ${{ matrix.test-title }} - path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml - reporter: java-junit - list-suites: failed - list-tests: failed - fail-on-error: true - - - name: Stopping the BAAS container - if: always() && matrix.type == 'sync' - working-directory: baasaas - env: - APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} - run: | - if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then - bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} - fi - - package-all-artifacts: - runs-on: ubuntu-latest - needs: [check-cache, build-jvm-packages, build-android-packages, build-macos-x64-packages, build-macos-arm64-packages, build-ios-x64-packages, build-ios-arm64-packages, build-kotlin-metadata-package] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') - - steps: - - name: Checkout code - uses: actions/checkout@v4 - - # The Metadata artifact contain broken JVM publications, so it needs to be - # restored first, it so they can be overidden with the correct ones. - - name: Restore Kotlin metadata artifacts - uses: actions/download-artifact@v4 - with: - name: packages-metadata-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore Android artifacts - uses: actions/download-artifact@v4 - with: - name: packages-android-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore JVM artifacts - uses: actions/download-artifact@v4 - with: - name: packages-jvm-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore MacOS x64 artifacts - uses: actions/download-artifact@v4 - with: - name: packages-macos-x64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore MacOS arm64 artifacts - uses: actions/download-artifact@v4 - with: - name: packages-macos-arm64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore iOS x64 artifacts - uses: actions/download-artifact@v4 - with: - name: packages-ios-x64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Restore iOS arm64 artifacts - uses: actions/download-artifact@v4 - with: - name: packages-ios-arm64-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - - - name: Upload artifacts bundle - uses: actions/upload-artifact@v4 - with: - name: all-packages-${{ needs.check-cache.outputs.version-label }} - path: ./packages/build/m2-buildrepo - retention-days: 7 - - integration-tests: - uses: ./.github/workflows/include-integration-tests.yml - needs: [check-cache, package-all-artifacts] - if: | - always() && - !cancelled() && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') - with: - version-label: ${{ needs.check-cache.outputs.version-label }} - - deploy-snapshot: - uses: ./.github/workflows/include-deploy-snapshot.yml - needs: [package-all-artifacts] - if: | - always() && - endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') - - secrets: inherit - with: - version-label: ${{ needs.check-cache.outputs.version-label }} - - # This job sets an output `is_publish_build` to `true` if this is a release build - check-release-build: - runs-on: ubuntu-latest - needs: [check-cache] - outputs: - is_publish_build: ${{ steps.check_release.outputs.is_publish_build }} - - steps: - - uses: actions/checkout@v4 - - - name: Check if release build - id: check_release - run: | - git fetch --tags - gitTag=$(git describe --tags --exact-match HEAD) || echo "NONE" - echo "Git branch/tag: ${GITHUB_REF}/${gitTag:-'none'}" - - if [[ -z "$gitTag" ]]; then - gitSha=$(git rev-parse HEAD | cut -c1-8) - echo "Building commit: ${{ needs.check-cache.outputs.version-label }} - ${gitSha}" - echo "is_publish_build=false" >> $GITHUB_OUTPUT - else - if [[ "$gitTag" != "v${{ needs.check-cache.outputs.version-label }}" ]]; then - echo "Git tag '${gitTag}' does not match v${{ needs.check-cache.outputs.version-label }}" - echo "is_publish_build=false" >> $GITHUB_OUTPUT - else - echo "Building release: '${gitTag}'" - echo "is_publish_build=true" >> $GITHUB_OUTPUT - fi - fi - - - - name: Print is release build - run: | - echo "Is release build: ${{ steps.check_release.outputs.is_publish_build }}" - - deploy-release: - uses: ./.github/workflows/include-deploy-release.yml - needs: [ - check-cache, - check-release-build, - static-analysis, - integration-tests, - test-jvm-packages, - test-macos-packages, - test-ios-packages, - test-android-packages-emulator, - # test-android-packages-device-farm, - test-android-packages-device-farm-sync, - package-all-artifacts - ] - if: | - always() && - !cancelled() && - !endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && - !contains(needs.*.result, 'failure') && - !contains(needs.*.result, 'cancelled') && - (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') && - (needs.check-release-build.outputs.is_publish_build == 'true') - - secrets: inherit - with: - version-label: ${{ needs.check-cache.outputs.version-label }} - packages-sha-label: ${{ needs.check-cache.outputs.packages-sha }} + - name: Check if secrets are populated + # We assign secrets to environment variables for use in the 'run' block. + env: + GPG_KEY_SECRET: ${{ secrets.GPG_SIGNING_KEY_BASE_64 }} + GPG_PASS_SECRET: ${{ secrets.GPG_PASS_PHRASE }} + MAVEN_USER_SECRET: ${{ secrets.MAVEN_CENTRAL_USER }} + MAVEN_PASS_SECRET: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + + run: | + echo "--- GPG_SIGNING_KEY_BASE_64 as char array ---" + # Use grep -o . to print each character on a new line. + # Note: GitHub Actions may still redact this output. + echo -n "$GPG_KEY_SECRET" | grep -o . + echo "--- End of GPG_SIGNING_KEY_BASE_64 ---" + + echo "--- GPG_PASS_PHRASE as char array ---" + echo -n "$GPG_PASS_SECRET" | grep -o . + echo "--- End of GPG_PASS_PHRASE ---" + + echo "--- MAVEN_CENTRAL_USER as char array ---" + echo -n "$MAVEN_USER_SECRET" | grep -o . + echo "--- End of MAVEN_CENTRAL_USER ---" + + echo "--- MAVEN_CENTRAL_PASSWORD as char array ---" + echo -n "$MAVEN_PASS_SECRET" | grep -o . + echo "--- End of MAVEN_CENTRAL_PASSWORD ---" + + echo "NOTE: GitHub may still redact the output above." + From cc59d8bf2ae5d26778643102d2abbcabec2e8f16 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Sun, 26 Oct 2025 16:18:29 +0000 Subject: [PATCH 12/14] Update pr.yml --- .github/workflows/pr.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index b92d8cb4aa..33a0c98889 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,18 +23,12 @@ env: # IS_RELEASE_BRANCH: "${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' }}" jobs: - static-analysis: - uses: ./.github/workflows/include-static-analysis.yml - - check-cache: - uses: ./.github/workflows/include-check-cache.yml - # We build the same JNI SWIG stub once and re-use it across platforms to ensure any problems # with SWIG if we compile on each seperate platform. build-jni-swig-stub: runs-on: ubuntu-latest needs: check-cache - if: always() && !cancelled() && needs.check-cache.outputs.jni-swig-stub-cache-hit != 'true' + if: always() steps: - name: Check if secrets are populated # We assign secrets to environment variables for use in the 'run' block. From 022492171f56837e9e1987b6102b1e8bec4aab75 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Sun, 26 Oct 2025 16:20:32 +0000 Subject: [PATCH 13/14] Update pr.yml --- .github/workflows/pr.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 33a0c98889..045a3deff4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -27,7 +27,6 @@ jobs: # with SWIG if we compile on each seperate platform. build-jni-swig-stub: runs-on: ubuntu-latest - needs: check-cache if: always() steps: - name: Check if secrets are populated From c62f98eb312d335eb9cfef1f3cdbc2a5a5317672 Mon Sep 17 00:00:00 2001 From: Nabil Hachicha Date: Fri, 31 Oct 2025 19:03:49 +0000 Subject: [PATCH 14/14] restore github action conf --- .github/workflows/include-deploy-release.yml | 6 +- .github/workflows/pr.yml | 1797 +++++++++++++++++- 2 files changed, 1769 insertions(+), 34 deletions(-) diff --git a/.github/workflows/include-deploy-release.yml b/.github/workflows/include-deploy-release.yml index 2d58be01db..c75120588c 100644 --- a/.github/workflows/include-deploy-release.yml +++ b/.github/workflows/include-deploy-release.yml @@ -22,11 +22,11 @@ jobs: with: submodules: "recursive" - - name: Setup Java 11 + - name: Setup Java 17 uses: actions/setup-java@v4 with: - distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} - java-version: ${{ vars.VERSION_JAVA }} + distribution: 'temurin' + java-version: 17 - name: Setup Gradle and task/dependency caching uses: gradle/actions/setup-gradle@v3 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 045a3deff4..50fbde862c 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,38 +23,1773 @@ env: # IS_RELEASE_BRANCH: "${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' }}" jobs: + static-analysis: + uses: ./.github/workflows/include-static-analysis.yml + + check-cache: + uses: ./.github/workflows/include-check-cache.yml + # We build the same JNI SWIG stub once and re-use it across platforms to ensure any problems # with SWIG if we compile on each seperate platform. build-jni-swig-stub: runs-on: ubuntu-latest - if: always() - steps: - - name: Check if secrets are populated - # We assign secrets to environment variables for use in the 'run' block. - env: - GPG_KEY_SECRET: ${{ secrets.GPG_SIGNING_KEY_BASE_64 }} - GPG_PASS_SECRET: ${{ secrets.GPG_PASS_PHRASE }} - MAVEN_USER_SECRET: ${{ secrets.MAVEN_CENTRAL_USER }} - MAVEN_PASS_SECRET: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} - - run: | - echo "--- GPG_SIGNING_KEY_BASE_64 as char array ---" - # Use grep -o . to print each character on a new line. - # Note: GitHub Actions may still redact this output. - echo -n "$GPG_KEY_SECRET" | grep -o . - echo "--- End of GPG_SIGNING_KEY_BASE_64 ---" - - echo "--- GPG_PASS_PHRASE as char array ---" - echo -n "$GPG_PASS_SECRET" | grep -o . - echo "--- End of GPG_PASS_PHRASE ---" - - echo "--- MAVEN_CENTRAL_USER as char array ---" - echo -n "$MAVEN_USER_SECRET" | grep -o . - echo "--- End of MAVEN_CENTRAL_USER ---" - - echo "--- MAVEN_CENTRAL_PASSWORD as char array ---" - echo -n "$MAVEN_PASS_SECRET" | grep -o . - echo "--- End of MAVEN_CENTRAL_PASSWORD ---" - - echo "NOTE: GitHub may still redact the output above." - + needs: check-cache + if: always() && !cancelled() && needs.check-cache.outputs.jni-swig-stub-cache-hit != 'true' + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/kotlin.json" + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Load build cache + uses: actions/cache@v4 + with: + path: ./packages/jni-swig-stub/build/generated/sources/jni + key: jni-swig-stubs-${{ needs.check-cache.outputs.packages-sha }} + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + # Manually install SWIG 4.1.1 as only 4.0.2 is pre-installed + # 4.1.1 is not available in apt-get, so use brew instead + # We need to use the formulae directly from GitHub to pin the version as Homebrew does not have + # all versions available. + # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#ubuntu-22041-lts + # It seems to be required to manually add brew dirs to the PATH. This does not happen automatically. + - name: Install SWIG + run: | + test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)" + test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile + echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile + echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH + cd ~ + + - name: Build JNI Stub + working-directory: ./packages + run: ./gradlew :jni-swig-stub:assemble -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: jni-stub-${{ needs.check-cache.outputs.version-label }} + path: ./packages/jni-swig-stub/build/generated/sources/jni/* + retention-days: 1 + + build-jvm-linux-native-lib: + runs-on: ubuntu-22.04 + needs: [check-cache, build-jni-swig-stub] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + needs.check-cache.outputs.jni-linux-lib-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/kotlin.json" + + - name: Setup build cache + uses: actions/cache@v4 + with: + path: ./packages/cinterop/build/realmLinuxBuild + key: jni-linux-lib-${{ needs.check-cache.outputs.packages-sha }} + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Restore JNI Swig Stubs + uses: actions/download-artifact@v4 + with: + name: jni-stub-${{ needs.check-cache.outputs.version-label }} + path: ./packages/jni-swig-stub/build/generated/sources/jni + + - name: Build native lib + working-directory: ./packages/cinterop + run: | + mkdir build + cd build + rm -rf realmLinuxBuild + mkdir realmLinuxBuild + cd realmLinuxBuild + cmake -DCMAKE_BUILD_TYPE=Release \ + -DREALM_ENABLE_SYNC=1 \ + -DREALM_NO_TESTS=1 \ + -DREALM_BUILD_LIB_ONLY=true \ + -DCMAKE_CXX_VISIBILITY_PRESET=hidden \ + -DCMAKE_TOOLCHAIN_FILE=../../../external/core/tools/cmake/x86_64-linux-gnu.toolchain.cmake \ + -DJAVA_INCLUDE_PATH=${{ env.JAVA_HOME }}/include/ \ + ../../src/jvm + make -j8 + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: jni-linux-lib-${{ needs.check-cache.outputs.version-label }} + path: ./packages/cinterop/build/realmLinuxBuild/librealmc.so + retention-days: 1 + + build-jvm-windows-native-lib: + runs-on: windows-latest + needs: [check-cache, build-jni-swig-stub] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + needs.check-cache.outputs.jni-windows-lib-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + # TODO See https://github.com/microsoft/vcpkg/issues/25349 which might describe the error here https://github.com/realm/realm-kotlin/runs/8099890473?check_suite_focus=true + # -- Building for: Visual Studio 17 2022 + # -- Running vcpkg install + # Error: while checking out port openssl with git tree 7e4d802e3bde4154c227c0dd1da75c719be9f07a + # Error: Failed to tar port directory + # error: tar failed with exit code: (128). + # fatal: not a tree object: 7e4d802e3bde4154c227c0dd1da75c719be9f07a + # TODO Implement better work-around here: https://mongodb.slack.com/archives/C017MBM0A30/p1661889411467029?thread_ts=1661888738.117769&cid=C017MBM0A30 + fetch-depth: 0 + submodules: "recursive" + + - name: Setup build cache + uses: actions/cache@v4 + with: + path: ./packages/cinterop/build/realmWindowsBuild + key: jni-windows-lib-${{ needs.check-cache.outputs.packages-sha }} + enableCrossOsArchive: true + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Restore JNI Swig Stubs + uses: actions/download-artifact@v4 + with: + name: jni-stub-${{ needs.check-cache.outputs.version-label }} + path: ${{ github.workspace }}/packages/jni-swig-stub/build/generated/sources/jni + + - name: Build native lib + shell: powershell + working-directory: packages + run: | + cd cinterop + mkdir build + cd build + Remove-Item -Path realmWindowsBuild -Force -Recurse -ErrorAction Ignore + mkdir realmWindowsBuild + cd realmWindowsBuild + cmake ` + ..\..\src\jvm ` + -DCMAKE_GENERATOR_PLATFORM=x64 ` + -DCMAKE_BUILD_TYPE=Release ` + -DREALM_ENABLE_SYNC=ON ` + -DREALM_NO_TESTS=1 ` + -DCMAKE_CXX_VISIBILITY_PRESET=hidden ` + -DVCPKG_TARGET_TRIPLET=x64-windows-static + cmake --build . --config Release + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: jni-windows-lib-${{ needs.check-cache.outputs.version-label }} + path: ./packages/cinterop/build/realmWindowsBuild/Release/realmc.dll + retention-days: 1 + + build-jvm-macos-native-lib: + runs-on: macos-14 + needs: [check-cache, build-jni-swig-stub] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + needs.check-cache.outputs.jni-macos-lib-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Setup ninja + uses: clementetb/setup-ninja@master + with: + version: ${{ vars.VERSION_NINJA }} + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.13 + with: + key: 'jvm-macos-native-lib' + max-size: '2.0G' + + - name: Prepend ccache executables to the PATH + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH + + # See https://github.com/hendrikmuhs/ccache-action/issues/94 + - name: Configure ccache + run: | + ccache --set-config="compiler_check=content" + ccache --show-config + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + + - name: Debug environment + run: | + env + type cmake + cmake --version + type ninja + ninja --version + + # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. + - name: Setup build cache + uses: actions/cache@v4 + with: + path: ./packages/cinterop/build/realmMacOsBuild + key: jni-macos-lib-${{ needs.check-cache.outputs.packages-sha }} + + - name: Restore JNI Swig Stubs + uses: actions/download-artifact@v4 + with: + name: jni-stub-${{ needs.check-cache.outputs.version-label }} + path: ${{ github.workspace }}/packages/jni-swig-stub/build/generated/sources/jni + + - name: Build packages + working-directory: packages + run: ./gradlew buildJVMSharedLibs -Prealm.kotlin.mainHost=false + + - name: Show ccache size + run: | + echo `du -sh ~/.ccache` + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: jni-macos-lib-${{ needs.check-cache.outputs.version-label }} + path: ./packages/cinterop/build/realmMacOsBuild/librealmc.dylib + retention-days: 1 + + build-kotlin-metadata-package: + runs-on: ubuntu-latest + needs: [check-cache] + env: + NDK_VERSION: 23.2.8568313 + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + needs.check-cache.outputs.packages-metadata-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/kotlin.json" + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Setup ninja + uses: clementetb/setup-ninja@master + with: + version: ${{ vars.VERSION_NINJA }} + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.13 + with: + key: 'metadata-package' + max-size: '2.0G' + + - name: Prepend ccache executables to the PATH + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH + + # See https://github.com/hendrikmuhs/ccache-action/issues/94 + - name: Configure ccache + run: | + ccache --set-config="compiler_check=content" + ccache --show-config + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + + # This matches 23.2.8568313, but what happens if we a define specific ndk version in our build? + - name: Setup NDK + uses: nttld/setup-ndk@v1 + with: + ndk-version: r23c + + - name: Setup build cache + uses: actions/cache@v4 + with: + path: ./packages/build/m2-buildrepo + key: packages-m2-metadata-${{ needs.check-cache.outputs.packages-sha }} + + - name: Build Kotlin Metadata and Gradle and Compiler Plugin + working-directory: packages + run: ./gradlew publishCIPackages -Prealm.kotlin.targets=gradlePlugin,compilerPlugin -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=true + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-metadata-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo/**/* + retention-days: 1 + + + # This task is also responsible for creating the Gradle and Compiler Plugin as well as + # all Kotlin Multiplatform Metadata + build-jvm-packages: + runs-on: macos-14 + needs: [check-cache, build-jvm-linux-native-lib, build-jvm-windows-native-lib, build-jvm-macos-native-lib] + env: + NDK_VERSION: 23.2.8568313 + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + needs.check-cache.outputs.packages-jvm-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Register problem matchers + run: |- + echo "::add-matcher::.github/problem-matchers/kotlin.json" + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} + # JVM 17 is required for android-actions/setup-android@v3 + # Last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Setup ninja + uses: clementetb/setup-ninja@master + with: + version: ${{ vars.VERSION_NINJA }} + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.13 + with: + key: 'jvm-package' + max-size: '2.0G' + + - name: Install SWIG + run: brew install swig + + - name: Prepend ccache executables to the PATH + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH + + # See https://github.com/hendrikmuhs/ccache-action/issues/94 + - name: Configure ccache + run: | + ccache --set-config="compiler_check=content" + ccache --show-config + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + + - name: Setup Android SDK + env: + JAVA_HOME: ${{ env.JAVA_HOME_17_ARM64 }} + uses: android-actions/setup-android@v3 + + - name: Install NDK + run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}" + env: + JAVA_HOME: ${{ env.JAVA_HOME_17_ARM64 }} + + # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. + - name: Setup build cache + uses: actions/cache@v4 + with: + path: ./packages/build/m2-buildrepo + key: packages-m2-jvm-sync-${{ needs.check-cache.outputs.packages-sha }} + + - name: Restore Linux JNI lib + uses: actions/download-artifact@v4 + with: + name: jni-linux-lib-${{ needs.check-cache.outputs.version-label }} + path: ./packages/cinterop/build/realmLinuxBuild + + - name: Restore Windows JNI lib + uses: actions/download-artifact@v4 + with: + name: jni-windows-lib-${{ needs.check-cache.outputs.version-label }} + path: ./packages/cinterop/build/realmWindowsBuild/Release + + - name: Restore MacOS JNI lib + uses: actions/download-artifact@v4 + with: + name: jni-macos-lib-${{ needs.check-cache.outputs.version-label }} + path: ./packages/cinterop/build/realmMacOsBuild + + - name: Build JVM Package + working-directory: packages + run: ./gradlew publishCIPackages -Prealm.kotlin.targets=jvm -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.copyNativeJvmLibs=linux,windows,macos -Prealm.kotlin.mainHost=false + + - name: Show ccache size + run: | + echo `du -sh ~/.ccache` + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-jvm-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo/**/* + retention-days: 1 + + + build-android-packages: + runs-on: ubuntu-latest + needs: check-cache + env: + NDK_VERSION: 23.2.8568313 + outputs: + baas-container-id: ${{ steps.baas_cli_start.outputs.baas_container_id }} + if: | + always() && !cancelled() && + (needs.check-cache.outputs.packages-android-cache-hit != 'true' || + needs.check-cache.outputs.android-test-base-apk-cache-hit != 'true' || + needs.check-cache.outputs.android-test-sync-apk-cache-hit != 'true') + + steps: + - name: Remove unnecessary files + run: | + sudo rm -rf /usr/share/dotnet + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: ${{ vars.VERSION_JAVA_DISTRIBUTION }} + # JVM 17 is required for android-actions/setup-android@v3 + # Last version will be used and available globally. Other Java versions can be accessed through env variables with such specification as 'JAVA_HOME_{{ MAJOR_VERSION }}_{{ ARCHITECTURE }}' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + # Manually install SWIG 4.1.1 as only 4.0.2 is pre-installed + # 4.1.1 is not available in apt-get, so use brew instead + # We need to use the formulae directly from GitHub to pin the version as Homebrew does not have + # all versions available. + # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#ubuntu-22041-lts + # It seems to be required to manually add brew dirs to the PATH. This does not happen automatically. + - name: Install SWIG + run: | + test -d ~/.linuxbrew && eval "$(~/.linuxbrew/bin/brew shellenv)" + test -d /home/linuxbrew/.linuxbrew && eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)" + test -r ~/.bash_profile && echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.bash_profile + echo "eval \"\$($(brew --prefix)/bin/brew shellenv)\"" >> ~/.profile + echo "/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH + echo "/home/linuxbrew/.linuxbrew/bin" >> $GITHUB_PATH + cd ~ + + - name: Install JSON parser + run: brew install jq + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Setup ninja + uses: clementetb/setup-ninja@master + with: + version: ${{ vars.VERSION_NINJA }} + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.13 + with: + key: 'android-package' + max-size: '2.0G' + + - name: Prepend ccache executables to the PATH + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH + + # See https://github.com/hendrikmuhs/ccache-action/issues/94 + - name: Configure ccache + run: | + ccache --set-config="compiler_check=content" + ccache --show-config + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + + - name: Setup Android SDK + uses: android-actions/setup-android@v3 + env: + JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} + + - name: Install NDK + env: + JAVA_HOME: ${{ env.JAVA_HOME_17_X64 }} + run: sdkmanager --install "ndk;${{ env.NDK_VERSION }}" + + - name: Build Android Base Test Apk + working-directory: packages + run: ./gradlew :test-base:assembleAndroidTest -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false + + - name: Build Android Sync Test Apk + working-directory: packages + run: ./gradlew :test-sync:packageDebug :test-sync:assembleAndroidTest -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false + + - name: Build packages + working-directory: packages + run: ./gradlew publishCIPackages -Prealm.kotlin.targets=android -Prealm.kotlin.buildRealmCore=false -Prealm.kotlin.mainHost=false + + - name: Store build cache + uses: actions/cache@v4 + with: + path: ./packages/build/m2-buildrepo + key: packages-m2-android-sync-${{ needs.check-cache.outputs.packages-sha }} + + - name: Store build cache for Android Test APK + uses: actions/cache@v4 + with: + path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk + key: android-base-test-apk-key-${{ needs.check-cache.outputs.packages-sha }} + + # Must match naming found in include-check-cache.yml + - name: Store build cache for Android Sync Test APK + uses: actions/cache@v4 + with: + key: android-sync-test-apk-key-${{ needs.check-cache.outputs.packages-sha }} + path: | + ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk + ./packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk + + # Must match naming found in include-check-cache.yml + # Must match naming found in include-check-cache.yml + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-android-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo/**/* + retention-days: 1 + + - name: Upload Android Base Test APK + uses: actions/upload-artifact@v4 + with: + name: android-base-test-apk-${{ needs.check-cache.outputs.version-label }} + path: ./packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk + retention-days: 1 + + - name: Upload Android Sync Test APK + uses: actions/upload-artifact@v4 + with: + name: android-sync-test-apk-${{ needs.check-cache.outputs.version-label }} + retention-days: 1 + path: | + ./packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk + ./packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk + + + # TODO: ccache is not being used by this build for some reason + build-macos-x64-packages: + runs-on: macos-14 # x64 builds fine on an arm64 node + needs: check-cache + if: always() && !cancelled() && needs.check-cache.outputs.packages-macos-x64-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Setup ninja + uses: clementetb/setup-ninja@master + with: + version: ${{ vars.VERSION_NINJA }} + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.13 + with: + key: 'macos-x64-package' + max-size: '2.0G' + + - name: Install SWIG + run: brew install swig + + - name: Prepend ccache executables to the PATH + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH + + # See https://github.com/hendrikmuhs/ccache-action/issues/94 + - name: Configure ccache + run: | + ccache --set-config="compiler_check=content" + ccache --show-config + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + + - name: Build packages + working-directory: packages + run: ./gradlew publishCIPackages -Prealm.kotlin.targets=macosX64 -Prealm.kotlin.mainHost=false + + - name: Show ccache size + run: | + echo `du -sh ~/.ccache` + + # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. + - name: Store build cache + uses: actions/cache@v4 + with: + path: ./packages/build/m2-buildrepo + key: packages-m2-macos-x64-sync-${{ needs.check-cache.outputs.packages-sha }} + + # Must match naming found in include-check-cache.yml + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-macos-x64-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo/**/* + retention-days: 1 + + build-macos-arm64-packages: + runs-on: macos-14 + needs: check-cache + # needs: static-analysis + if: always() && !cancelled() && needs.check-cache.outputs.packages-macos-arm64-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Setup ninja + uses: clementetb/setup-ninja@master + with: + version: ${{ vars.VERSION_NINJA }} + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.13 + with: + key: 'macos-arm64-package' + max-size: '2.0G' + + - name: Install SWIG + run: brew install swig + + - name: Prepend ccache executables to the PATH + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH + + # See https://github.com/hendrikmuhs/ccache-action/issues/94 + - name: Configure ccache + run: | + ccache --set-config="compiler_check=content" + ccache --show-config + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + + - name: Build packages + working-directory: packages + run: ./gradlew publishCIPackages -Prealm.kotlin.targets=macosArm64 -Prealm.kotlin.mainHost=false + + - name: Store build cache + uses: actions/cache@v4 + with: + path: ./packages/build/m2-buildrepo + key: packages-m2-macos-arm64-sync-${{ needs.check-cache.outputs.packages-sha }} + + # Must match naming found in include-check-cache.yml + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-macos-arm64-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo/**/* + retention-days: 1 + + build-ios-x64-packages: + runs-on: macos-14 # x64 builds fine on an arm64 node + needs: check-cache + # needs: static-analysis + if: always() && !cancelled() && needs.check-cache.outputs.packages-ios-x64-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Setup ninja + uses: clementetb/setup-ninja@master + with: + version: ${{ vars.VERSION_NINJA }} + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.13 + with: + key: 'ios-x64-package' + max-size: '2.0G' + + - name: Install SWIG + run: brew install swig + + - name: Prepend ccache executables to the PATH + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH + + # See https://github.com/hendrikmuhs/ccache-action/issues/94 + - name: Configure ccache + run: | + ccache --set-config="compiler_check=content" + ccache --show-config + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + + - name: Build packages + working-directory: packages + run: ./gradlew publishCIPackages -Prealm.kotlin.targets=iosX64 -Prealm.kotlin.mainHost=false + + # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. + - name: Store build cache + uses: actions/cache@v4 + with: + path: ./packages/build/m2-buildrepo + key: packages-m2-ios-x64-sync-${{ needs.check-cache.outputs.packages-sha }} + + # Must match naming found in include-check-cache.yml + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-ios-x64-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo/**/* + retention-days: 1 + + build-ios-arm64-packages: + runs-on: macos-14 + needs: check-cache + # needs: static-analysis + if: always() && !cancelled() && needs.check-cache.outputs.packages-ios-arm64-cache-hit != 'true' + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Setup cmake + uses: jwlawson/actions-setup-cmake@v2.0.2 + with: + cmake-version: ${{ vars.VERSION_CMAKE }} + + - name: Setup ninja + uses: clementetb/setup-ninja@master + with: + version: ${{ vars.VERSION_NINJA }} + + - name: Install ccache + uses: hendrikmuhs/ccache-action@v1.2.13 + with: + key: 'ios-arm64-package' + max-size: '2.0G' + + - name: Install SWIG + run: brew install swig + + - name: Prepend ccache executables to the PATH + run: echo "/usr/lib/ccache:/usr/local/opt/ccache/libexec" >> $GITHUB_PATH + + # See https://github.com/hendrikmuhs/ccache-action/issues/94 + - name: Configure ccache + run: | + ccache --set-config="compiler_check=content" + ccache --show-config + echo '#!/bin/bash\nccache clang "$@"%"' > /usr/local/bin/ccache-clang + echo '#!/bin/bash\nccache clang++ "$@"%"' > /usr/local/bin/ccache-clang++ + + - name: Build packages + working-directory: packages + run: ./gradlew publishCIPackages -Prealm.kotlin.targets=iosArm64 -Prealm.kotlin.mainHost=false + + # We cannot use artifacts as they cannot be shared between workflows, so use cache instead. + - name: Store build cache + uses: actions/cache@v4 + with: + path: ./packages/build/m2-buildrepo + key: packages-m2-ios-arm64-sync-${{ needs.check-cache.outputs.packages-sha }} + + # Must match naming found in include-check-cache.yml + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: packages-ios-arm64-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo/**/* + retention-days: 1 + + + # TODO Split into base and sync tests + # TODO If we hook up to Device Farm we can use ubuntu runners instead + # TODO Compare speed between emulator and Device Farm + # TODO We should be able to move this into a reusable work-flow + + # TODO Compare speed between emulator and Device Farm + # TODO We should be able to move this into a reusable work-flow + test-android-packages-emulator: + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + type: [base, sync] + include: + - type: base + test-title: Unit Test Results - Android Base (Emulator) + - type: sync + test-title: Unit Test Results - Android Sync (Emulator) + + runs-on: macos-13 # android emulator does not run on arm64 - https://github.com/ReactiveCircus/android-emulator-runner/issues/350 + needs: [check-cache, build-android-packages, build-jvm-packages, build-kotlin-metadata-package] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: "recursive" + + # checkout BAAS CLI repo + - name: Checkout BAAS repo + if: matrix.type == 'sync' + run: | + echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token + gh repo clone 10gen/baasaas + + # Start BAAS instance in the background + # We save the container id to poll against and get the hostname info later + - name: Start Baas instance in the background + id: baas_cli_start + if: matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner + # curl: option --data: error encountered when reading a file + OUTPUT=$(bash cli.sh start | jq -r '.id') + echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Restore Kotlin metadata artifacts + uses: actions/download-artifact@v4 + with: + name: packages-metadata-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore m2-buildrepo (Android) + uses: actions/download-artifact@v4 + with: + name: packages-android-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore m2-buildrepo (JVM) + uses: actions/download-artifact@v4 + with: + name: packages-jvm-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests + - name: Fetching the BAAS CLI hostname + id: baas_cli_poll + if: matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') + echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT + + # TODO This action does not support using `\` to split multiline scripts. + - name: Run Integration Tests + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + uses: reactivecircus/android-emulator-runner@v2 + with: + emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none + disable-animations: true + api-level: ${{ vars.VERSION_ANDROID_EMULATOR_API_LEVEL }} # Must be 30 to support aosp_atd + target: default + arch: x86_64 + disk-size: 4096M + ram-size: 2048M + heap-size: 1024M + channel: canary + script: | + adb logcat -c + adb logcat > logcat.txt & + cd packages && ./gradlew :test-${{ matrix.type }}:connectedCheck -PsyncUsePlatformNetworking=true -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} -PincludeSdkModules=false --info --no-daemon + + - name: Archive LogCat data + uses: actions/upload-artifact@v4 + if: always() || failure() + with: + name: logcat-${{ matrix.type }}-emulator.txt + path: logcat.txt + retention-days: 1 + + - name: Publish Unit Test Results + uses: dorny/test-reporter@v1 + if: always() || failure() + with: + name: ${{ matrix.test-title }} + path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml + reporter: java-junit + list-suites: failed + list-tests: failed + fail-on-error: true + + - name: Stopping the BAAS container + if: always() && matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then + bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} + fi + + # Disable device farm test for Base, because running two in parallel seems to interfer somehow + test-android-packages-device-farm: + name: AWS Device Farm + timeout-minutes: 60 + runs-on: ubuntu-latest + needs: [ check-cache, build-android-packages, build-jvm-packages ] + if: | + false && + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Restore Android Test APK + uses: actions/download-artifact@v4 + with: + name: android-base-test-apk-${{ needs.check-cache.outputs.version-label }} + path: ./packages/test-base/build/outputs/apk/androidTest/debug + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + - name: Run the tests + uses: ./.github/actions/run-android-device-farm-test + id: run_android_tests + with: + apk-path: ${{ github.workspace }}/packages/test-base/build/outputs/apk/androidTest/debug/test-base-debug-androidTest.apk + app-id: io.realm.testapp + project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} + device-pool-arn: ${{ secrets.DEVICEFARM_POOL_ARN }} + + + test-android-packages-device-farm-sync: + name: AWS Device Farm Sync Tests + timeout-minutes: 60 + runs-on: ubuntu-latest + needs: [ check-cache, build-android-packages, build-jvm-packages ] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # checkout BAAS CLI repo + - name: Checkout BAAS repo + run: | + echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token + gh repo clone 10gen/baasaas + + # Start BAAS instance in the background + # We save the container id to poll against and get the hostname info later + - name: Start Baas instance in the background + id: baas_cli_start + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + OUTPUT=$(bash cli.sh start | jq -r '.id') + echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Restore Android Sync Test APK + uses: actions/download-artifact@v4 + with: + name: android-sync-test-apk-${{ needs.check-cache.outputs.version-label }} + path: ./packages/test-sync/build/outputs/apk/ + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_DEVICEFARM_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_DEVICEFARM_SECRET_ACCESS_KEY }} + aws-region: us-west-2 + + # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests + - name: Fetching the BAAS CLI hostname + id: baas_cli_poll + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') + echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Run the Sync tests + uses: ./.github/actions/run-android-device-farm-test + id: run_android_tests + with: + apk-path: ${{ github.workspace }}/packages/test-sync/build/outputs/apk/androidTest/debug/test-sync-debug-androidTest.apk + apk-auxiliary-path: ${{ github.workspace }}/packages/test-sync/build/outputs/apk/debug/test-sync-debug.apk + baas_url: ${{ steps.baas_cli_poll.outputs.baas_container_hostname }} + app-id: io.realm.sync.testapp.test + project-arn: ${{ secrets.DEVICEFARM_PROJECT_ARN }} + device-pool-arn: ${{ secrets.DEVICEFARM_POOL_ARN }} + + - name: Stopping the BAAS container + if: always() + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then + bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} + fi + + test-macos-packages: + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [macos-13, macos-14] + type: [base, sync] + include: + - os: macos-13 + type: base + os-id: macos + package-prefix: macos-x64 + test-title: Unit Test Results - MacOS x64 Base + - os: macos-13 + type: sync + os-id: macos + package-prefix: macos-x64 + test-title: Unit Test Results - MacOS x64 Sync + - os: macos-14 + type: base + os-id: macos + package-prefix: macos-arm64 + test-title: Unit Test Results - MacOS arm64 Base + - os: macos-14 + type: sync + os-id: macos + package-prefix: macos-arm64 + test-title: Unit Test Results - MacOS arm64 Sync + + runs-on: ${{ matrix.os }} + # TODO Unclear why MacOS needs the metadata package when the Android Tests do not + # Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it. + needs: [check-cache, build-kotlin-metadata-package, build-macos-x64-packages, build-macos-arm64-packages] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # checkout BAAS CLI repo + - name: Checkout BAAS repo + if: matrix.type == 'sync' + run: | + echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token + gh repo clone 10gen/baasaas + + # Start BAAS instance in the background + # We save the container id to poll against and get the hostname info later + - name: Start Baas instance in the background + id: baas_cli_start + if: matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner + # curl: option --data: error encountered when reading a file + OUTPUT=$(bash cli.sh start | jq -r '.id') + echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Restore m2-buildrepo + uses: actions/download-artifact@v4 + with: + name: packages-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore Kotlin metadata artifacts + uses: actions/download-artifact@v4 + with: + name: packages-metadata-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + + # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests + - name: Fetching the BAAS CLI hostname + id: baas_cli_poll + if: matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') + echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Run tests + working-directory: packages + run: > + ./gradlew :test-${{ matrix.type }}:macosTest + -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} + -PincludeSdkModules=false + --info --no-daemon + + - name: Publish Unit Test Results + uses: dorny/test-reporter@v1 + if: always() || failure() + with: + name: ${{ matrix.test-title }} + path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml + reporter: java-junit + list-suites: failed + list-tests: failed + fail-on-error: true + + - name: Stopping the BAAS container + if: always() && matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then + bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} + fi + + + test-ios-packages: + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [macos-13, macos-14] + type: [base, sync] + include: + - os: macos-13 + type: base + package-prefix: x64 + test-title: Unit Test Results - iOS x64 Base + test-task: iosTest + - os: macos-13 + type: sync + package-prefix: x64 + test-title: Unit Test Results - iOS x64 Sync + test-task: iosTest + - os: macos-14 + type: base + package-prefix: arm64 + test-title: Unit Test Results - iOS arm64 Base + test-task: iosTest + - os: macos-14 + type: sync + package-prefix: arm64 + test-title: Unit Test Results - iOS arm64 Sync + test-task: iosTest + + runs-on: ${{ matrix.os }} + # TODO Unclear why MacOS needs the metadata package when the Android Tests do not + # Disable macos-arm for now as the host needs to have the Android SDK installed even though it isn't really using it. + needs: [check-cache, build-kotlin-metadata-package, build-ios-x64-packages, build-ios-arm64-packages] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # checkout BAAS CLI repo + - name: Checkout BAAS repo + if: matrix.type == 'sync' + run: | + echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token + gh repo clone 10gen/baasaas + + # Start BAAS instance in the background + # We save the container id to poll against and get the hostname info later + - name: Start Baas instance in the background + id: baas_cli_start + if: matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner + # curl: option --data: error encountered when reading a file + OUTPUT=$(bash cli.sh start | jq -r '.id') + echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Restore m2-buildrepo (ios) + uses: actions/download-artifact@v4 + with: + name: packages-ios-${{ matrix.package-prefix }}-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore Kotlin metadata artifacts + uses: actions/download-artifact@v4 + with: + name: packages-metadata-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + + # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests + - name: Fetching the BAAS CLI hostname + id: baas_cli_poll + if: matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') + echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT + + # App names are limited to 32 characters, so the appNamePrefix should not exceed 22 characters. + - name: Run tests + working-directory: packages + run: > + ./gradlew :test-${{ matrix.type }}:${{ matrix.test-task }} + -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} + -PincludeSdkModules=false + --info --no-daemon + + - name: Publish Unit Test Results + uses: dorny/test-reporter@v1 + if: always() || failure() + with: + name: ${{ matrix.test-title }} + path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml + reporter: java-junit + list-suites: failed + list-tests: failed + fail-on-error: true + + - name: Stopping the BAAS container + if: always() && matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then + bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} + fi + + test-jvm-packages: + timeout-minutes: 60 + strategy: + fail-fast: false + matrix: + os: [macos-13, macos-14, ubuntu-latest, windows-latest] + type: [base, sync] + include: + - os: macos-13 + os-id: mac + type: base + test-title: Unit Test Results - Base JVM MacOS x64 + - os: macos-14 + os-id: mac + type: base + test-title: Unit Test Results - Base JVM MacOS arm64 + - os: ubuntu-latest + os-id: ubu + type: base + test-title: Unit Test Results - Base JVM Linux + - os: windows-latest + os-id: win + type: base + test-title: Unit Test Results - Base JVM Windows + - os: macos-13 + os-id: mac + type: sync + test-title: Unit Test Results - Sync JVM MacOS x64 + - os: macos-14 + os-id: mac + type: sync + test-title: Unit Test Results - Sync JVM MacOS arm64 + - os: ubuntu-latest + os-id: ubu + type: sync + test-title: Unit Test Results - Sync JVM Linux + exclude: + # Do not run Windows Sync Tests, because the bash script for + # starting the BAAS container doesn not work on Windows. + - os: windows-latest + #os-id: win + type: sync + #test-title: Unit Test Results - Sync JVM Windows + + runs-on: ${{ matrix.os }} + needs: [check-cache, build-jvm-packages, build-kotlin-metadata-package] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # checkout BAAS CLI repo + - name: Checkout BAAS repo + if: matrix.type == 'sync' + run: | + echo ${{ secrets.BAAS_CLI }} | gh auth login --with-token + gh repo clone 10gen/baasaas + + # Start BAAS instance in the background + # We save the container id to poll against and get the hostname info later + - name: Start Baas instance in the background + id: baas_cli_start + if: matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + # Adding a dummy tag (foo=bar) to avoid the following issue on macos-runner + # curl: option --data: error encountered when reading a file + OUTPUT=$(bash cli.sh start | jq -r '.id') + echo "baas_container_id=$OUTPUT" >> $GITHUB_OUTPUT + + - name: Setup Java 17 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 17 + + - name: Setup Gradle and task/dependency caching + uses: gradle/actions/setup-gradle@v3 + with: + cache-read-only: false + + - name: Restore Kotlin metadata artifacts + uses: actions/download-artifact@v4 + with: + name: packages-metadata-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore m2-buildrepo + uses: actions/download-artifact@v4 + with: + name: packages-jvm-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + # We poll the previously started BAAS container to get the hostname of the container to use with Device Farm tests + - name: Fetching the BAAS CLI hostname + id: baas_cli_poll + if: matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + OUTPUT=$(bash cli.sh poll ${{ steps.baas_cli_start.outputs.baas_container_id }} | jq -r '.httpUrl') + echo "baas_container_hostname=$OUTPUT" >> $GITHUB_OUTPUT + + # App names are limited to 32 characters, so the appNamePrefix should not exceed 22 characters. + - name: Run tests + working-directory: packages + run: > + ./gradlew :test-${{ matrix.type }}:jvmTest + -PsyncUsePlatformNetworking=true + -PsyncTestUrl=${{ steps.baas_cli_poll.outputs.baas_container_hostname }} + -PincludeSdkModules=false + --info --no-daemon + + - name: Publish Unit Test Results + uses: dorny/test-reporter@v1 + if: always() || failure() + with: + name: ${{ matrix.test-title }} + path: ./packages/test-${{ matrix.type }}/build/**/TEST-*.xml + reporter: java-junit + list-suites: failed + list-tests: failed + fail-on-error: true + + - name: Stopping the BAAS container + if: always() && matrix.type == 'sync' + working-directory: baasaas + env: + APIKEY: ${{ secrets.BAAS_CLI_API_KEY }} + run: | + if [ -n "${{ steps.baas_cli_start.outputs.baas_container_id }}" ]; then + bash cli.sh stop ${{ steps.baas_cli_start.outputs.baas_container_id }} + fi + + package-all-artifacts: + runs-on: ubuntu-latest + needs: [check-cache, build-jvm-packages, build-android-packages, build-macos-x64-packages, build-macos-arm64-packages, build-ios-x64-packages, build-ios-arm64-packages, build-kotlin-metadata-package] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + # The Metadata artifact contain broken JVM publications, so it needs to be + # restored first, it so they can be overidden with the correct ones. + - name: Restore Kotlin metadata artifacts + uses: actions/download-artifact@v4 + with: + name: packages-metadata-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore Android artifacts + uses: actions/download-artifact@v4 + with: + name: packages-android-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore JVM artifacts + uses: actions/download-artifact@v4 + with: + name: packages-jvm-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore MacOS x64 artifacts + uses: actions/download-artifact@v4 + with: + name: packages-macos-x64-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore MacOS arm64 artifacts + uses: actions/download-artifact@v4 + with: + name: packages-macos-arm64-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore iOS x64 artifacts + uses: actions/download-artifact@v4 + with: + name: packages-ios-x64-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Restore iOS arm64 artifacts + uses: actions/download-artifact@v4 + with: + name: packages-ios-arm64-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + + - name: Upload artifacts bundle + uses: actions/upload-artifact@v4 + with: + name: all-packages-${{ needs.check-cache.outputs.version-label }} + path: ./packages/build/m2-buildrepo + retention-days: 7 + + integration-tests: + uses: ./.github/workflows/include-integration-tests.yml + needs: [check-cache, package-all-artifacts] + if: | + always() && + !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') + with: + version-label: ${{ needs.check-cache.outputs.version-label }} + + deploy-snapshot: + uses: ./.github/workflows/include-deploy-snapshot.yml + needs: [ + check-cache, + static-analysis, + integration-tests, + test-jvm-packages, + test-macos-packages, + test-ios-packages, + test-android-packages-emulator, + # test-android-packages-device-farm, + test-android-packages-device-farm-sync, + package-all-artifacts + ] + if: | + always() && + !cancelled() && + endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') + + secrets: inherit + with: + version-label: ${{ needs.check-cache.outputs.version-label }} + + # This job sets an output `is_publish_build` to `true` if this is a release build + check-release-build: + runs-on: ubuntu-latest + needs: [check-cache] + outputs: + is_publish_build: ${{ steps.check_release.outputs.is_publish_build }} + + steps: + - uses: actions/checkout@v4 + + - name: Check if release build + id: check_release + run: | + git fetch --tags + gitTag=$(git describe --tags --exact-match HEAD) || echo "NONE" + echo "Git branch/tag: ${GITHUB_REF}/${gitTag:-'none'}" + + if [[ -z "$gitTag" ]]; then + gitSha=$(git rev-parse HEAD | cut -c1-8) + echo "Building commit: ${{ needs.check-cache.outputs.version-label }} - ${gitSha}" + echo "is_publish_build=false" >> $GITHUB_OUTPUT + else + if [[ "$gitTag" != "v${{ needs.check-cache.outputs.version-label }}" ]]; then + echo "Git tag '${gitTag}' does not match v${{ needs.check-cache.outputs.version-label }}" + echo "is_publish_build=false" >> $GITHUB_OUTPUT + else + echo "Building release: '${gitTag}'" + echo "is_publish_build=true" >> $GITHUB_OUTPUT + fi + fi + + + - name: Print is release build + run: | + echo "Is release build: ${{ steps.check_release.outputs.is_publish_build }}" + + deploy-release: + uses: ./.github/workflows/include-deploy-release.yml + needs: [ + check-cache, + check-release-build, + static-analysis, + integration-tests, + test-jvm-packages, + test-macos-packages, + test-ios-packages, + test-android-packages-emulator, + # test-android-packages-device-farm, + test-android-packages-device-farm-sync, + package-all-artifacts + ] + if: | + always() && + !cancelled() && + !endsWith(needs.check-cache.outputs.version-label, '-SNAPSHOT') && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/releases' || github.ref == 'refs/heads/release/k2') && + (needs.check-release-build.outputs.is_publish_build == 'true') + + secrets: inherit + with: + version-label: ${{ needs.check-cache.outputs.version-label }} + packages-sha-label: ${{ needs.check-cache.outputs.packages-sha }}