Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github actions for UI tests #21

Open
wants to merge 33 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
124a3d0
Add yml for UI tests
corrado4eyes Jun 30, 2023
7d92fb0
Fix env variable usage
corrado4eyes Jun 30, 2023
615a45a
Use java 17
corrado4eyes Jun 30, 2023
b7f5a74
Correct usage of env variable
corrado4eyes Jun 30, 2023
fae598d
Wrap variable inside string
corrado4eyes Jun 30, 2023
da79ec8
Add common steps
corrado4eyes Jun 30, 2023
b502a9c
Remove common steps
corrado4eyes Jun 30, 2023
1903434
Remove `needs`
corrado4eyes Jun 30, 2023
5b3e97e
Inline ios script
corrado4eyes Jun 30, 2023
1045afe
Add android emulator runner
corrado4eyes Jun 30, 2023
bbb5aa3
Change iOS device
corrado4eyes Jun 30, 2023
1aa8c21
Add android api level
corrado4eyes Jun 30, 2023
391e9e7
Update emulator step
corrado4eyes Jun 30, 2023
0c66687
Add `matrix` for api-level
corrado4eyes Jun 30, 2023
0fe3653
Compile modules
corrado4eyes Jun 30, 2023
491531f
Add cocoapods-action step
corrado4eyes Jun 30, 2023
080554f
Add steps to configure and build ios project
corrado4eyes Jun 30, 2023
20a94f1
Add transitiveExport flag
corrado4eyes Jun 30, 2023
4140935
Change submodule HEAD
corrado4eyes Jun 30, 2023
58e34da
Forcing deployment target
corrado4eyes Jun 30, 2023
2031b4a
Trigger CI
corrado4eyes Jun 30, 2023
4c987f9
Add podImport task before running pod install and tests
corrado4eyes Jun 30, 2023
31c7693
Add prettifier
corrado4eyes Jul 1, 2023
81684b8
Remove ununsed configuration
corrado4eyes Jul 1, 2023
9f1bd9a
Remove prettiefier
corrado4eyes Jul 1, 2023
e45c3ac
Add task to upload test result artifacts
corrado4eyes Jul 1, 2023
f40a109
Add `always` policy to run step even if previous step failed
corrado4eyes Jul 1, 2023
94463b4
Fix path
corrado4eyes Jul 1, 2023
5274ef8
Update artefacts folder
corrado4eyes Jul 3, 2023
86a41e7
Add gradle task to update .def file
corrado4eyes Sep 8, 2023
328d6f7
Add Throws annotation to the wrappers
corrado4eyes Sep 8, 2023
4686084
Update feature file so that tests fails
corrado4eyes Sep 8, 2023
741ea66
Add try/catch to wrapper methods
corrado4eyes Sep 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/ui-tests-check.yml
Original file line number Diff line number Diff line change
@@ -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*
19 changes: 19 additions & 0 deletions cucumber/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

import org.jetbrains.kotlin.gradle.targets.native.tasks.PodGenTask
import org.jetbrains.kotlin.gradle.tasks.DefFileTask

plugins {
kotlin("multiplatform")
Expand All @@ -14,6 +16,7 @@ kotlin {
}
}
}

iosX64()
iosArm64()
iosSimulatorArm64()
Expand Down Expand Up @@ -78,6 +81,22 @@ android {
}
}

tasks.named<DefFileTask>("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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "\\\"(.*)\\\""

Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion dependencies/kaluga-swiftui
2 changes: 1 addition & 1 deletion ios/CucumberTests/Features/Login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 0 additions & 6 deletions ios/CucumberTests/TestPlan.xctestplan
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{
"configurations" : [
{
"id" : "437917A8-B65A-45A5-8D34-B8C13877CC13",
"name" : "Configuration 1",
"options" : {

}
}
],
"defaultOptions" : {
"repeatInNewRunnerProcess" : true,
Expand Down
8 changes: 8 additions & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading