Skip to content

Commit

Permalink
ci: run an example code on CI as a quick functionality check (#720)
Browse files Browse the repository at this point in the history
* chore: update ruby code

* chore: remove userland

* ci: add fail fast fail

* add a func yml

* add android

* tune for andorid

* tune command name

* add ?
  • Loading branch information
KazuCocoa authored Jul 23, 2024
1 parent 0130dd0 commit 73b497e
Show file tree
Hide file tree
Showing 13 changed files with 189 additions and 23 deletions.
156 changes: 156 additions & 0 deletions .github/workflows/driver-function.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: Run quick functionality check

on:
workflow_dispatch:
push:
paths:
- 'driver/**'
branches: [ main ]
pull_request:
paths:
- 'driver/**'
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
ios_test:
runs-on: macos-14

env:
XCODE_VERSION: 15.3
IOS_DEVICE_NAME: iPhone 15 Plus
IOS_VERSION: 17.4

steps:
- uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'

- name: Select Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ env.XCODE_VERSION }}
- run: defaults write com.apple.iphonesimulator PasteboardAutomaticSync -bool false

- uses: futureware-tech/simulator-action@v3
with:
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
model: ${{ env.IOS_DEVICE_NAME }}
os_version: ${{ env.IOS_VERSION }}

# Start Appium
- run: npm install -g appium
- run: |
npm install
nohup appium --log-timestamp --log-no-colors > appium.log &
working-directory:
driver
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install dependencies
run: bundle install
working-directory: example/ruby
- name: Run tests
run: ruby example_sample2_ios.rb
working-directory: example/ruby

- name: Save server output
if: ${{ always() }}
uses: actions/upload-artifact@master
with:
name: appium-ios.log
path: driver/appium.log

android_test:
runs-on: ubuntu-latest

env:
API_LEVEL: 34
ARCH: x86_64

steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 'lts/*'

