Skip to content

Commit 7de0998

Browse files
authored
ci: gha android (#544)
* try android * fix syntax * tweak * specify target and profile * add tests * tweak * only three * add espresso * tweak * run only mobile command * tweak a bit * remove some tests from azure * comment out for future work
1 parent 9fd8589 commit 7de0998

File tree

3 files changed

+91
-89
lines changed

3 files changed

+91
-89
lines changed

.github/workflows/functional-test.yml

+85-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Functional Tests for iOS
1+
name: Functional Tests
22

33
on:
44
# Run by manual at this time
@@ -81,7 +81,7 @@ jobs:
8181
if: ${{ always() }}
8282
uses: actions/upload-artifact@master
8383
with:
84-
name: appium-${{matrix.test_targets.name}}.log
84+
name: appium-ios-${{matrix.test_targets.name}}.log
8585
path: appium.log
8686

8787
ios_test_with_other_deps:
@@ -143,3 +143,86 @@ jobs:
143143
with:
144144
name: appium-ios_test_with_other_deps.log
145145
path: appium.log
146+
147+
android_test:
148+
runs-on: ubuntu-latest
149+
150+
strategy:
151+
fail-fast: false
152+
matrix:
153+
test_targets:
154+
- target: test/functional/android/driver_test.rb,test/functional/android/patch_test.rb,test/functional/android/android/device_test.rb,test/functional/android/android/search_context_test.rb
155+
automation_name: uiautomator2
156+
name: test1
157+
- target: test/functional/android/driver_test.rb,test/functional/android/patch_test.rb,test/functional/android/android/device_test.rb,test/functional/android/android/search_context_test.rb
158+
automation_name: espresso
159+
name: test2
160+
- target: test/functional/android/webdriver/create_session_test.rb,test/functional/android/webdriver/device_test.rb,test/functional/android/webdriver/w3c_actions_test.rb
161+
automation_name: uiautomator2
162+
name: test3
163+
- target: test/functional/android/webdriver/create_session_test.rb,test/functional/android/webdriver/device_test.rb,test/functional/android/webdriver/w3c_actions_test.rb
164+
automation_name: espresso
165+
name: test4
166+
167+
# Some may not work well on GHA. Haven't fully fixed.
168+
# test/functional/android/android/mjpeg_server_test.rb
169+
# test/functional/android/android/image_comparison_test.rb
170+
# - target: test/functional/android/android/device_data_test.rb,test/functional/android/android/mobile_commands_test.rb
171+
# automation_name: uiautomator2
172+
# name: test5
173+
# - target: test/functional/android/android/device_data_test.rb,test/functional/android/android/mobile_commands_test.rb
174+
# automation_name: espresso
175+
# name: test6
176+
177+
steps:
178+
- uses: actions/checkout@v3
179+
180+
- name: Install Node.js
181+
uses: actions/setup-node@v3
182+
with:
183+
node-version: 'lts/*'
184+
185+
# Start Appium
186+
- run: npm install -g appium
187+
- run: |
188+
appium driver install ${{matrix.test_targets.automation_name}}
189+
appium plugin install images
190+
appium plugin install execute-driver
191+
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors --base-path=/wd/hub > appium.log &
192+
193+
- name: Enable KVM group perms
194+
run: |
195+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
196+
sudo udevadm control --reload-rules
197+
sudo udevadm trigger --name-match=kvm
198+
199+
- name: Set up Ruby
200+
uses: ruby/setup-ruby@v1
201+
with:
202+
ruby-version: 3.2
203+
- name: Install dependencies
204+
run: bundle install
205+
206+
# Run tests
207+
208+
- name: run tests
209+
uses: reactivecircus/android-emulator-runner@v2
210+
with:
211+
api-level: 29
212+
script: |
213+
bundle exec rake test:func:android TESTS=${{matrix.test_targets.target}}
214+
target: google_apis
215+
profile: Nexus 5X
216+
217+
env:
218+
ANDROID_SDK_VERSION: 29
219+
APPIUM_DRIVER: ${{matrix.test_targets.automation_name}}
220+
IGNORE_VERSION_SKIP: true
221+
CI: true
222+
223+
- name: Save server output
224+
if: ${{ always() }}
225+
uses: actions/upload-artifact@master
226+
with:
227+
name: appium-android-${{matrix.test_targets.automation_name}}-${{matrix.test_targets.name}}.log
228+
path: appium.log

ci-jobs/functional_test.yml

+1-85
Original file line numberDiff line numberDiff line change
@@ -8,90 +8,6 @@ parameters:
88
CI: true
99

1010
jobs:
11-
- job: func_test_android_base
12-
pool:
13-
vmImage: ${{ parameters.vmImage }}
14-
variables:
15-
CI: ${{ parameters.ci }}
16-
ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
17-
IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
18-
APPIUM_VERSION: ${{ parameters.appiumVersion }}
19-
strategy:
20-
matrix:
21-
uiautomator2:
22-
APPIUM_DRIVER: uiautomator2
23-
espresso:
24-
APPIUM_DRIVER: espresso
25-
steps:
26-
- template: ./functional/android_setup.yml
27-
- template: ./functional/run_appium.yml
28-
- script: bundle exec rake test:func:android TESTS=test/functional/android/driver_test.rb,test/functional/android/patch_test.rb
29-
displayName: Run tests func_test_android_base
30-
- template: ./functional/publish_test_result.yml
31-
32-
- job: func_test_android_webdriver
33-
pool:
34-
vmImage: ${{ parameters.vmImage }}
35-
variables:
36-
CI: ${{ parameters.ci }}
37-
ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
38-
IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
39-
APPIUM_VERSION: ${{ parameters.appiumVersion }}
40-
strategy:
41-
matrix:
42-
uiautomator2:
43-
APPIUM_DRIVER: uiautomator2
44-
espresso:
45-
APPIUM_DRIVER: espresso
46-
steps:
47-
- template: ./functional/android_setup.yml
48-
- template: ./functional/run_appium.yml
49-
- script: bundle exec rake test:func:android TESTS=test/functional/android/webdriver/create_session_test.rb,test/functional/android/webdriver/device_test.rb,test/functional/android/webdriver/w3c_actions_test.rb
50-
displayName: Run tests func_test_android_webdriver
51-
- template: ./functional/publish_test_result.yml
52-
53-
- job: func_test_android_android1
54-
pool:
55-
vmImage: ${{ parameters.vmImage }}
56-
variables:
57-
CI: ${{ parameters.ci }}
58-
ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
59-
IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
60-
APPIUM_VERSION: ${{ parameters.appiumVersion }}
61-
strategy:
62-
matrix:
63-
uiautomator2:
64-
APPIUM_DRIVER: uiautomator2
65-
espresso:
66-
APPIUM_DRIVER: espresso
67-
steps:
68-
- template: ./functional/android_setup.yml
69-
- template: ./functional/run_appium.yml
70-
- script: bundle exec rake test:func:android TESTS=test/functional/android/android/device_test.rb
71-
displayName: Run tests func_test_android_android1
72-
- template: ./functional/publish_test_result.yml
73-
74-
- job: func_test_android_android2
75-
pool:
76-
vmImage: ${{ parameters.vmImage }}
77-
variables:
78-
CI: ${{ parameters.ci }}
79-
ANDROID_SDK_VERSION: ${{ parameters.androidSDK }}
80-
IGNORE_VERSION_SKIP: ${{ parameters.ignoreVersionSkip }}
81-
APPIUM_VERSION: ${{ parameters.appiumVersion }}
82-
strategy:
83-
matrix:
84-
uiautomator2:
85-
APPIUM_DRIVER: uiautomator2
86-
espresso:
87-
APPIUM_DRIVER: espresso
88-
steps:
89-
- template: ./functional/android_setup.yml
90-
- template: ./functional/run_appium.yml
91-
- script: bundle exec rake test:func:android TESTS=test/functional/android/android/search_context_test.rb,test/functional/android/android/mjpeg_server_test.rb
92-
displayName: Run tests func_test_android_android2
93-
- template: ./functional/publish_test_result.yml
94-
9511
- job: func_test_android_android3
9612
pool:
9713
vmImage: ${{ parameters.vmImage }}
@@ -151,6 +67,6 @@ jobs:
15167
steps:
15268
- template: ./functional/android_setup.yml
15369
- template: ./functional/run_appium.yml
154-
- script: bundle exec rake test:func:android TESTS=test/functional/android/android/image_comparison_test.rb
70+
- script: bundle exec rake test:func:android TESTS=test/functional/android/android/image_comparison_test.rb,test/functional/android/android/mjpeg_server_test.rb
15571
displayName: Run tests func_test_android_opencv
15672
- template: ./functional/publish_test_result.yml

test/functional/android/android/device_test.rb

+5-2
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,11 @@ def test_context_related
102102

103103
native_page = @driver.page_source
104104

105-
contexts = @driver.available_contexts
106-
webview_context = contexts.detect { |e| e.start_with?('WEBVIEW') }
105+
webview_context = @@core.wait do
106+
context = @driver.available_contexts.detect { |c| c.start_with?('WEBVIEW') }
107+
assert context
108+
context
109+
end
107110

108111
@driver.set_context webview_context
109112
@driver.wait { |d| assert d.current_context.start_with? 'WEBVIEW' }

0 commit comments

Comments
 (0)