From 798040bf64cf841298c041b8609b4dbd0883191b Mon Sep 17 00:00:00 2001 From: Mansi-mParticle <159845845+Mansi-mParticle@users.noreply.github.com> Date: Wed, 15 May 2024 17:54:45 -0400 Subject: [PATCH] fix: Update mac version and JDK version into yml file (#482) --- .github/workflows/cross-platform-tests.yml | 2 +- .github/workflows/pull-request.yml | 58 +++++++++++-------- android-core/build.gradle | 8 +++ .../kotlin/com.mparticle/MPUserTest.kt | 6 +- android-kit-base/build.gradle | 6 ++ kit-plugin/build.gradle | 4 ++ .../com/mparticle/kits/KitPlugin.groovy | 7 +++ 7 files changed, 63 insertions(+), 28 deletions(-) diff --git a/.github/workflows/cross-platform-tests.yml b/.github/workflows/cross-platform-tests.yml index de5bed35d..19a5604a8 100644 --- a/.github/workflows/cross-platform-tests.yml +++ b/.github/workflows/cross-platform-tests.yml @@ -4,7 +4,7 @@ on: jobs: cross-platform-tests: timeout-minutes: 30 - runs-on: macos-latest + runs-on: macOS-12 steps: - name: "Checkout Cross Platform Tests Repo" uses: actions/checkout@v3 diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 5b9deaa4f..a7aeb3c17 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -7,15 +7,15 @@ jobs: instrumented-tests: name: "Instrumented Tests" timeout-minutes: 30 - runs-on: macos-latest + runs-on: ubuntu-latest steps: - name: "Checkout Branch" uses: actions/checkout@v3 - - name: "Install JDK 11" + - name: "Install JDK 17" uses: actions/setup-java@v3 with: distribution: "zulu" - java-version: "11" + java-version: "17" - name: Gradle cache uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a #v2.9.0 - name: AVD cache @@ -35,6 +35,11 @@ jobs: emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false script: echo "Generated AVD snapshot for caching." + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm - name: "Run Instrumented Tests" uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #v2.28.0 with: @@ -42,7 +47,11 @@ jobs: force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true - script: ./gradlew :android-core:cAT :android-kit-base:cAT --stacktrace + #script: ./gradlew :android-core:cAT :android-kit-base:cAT --stacktrace + script: | + # Disable benchmark tests as they do not work on emulators + adb uninstall com.mparticle.kits.test; ./gradlew connectedCheck --stacktrace + ./gradlew :android-core:cAT :android-kit-base:cAT -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=none - name: "Archive Instrumented Tests Results" uses: actions/upload-artifact@v3 if: always() @@ -53,25 +62,18 @@ jobs: instrumented-orchestrator-tests: name: "Instrumented Orchestrator Tests" timeout-minutes: 30 - runs-on: macos-latest + runs-on: ubuntu-latest steps: - name: "Checkout Branch" uses: actions/checkout@v3 - - name: "Install JDK 11" + - name: "Install JDK 17" uses: actions/setup-java@v3 with: distribution: "zulu" - java-version: "11" + java-version: "17" - name: Gradle cache uses: gradle/gradle-build-action@842c587ad8aa4c68eeba24c396e15af4c2e9f30a #v2.9.0 - - name: AVD cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-29 + - name: create AVD and generate snapshot for caching if: steps.avd-cache.outputs.cache-hit != 'true' uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #v2.28.0 @@ -81,6 +83,11 @@ jobs: emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: false script: echo "Generated AVD snapshot for caching." + - name: Enable KVM group perms + run: | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules + sudo udevadm control --reload-rules + sudo udevadm trigger --name-match=kvm - name: "Run Instrumented Orchestrator Tests" uses: reactivecircus/android-emulator-runner@d94c3fbe4fe6a29e4a5ba47c12fb47677c73656b #v2.28.0 with: @@ -88,7 +95,10 @@ jobs: force-avd-creation: false emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none disable-animations: true - script: ./gradlew -Porchestrator=true :android-core:cAT --stacktrace + script: | + # Disable benchmark tests as they do not work on emulators + adb uninstall com.mparticle.test; ./gradlew connectedCheck --stacktrace + ./gradlew -Porchestrator=true :android-core:cAT -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=none - name: "Archive Instrumented Orchestrator Tests Results" uses: actions/upload-artifact@v3 if: always() @@ -102,11 +112,11 @@ jobs: steps: - name: "Checkout Branch" uses: actions/checkout@v3 - - name: "Install JDK 11" + - name: "Install JDK 17" uses: actions/setup-java@v3 with: distribution: "zulu" - java-version: "11" + java-version: "17" - name: "Run Unit Tests" run: ./gradlew test - name: "Print Android Unit Tests Report" @@ -128,11 +138,11 @@ jobs: uses: actions/checkout@v3 with: submodules: recursive - - name: "Install JDK 11" + - name: "Install JDK 17" uses: actions/setup-java@v3 with: distribution: "zulu" - java-version: "11" + java-version: "17" - name: "Run Android Core SDK Lint" run: ./gradlew lint - name: "Archive Lint Test Results" @@ -151,11 +161,11 @@ jobs: uses: actions/checkout@v3 with: submodules: recursive - - name: "Install JDK 11" + - name: "Install JDK 17" uses: actions/setup-java@v3 with: distribution: "zulu" - java-version: "11" + java-version: "17" - name: "Run Android Core SDK Kotlin Lint" run: ./gradlew ktlintCheck - name: "Archive Kotlin Lint Test Results" @@ -181,11 +191,11 @@ jobs: with: submodules: recursive fetch-depth: 0 - - name: "Install JDK 11" + - name: "Install JDK 17" uses: actions/setup-java@v3 with: distribution: "zulu" - java-version: "11" + java-version: "17" - name: "Get Latest Kits" run: git submodule foreach "git rebase main" - name: "Generate Core Release Build" diff --git a/android-core/build.gradle b/android-core/build.gradle index 2cbdfb89c..e4b7d1df9 100644 --- a/android-core/build.gradle +++ b/android-core/build.gradle @@ -78,6 +78,14 @@ android { } } testOptions { + unitTests.all { + jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.util=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.text=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.math=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.util.concurrent=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.lang.ref=ALL-UNNAMED'] + } if (useOrchestrator()) { execution 'ANDROIDX_TEST_ORCHESTRATOR' reportDir buildDir.absolutePath + '/orchestrator/reports' diff --git a/android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt b/android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt index 332b5b591..dce918116 100644 --- a/android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt +++ b/android-core/src/androidTest/kotlin/com.mparticle/MPUserTest.kt @@ -28,10 +28,10 @@ class MPUserTest : BaseCleanStartedEachTest() { assertTrue { getUserAttributes().isEmpty() } setUserAttribute("foo", "bar") setUserAttribute("fooInt", 123) - setUserAttribute("fooLong", 12345L) + setUserAttribute("fooLong", 12345) setUserAttribute("fooDouble", 10.15) - setUserAttribute("fooNegInt", -10L) - setUserAttribute("fooNegLong", -1010L) + setUserAttribute("fooNegInt", -10) + setUserAttribute("fooNegLong", -1010) this.userAttributes.put("fooNull", null) android_test_hack() diff --git a/android-kit-base/build.gradle b/android-kit-base/build.gradle index 2bfc817e3..a3884c8b8 100644 --- a/android-kit-base/build.gradle +++ b/android-kit-base/build.gradle @@ -41,6 +41,12 @@ android { } } +tasks.withType(Test).configureEach { + jvmArgs('--add-opens=java.base/java.lang=ALL-UNNAMED') + jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED") + jvmArgs('--add-opens=java.base/java.util.concurrent=ALL-UNNAMED') +} + task kitSdkJavadocs(type: Javadoc) { include { String filePath = it.toString() diff --git a/kit-plugin/build.gradle b/kit-plugin/build.gradle index d8898e5f7..5d78bc289 100644 --- a/kit-plugin/build.gradle +++ b/kit-plugin/build.gradle @@ -22,6 +22,10 @@ dependencies { testImplementation 'junit:junit:4.13.2' } +tasks.withType(Test) { + jvmArgs('--add-opens=java.base/java.lang=ALL-UNNAMED') +} + task generateJavadocsJar(type: Jar, dependsOn: groovydoc) { archiveClassifier.set("javadoc") from groovydoc.destinationDir diff --git a/kit-plugin/src/main/groovy/com/mparticle/kits/KitPlugin.groovy b/kit-plugin/src/main/groovy/com/mparticle/kits/KitPlugin.groovy index 79a345a98..d8d70b06b 100644 --- a/kit-plugin/src/main/groovy/com/mparticle/kits/KitPlugin.groovy +++ b/kit-plugin/src/main/groovy/com/mparticle/kits/KitPlugin.groovy @@ -36,6 +36,13 @@ class KitPlugin implements Plugin { androidLib.buildTypes.release.minifyEnabled false androidLib.buildTypes.release.consumerProguardFiles 'consumer-proguard.pro' androidLib.lintOptions.abortOnError true + androidLib.testOptions.unitTests.all { jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.lang.reflect=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.util=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.text=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.desktop/java.awt.font=ALL-UNNAMED'] + jvmArgs += ['--add-opens', 'java.base/java.util.concurrent=ALL-UNNAMED'] } + //formerly in maven.gradle target.apply(plugin: 'maven-publish')