diff --git a/.github/workflows/ui-tests-check.yml b/.github/workflows/ui-tests-check.yml new file mode 100644 index 0000000..bde17f2 --- /dev/null +++ b/.github/workflows/ui-tests-check.yml @@ -0,0 +1,89 @@ +name: ui-tests-check +run-name: ${{ github.actor }} is running the UI tests check for PR ${{ github.event.number }} +on: + pull_request: + branches: + - main +jobs: +# run-android-ui-tests: +# runs-on: ubuntu-latest +# strategy: +# api-level: [29, 30, 31] +# steps: +# - uses: actions/checkout@v3 +# +# - name: Set up JDK 17 +# uses: actions/setup-java@v3 +# with: +# java-version: 17 +# distribution: 'adopt' +# +# - name: Gradle cache +# uses: gradle/gradle-build-action@v2 +# +# - name: AVD cache +# uses: actions/cache@v3 +# id: avd-cache +# with: +# path: | +# ~/.android/avd/* +# ~/.android/adb* +# key: avd-${{ matrix.api-level }} +# +# - name: Run Android Emulator and execute tests +# uses: reactivecircus/android-emulator-runner@v2 +# with: +# api-level: ${{ matrix.api-level }} +# target: google_apis +# force-avd-creation: false +# emulator-options: -no-window -gpu swiftshader_indirect -no-snapshot-save -noaudio -no-boot-anim -camera-back none +# disable-animations: true +# arch: x86_64 +# disk-size: 3G +# ram-size: 3G +# heap-size: 1500M +# profile: 3.4in WQVGA +# channel: canary +# cores: 6 +# script: +# ./gradlew :android:connectedCheck + + run-iOS-ui-tests: + env: + WORKING_DIRECTORY: ./ios + runs-on: macos-13 + steps: + - uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'adopt' + + - name: Install sourcery + run: brew install sourcery + + - name: Configure sourcery + working-directory: ${{env.WORKING_DIRECTORY}} + run: sourcery --config kaluga.sourcery.yml + + - name: Run podImport + run: ./gradlew :cucumber:podImport + + - name: Run pod install + working-directory: ${{env.WORKING_DIRECTORY}} + run: pod install + + - name: Run iOS UI tests + working-directory: ${{env.WORKING_DIRECTORY}} + run: xcodebuild -workspace ios.xcworkspace -scheme ios -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14,OS=16.2' -resultBundlePath TestResults test + + - name: Upload test result artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: dist-without-markdown + path: ./**/TestResults* diff --git a/cucumber/build.gradle.kts b/cucumber/build.gradle.kts index 86a3cf8..7ba7c09 100644 --- a/cucumber/build.gradle.kts +++ b/cucumber/build.gradle.kts @@ -1,4 +1,6 @@ + import org.jetbrains.kotlin.gradle.targets.native.tasks.PodGenTask +import org.jetbrains.kotlin.gradle.tasks.DefFileTask plugins { kotlin("multiplatform") @@ -14,6 +16,7 @@ kotlin { } } } + iosX64() iosArm64() iosSimulatorArm64() @@ -78,6 +81,22 @@ android { } } +tasks.named("generateDefCucumberish").configure { + doLast { + println("DefFileTask named: $name") + val file = project.buildDir.resolve("cocoapods/defs/Cucumberish.def") + val writer = file.bufferedWriter() + writer.use { + it.write(""" + language = Objective-C + modules = Cucumberish + linkerOpts = -framework Cucumberish + foreignExceptionMode = objc-wrap + """.trimIndent()) + } + } +} + /** * Custom gradle task since Cucumberish library targets iOS 8. User running on the latest macOS version will have errors when syncing since iOS 8 won't be a valid target anymore. * This script will override the target version to the given string. diff --git a/cucumber/src/iosMain/kotlin/com/corrado4eyes/cucumber/DefaultGherkinRunner.kt b/cucumber/src/iosMain/kotlin/com/corrado4eyes/cucumber/DefaultGherkinRunner.kt index 50eab50..7dcaabb 100644 --- a/cucumber/src/iosMain/kotlin/com/corrado4eyes/cucumber/DefaultGherkinRunner.kt +++ b/cucumber/src/iosMain/kotlin/com/corrado4eyes/cucumber/DefaultGherkinRunner.kt @@ -4,6 +4,7 @@ import cocoapods.Cucumberish.CCIStepBody import cocoapods.Cucumberish.Given import cocoapods.Cucumberish.Then import cocoapods.Cucumberish.When +import kotlinx.cinterop.ForeignException actual val EXPECT_VALUE_STRING = "\\\"(.*)\\\"" @@ -31,16 +32,31 @@ actual fun given(regex: String, lambda: GherkinLambda2) { Given(regex, lambda) } +@Throws(ForeignException::class) actual fun then(regex: String, lambda: GherkinLambda0) { - Then(regex, lambda) + try { + Then(regex, lambda) + } catch(e: ForeignException) { + println("Exception is $e") + } } +@Throws(ForeignException::class) actual fun then(regex: String, lambda: GherkinLambda1) { - Then(regex, lambda) + try { + Then(regex, lambda) + } catch(e: ForeignException) { + println("Exception is $e") + } } +@Throws(ForeignException::class) actual fun then(regex: String, lambda: GherkinLambda2) { - Then(regex, lambda) + try { + Then(regex, lambda) + } catch(e: ForeignException) { + println("Exception is $e") + } } actual fun `when`(regex: String, lambda: GherkinLambda0) { diff --git a/dependencies/kaluga-swiftui b/dependencies/kaluga-swiftui index 260db7b..b2c6a94 160000 --- a/dependencies/kaluga-swiftui +++ b/dependencies/kaluga-swiftui @@ -1 +1 @@ -Subproject commit 260db7bd1ec2552d407433d4ebd3ec1ab27cadb1 +Subproject commit b2c6a941f15fc8b183d4322def71a9816169d07d diff --git a/ios/CucumberTests/Features/Login.feature b/ios/CucumberTests/Features/Login.feature index ec36c05..7d4a025 100644 --- a/ios/CucumberTests/Features/Login.feature +++ b/ios/CucumberTests/Features/Login.feature @@ -8,4 +8,4 @@ Feature: Login Then I see the "Login" button Then I press the login button Then I see the "Home" screen - Then I see "test@test.com" text + Then I see "test@test.com1" text diff --git a/ios/CucumberTests/TestPlan.xctestplan b/ios/CucumberTests/TestPlan.xctestplan index 42ab4c5..5796d04 100644 --- a/ios/CucumberTests/TestPlan.xctestplan +++ b/ios/CucumberTests/TestPlan.xctestplan @@ -1,12 +1,6 @@ { "configurations" : [ - { - "id" : "437917A8-B65A-45A5-8D34-B8C13877CC13", - "name" : "Configuration 1", - "options" : { - } - } ], "defaultOptions" : { "repeatInNewRunnerProcess" : true, diff --git a/ios/Podfile b/ios/Podfile index 07525ae..73c2201 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -3,3 +3,11 @@ target 'CucumberTests' do platform :ios, '14.1' pod 'Cucumberish' end + +post_install do |installer| + installer.pods_project.targets.each do |target| + target.build_configurations.each do |config| + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = Gem::Version.new('9.0') + end + end +end \ No newline at end of file diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts index 616c0f0..8aefc73 100644 --- a/shared/build.gradle.kts +++ b/shared/build.gradle.kts @@ -16,6 +16,7 @@ kotlin { val target: org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.() -> Unit = { binaries { framework { + transitiveExport = true baseName = "shared" export("com.splendo.kaluga:alerts:$kalugaVersion")