# Start Appium
- run: npm install -g appium
- run: |
npm install
nohup appium --log-timestamp --log-no-colors > appium.log &
working-directory:
driver
- 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: AVD cache
uses: actions/cache@v3
id: avd-cache
with:
path: |
~/.android/avd/*
~/.android/adb*
key: avd-${{ env.API_LEVEL }}
- name: create AVD and generate snapshot for caching
if: steps.avd-cache.outputs.cache-hit != 'true'
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API_LEVEL }}
arch: ${{ env.ARCH }}
target: google_apis
force-avd-creation: false
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: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
- name: Install dependencies
run: bundle install
working-directory: example/ruby

- name: Run tests
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: ${{ env.API_LEVEL }}
arch: ${{ env.ARCH }}
script: ruby example/ruby/example_sample2.rb
target: google_apis
profile: Nexus 5X
disable-spellchecker: true
disable-animations: true
env:
ANDROID_SDK_VERSION: ${{ env.API_LEVEL }}
APPIUM_DRIVER: ${{matrix.test_targets.automation_name}}
IGNORE_VERSION_SKIP: true
CI: true

- name: Save server output
if: ${{ always() }}
uses: actions/upload-artifact@master
with:
name: appium-android.log
path: driver/appium.log
1 change: 1 addition & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: ${{ fromJSON(needs.prepare_matrix.outputs.versions) }}
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
Expand Down
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ SKIP_IOS=1 appium driver doctor flutter
| Capability | Description | Example Values |
| - | - | -|
| appium:retryBackoffTime | The time wait for socket connection retry to get flutter session (default 3000ms)|500|
| appium:maxRetryCount | The count for socket connection retry for get flutter session (default 10) | 20|
| appium:observatoryWsUri | The URL to attach to the Dart VM. The Appium Flutter Driver finds the WebSocket URL from the device log by default. You can skip the finding the URL process by specifying this capability. Then, this driver attempt to establish a WebSocket connection against the given WebSocket URL. Note that this capability expects the URL is ready for access by outside an appium session. This flutter driver does not do port-forwarding with this capability. You may need to coordinate the port-forwarding as well. | 'ws://127.0.0.1:60992/aaaaaaaaaaa=/ws' |
| appium:isolateId | The isolate id to attach to as the initial attempt. A session can change the isolate with `flutter:setIsolateId` command. The default behavior finds `main` isolate id and attaches it. | `isolates/2978358234363215`, `2978358234363215` |
| appium:skipPortForward | Whether skip port forwarding from the flutter driver local to the device under test with `observatoryWsUri` capability. It helps you to manage the application under test, the observatory URL and the port forwarding configuration. The default is `true`. | true, false |
Expand Down Expand Up @@ -205,7 +203,6 @@ You have a couple of methods to start the application under test by establishing
1. Start a session without `app` capability
2. Install the application under test via `driver.install_app` or `mobile:installApp` command etc
3. Calls `flutter:connectObservatoryWsUrl` command to keep finding an observatory URL to the Dart VM
- `appium:retryBackoffTime` and `appium:maxRetryCount` will control the duration to keep finding an observatory URL to the Dart VM
4. (at the same time) Launch the application under test via outside the appium-flutter-driver
- e.g. Launch an iOS process via [ios-go](https://github.com/danielpaulus/go-ios), [iproxy](https://github.com/libimobiledevice/libusbmuxd#iproxy) or [tidevice](https://github.com/alibaba/taobao-iphone-device)
5. Once `flutter:connectObservatoryWsUrl` identify the observatory URL, the command will establish a connection to the Dart VM
Expand Down
4 changes: 4 additions & 0 deletions driver/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## not released
- Tune syslog scanning
- Drop `appium:maxRetryCount` and `appium:retryBackoffTime`

## 2.8.0
- Support `getWidgetDiagnostics`

Expand Down
6 changes: 0 additions & 6 deletions driver/lib/desired-caps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ export const desiredCapConstraints = {
avd: {
isString: true,
},
maxRetryCount: {
isNumber: true,
},
platformName: {
inclusionCaseInsensitive: [
'iOS',
Expand All @@ -16,9 +13,6 @@ export const desiredCapConstraints = {
isString: true,
presence: true,
},
retryBackoffTime: {
isNumber: true,
},
udid: {
isString: true,
},
Expand Down
2 changes: 1 addition & 1 deletion driver/lib/driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class FlutterDriver extends BaseDriver<FluttertDriverConstraints> {
break;
case PLATFORM.ANDROID:
if (this.portForwardLocalPort) {
await this.proxydriver.adb.removePortForward(this.portForwardLocalPort);
await this.proxydriver?.adb?.removePortForward(this.portForwardLocalPort);
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion driver/lib/sessions/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function getObservatoryWsUri (
throw new Error(
`No observatory URL matching to '${OBSERVATORY_URL_PATTERN}' was found in the device log. ` +
`Please make sure the application under test is configured properly according to ` +
`https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup.`
`https://github.com/appium/appium-flutter-driver#usage and that it does not crash on startup.`
);
}
urlObject = extractObservatoryUrl(this._logmon.lastMatch) as URL;
Expand Down
2 changes: 1 addition & 1 deletion driver/lib/sessions/ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export async function getObservatoryWsUri (
throw new Error(
`No observatory URL matching to '${OBSERVATORY_URL_PATTERN}' was found in the device log. ` +
`Please make sure the application under test is configured properly according to ` +
`https://github.com/appium-userland/appium-flutter-driver#usage and that it does not crash on startup.`
`https://github.com/appium/appium-flutter-driver#usage and that it does not crash on startup.`
);
}
urlObject = extractObservatoryUrl(this._logmon.lastMatch) as URL;
Expand Down
2 changes: 1 addition & 1 deletion driver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/appium-userland/appium-flutter-driver.git"
"url": "git+https://github.com/appium/appium-flutter-driver.git"
},
"engines": {
"node": ">=14",
Expand Down
4 changes: 2 additions & 2 deletions example/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
1. Make sure node and npm are installed locally
2. cd to ./driver
3. `npm install -g typescript` for typescript compile to work globally
4. `npm install` to install node modules
4. `npm install` to install node modules
5. run `npm link`
6. install Appium globally by running `npm i -g appium`
7. run appium server by running `appium` (in a seperate terminal)
Expand All @@ -12,6 +12,6 @@
- (Android) https://github.com/truongsinh/appium-flutter-driver/releases/download/v0.0.4/android-real-debug.apk
- (iOS) https://github.com/truongsinh/appium-flutter-driver/releases/download/v0.0.4/ios-sim-debug.zip

9. Modify the path for apk/ipa appropriately at https://github.com/appium-userland/appium-flutter-driver/blob/main/example/nodejs/src/index.js#L13
9. Modify the path for apk/ipa appropriately at https://github.com/appium/appium-flutter-driver/blob/main/example/nodejs/src/index.js#L13

10. either run `APPIUM_OS=android npm start` or `APPIUM_OS=ios npm start`
10 changes: 8 additions & 2 deletions example/ruby/example_sample2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ExampleTests < Minitest::Test
automationName: 'flutter',
udid: 'emulator-5554',
deviceName: 'Android',
app: "#{Dir.pwd}/../sample2/app-debug.apk"
app: "#{Dir.pwd}/example/sample2/app-debug.apk"
},
appium_lib: {
export_session: true,
Expand All @@ -21,10 +21,16 @@ class ExampleTests < Minitest::Test
}
}

def test_run_example_android
def setup
@core = ::Appium::Core.for(CAPS)
@driver = @core.start_driver server_url: 'http://localhost:4723'
end

def teardown
@driver&.quit
end

def test_run_example_android
@driver.context = 'NATIVE_APP'

element = @driver.find_element :id, 'dev.flutter.example.androidfullscreen:id/launch_button'
Expand Down
18 changes: 13 additions & 5 deletions example/ruby/example_sample2_ios.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ class ExampleTests < Minitest::Test
caps: {
platformName: 'iOS',
automationName: 'flutter',
platformVersion: '15.5',
deviceName: 'iPhone 13',
app: "#{Dir.pwd}/../sample2/iOSFullScreen.zip"
platformVersion: '17.4',
deviceName: 'iPhone 15 Plus',
app: "#{Dir.pwd}/../sample2/iOSFullScreen.zip",
showIOSLog: true,
wdaLaunchTimeout: 600_000
},
appium_lib: {
export_session: true,
Expand All @@ -21,10 +23,16 @@ class ExampleTests < Minitest::Test
}
}

def test_run_example_ios
def setup
@core = ::Appium::Core.for(CAPS)
@driver = @core.start_driver
@driver = @core.start_driver server_url: 'http://localhost:4723'
end

def teardown
@driver&.quit
end

def test_run_example_ios
@driver.context = 'NATIVE_APP'

element = @driver.find_element :accessibility_id, 'launchFlutter'
Expand Down
2 changes: 1 addition & 1 deletion finder/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
],
author='Kazuaki Matsuo',
author_email='[email protected]',
url='https://github.com/appium-userland/appium-flutter-driver',
url='https://github.com/appium/appium-flutter-driver',
packages=find_packages(include=['appium_flutter_finder*']),
license='MIT',
classifiers=[
Expand Down

0 comments on commit 73b497e

Please sign in to comment.