diff --git a/.github/workflows/check-pr-title.yml b/.github/workflows/check-pr-title.yml new file mode 100644 index 0000000000..1842f5bf39 --- /dev/null +++ b/.github/workflows/check-pr-title.yml @@ -0,0 +1,22 @@ +# NOTE: This is a common file that is overwritten by realm/ci-actions sync service +# and should only be modified in that repository. + +name: "Check PR Title" +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled, converted_to_draft, edited] + +jobs: + check-pr-title: + name: Check PR Title + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: false + - name: Enforce PR title + uses: realm/ci-actions/title-checker@main + with: + regex: R[A-Z]{2,6}-[0-9]{1,6} + error-hint: Invalid PR title. Make sure it's prefixed with the JIRA ticket the PR addresses or add the no-jira-ticket label. + ignore-labels: 'no-jira-ticket' \ No newline at end of file diff --git a/.github/workflows/include-deploy-snapshot.yml b/.github/workflows/include-deploy-snapshot.yml index 3f5a5b1842..d50f9abbdc 100644 --- a/.github/workflows/include-deploy-snapshot.yml +++ b/.github/workflows/include-deploy-snapshot.yml @@ -41,12 +41,12 @@ jobs: path: ./packages/build/m2-buildrepo - name: Publish SNAPSHOT to Maven Central - env: - GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY_BASE_64 }} - GPG_PASS_PHRASE: ${{ secrets.GPG_PASS_PHRASE }} - MAVEN_CENTRAL_USER: ${{ secrets.MAVEN_CENTRAL_USER }} - MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + # env: + # GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY_BASE_64 }} + # GPG_PASS_PHRASE: ${{ secrets.GPG_PASS_PHRASE }} + # MAVEN_CENTRAL_USER: ${{ secrets.MAVEN_CENTRAL_USER }} + # MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} working-directory: tools run: | export GPG_TTY=$(tty) - kotlin ./publish_snapshots.main.kts "../" "${{ inputs.version-label }}" "$GPG_SIGNING_KEY" "$GPG_PASS_PHRASE" "$MAVEN_CENTRAL_USER" "$MAVEN_CENTRAL_PASSWORD" + kotlin ./publish_snapshots.main.kts "../" "${{ inputs.version-label }}" "${{ secrets.GPG_SIGNING_KEY_BASE_64 }}" "${{ secrets.GPG_PASS_PHRASE }}" "${{ secrets.MAVEN_CENTRAL_USER }}" "${{ secrets.MAVEN_CENTRAL_PASSWORD }}" diff --git a/.github/workflows/include-integration-tests.yml b/.github/workflows/include-integration-tests.yml index acf8a6abaa..e8b35c5133 100644 --- a/.github/workflows/include-integration-tests.yml +++ b/.github/workflows/include-integration-tests.yml @@ -7,6 +7,11 @@ on: required: true type: string +env: + REALM_DISABLE_ANALYTICS: true + REALM_PRINT_ANALYTICS: true + REALM_FAIL_ON_ANALYTICS_ERRORS: true + jobs: # TODO: The Monkey seems to crash the app all the time, but with failures that are not coming from the app. Figure out why. diff --git a/.github/workflows/issue-labeler.yml b/.github/workflows/issue-labeler.yml index 5c9af500c0..a93e0c8c02 100644 --- a/.github/workflows/issue-labeler.yml +++ b/.github/workflows/issue-labeler.yml @@ -19,7 +19,7 @@ jobs: template: [ bug.yml, feature.yml ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Parse issue form uses: stefanbuck/github-issue-parser@c1a559d78bfb8dd05216dab9ffd2b91082ff5324 # v3.0.1 diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index c84c0fead1..611f4a4c21 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -15,6 +15,7 @@ concurrency: env: REALM_DISABLE_ANALYTICS: true + REALM_PRINT_ANALYTICS: true CMAKE_C_COMPILER: /usr/local/bin/ccache-clang 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 @@ -231,7 +232,7 @@ jobs: !cancelled() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && - needs.check-cache.outputs.jni-windows-lib-cache-hit != 'true' + needs.check-cache.outputs.jni-macos-lib-cache-hit != 'true' steps: - name: Checkout code diff --git a/CHANGELOG.md b/CHANGELOG.md index a150bebb97..185667886c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Fixed * Cache notification callback JNI references at startup to ensure that symbols can be resolved in core callbacks. (Issue [#1577](https://github.com/realm/realm-kotlin/issues/1577)) * Using `Realm.asFlow()` could miss an update if a write was started right after opening the Realm. (Issue [#1582](https://github.com/realm/realm-kotlin/issues/1582)) +* Guarded analytic errors so that they do not fail user builds. * [Sync] `NullPointerException` while waiting for the synchronization of a subscription set if the client was set in `AwaitingMark` state. (Issue [#1671](https://github.com/realm/realm-kotlin/issues/1671) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1027)) * Github Action: Snapshot publishing with Github Action. (Issue [#1654](https://github.com/realm/realm-kotlin/issues/1654) [JIRA](https://jira.mongodb.org/browse/RKOTLIN-1018)) * Github Action: automate release process to Maven Central. (Issue [JIRA](https://jira.mongodb.org/browse/RKOTLIN-709)) diff --git a/packages/gradle-plugin/src/main/kotlin/io/realm/kotlin/gradle/RealmCompilerSubplugin.kt b/packages/gradle-plugin/src/main/kotlin/io/realm/kotlin/gradle/RealmCompilerSubplugin.kt index a6cbbccb58..3efef80de3 100644 --- a/packages/gradle-plugin/src/main/kotlin/io/realm/kotlin/gradle/RealmCompilerSubplugin.kt +++ b/packages/gradle-plugin/src/main/kotlin/io/realm/kotlin/gradle/RealmCompilerSubplugin.kt @@ -217,18 +217,23 @@ class RealmCompilerSubplugin : KotlinCompilerPluginSupportPlugin, AnalyticsError options.add(SubpluginOption(key = featureListPathKey, featureListPath)) // Gather target specific information - val targetInfo: TargetInfo? = gatherTargetInfo(kotlinCompilation) + val targetInfo: TargetInfo? = muteErrors { + gatherTargetInfo(kotlinCompilation) + } + // If we have something to submit register it for submission after the compilation has // gathered the feature list information targetInfo?.let { kotlinCompilation.compileTaskProvider.get().doLast { - val analyticsService = provider.get() - val json = analyticsService.toJson(targetInfo) - if (printAnalytics) { - analyticsService.print(json) - } - if (submitAnalytics) { - analyticsService.submit(json) + muteErrors { + val analyticsService = provider.get() + val json = analyticsService.toJson(targetInfo) + if (printAnalytics) { + analyticsService.print(json) + } + if (submitAnalytics) { + analyticsService.submit(json) + } } } } @@ -237,6 +242,20 @@ class RealmCompilerSubplugin : KotlinCompilerPluginSupportPlugin, AnalyticsError options } } + + /** + * Wrapper that ignores error if `failOnAnalyticsError=true`. + */ + private fun muteErrors(block: () -> R): R? { + return try { + block() + } catch (e: Throwable) { + when { + failOnAnalyticsError -> { throw e } + else -> { null } + } + } + } } /** @@ -336,15 +355,19 @@ fun nativeTarget(target: KonanTarget) = when (target.family) { } // Helper method to ensure that we align architecture strings for Kotlin native builds -fun nativeArch(target: KonanTarget) = when (target.architecture) { - Architecture.X64 -> io.realm.kotlin.gradle.analytics.Architecture.X64.serializedName - Architecture.X86 -> io.realm.kotlin.gradle.analytics.Architecture.X86.serializedName - Architecture.ARM64 -> io.realm.kotlin.gradle.analytics.Architecture.ARM64.serializedName - Architecture.ARM32 -> io.realm.kotlin.gradle.analytics.Architecture.ARM.serializedName - Architecture.MIPS32 -> "Mips" - Architecture.MIPSEL32 -> "MipsEL32" - Architecture.WASM32 -> "Wasm" - else -> unknown(target.architecture.name) +fun nativeArch(target: KonanTarget): String = try { + when (target.architecture) { + Architecture.X64 -> io.realm.kotlin.gradle.analytics.Architecture.X64.serializedName + Architecture.X86 -> io.realm.kotlin.gradle.analytics.Architecture.X86.serializedName + Architecture.ARM64 -> io.realm.kotlin.gradle.analytics.Architecture.ARM64.serializedName + Architecture.ARM32 -> io.realm.kotlin.gradle.analytics.Architecture.ARM.serializedName + Architecture.MIPS32 -> "Mips" + Architecture.MIPSEL32 -> "MipsEL32" + Architecture.WASM32 -> "Wasm" + else -> unknown(target.architecture.name) + } +} catch (e: Throwable) { + unknown(target.architecture.name) } // Helper method to ensure that we align architecture strings for Android platforms