Skip to content

Commit b148174

Browse files
authored
ci: move Azure to GHA (Android) (appium#1007)
* ci: move Azure to GHA (Android)
1 parent e34ca80 commit b148174

6 files changed

Lines changed: 120 additions & 18 deletions

File tree

.github/workflows/functional-test.yml

Lines changed: 108 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ jobs:
2727

2828
runs-on: macos-14
2929

30+
# Please make sure the available Xcode versions and iOS versions
31+
# on the runner images. https://github.com/actions/runner-images
32+
env:
33+
XCODE_VERSION: 15.3
34+
IOS_VERSION: 17.4
35+
IPHONE_MODEL: iPhone 15 Plus
36+
3037
steps:
3138
- uses: actions/checkout@v3
3239

@@ -38,14 +45,14 @@ jobs:
3845
- name: Select Xcode
3946
uses: maxim-lobanov/setup-xcode@v1
4047
with:
41-
xcode-version: 15.3
48+
xcode-version: ${{ env.XCODE_VERSION }}
4249
- run: defaults write com.apple.iphonesimulator PasteboardAutomaticSync -bool false
4350

4451
- uses: futureware-tech/simulator-action@v3
4552
with:
4653
# https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md
47-
model: 'iPhone 15 Plus'
48-
os_version: '17.4'
54+
model: ${{ env.IPHONE_MODEL }}
55+
os_version: ${{ env.IOS_VERSION }}
4956

5057
# needed?
5158
- run: brew install ffmpeg
@@ -77,3 +84,101 @@ jobs:
7784
with:
7885
name: appium-ios-${{matrix.test_targets.name}}.log
7986
path: appium.log
87+
88+
89+
android_test:
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
test_targets:
94+
- target: test/functional/android/device_time_tests.py test/functional/android/search_context/find_by_*.py
95+
name: func_test_android1
96+
97+
runs-on: ubuntu-latest
98+
99+
env:
100+
API_LEVEL: 29
101+
ARCH: x86
102+
103+
steps:
104+
- uses: actions/checkout@v3
105+
106+
- uses: actions/setup-java@v3
107+
with:
108+
distribution: 'temurin'
109+
java-version: '17'
110+
111+
- name: Install Node.js
112+
uses: actions/setup-node@v3
113+
with:
114+
node-version: 'lts/*'
115+
116+
# Start Appium
117+
- run: npm install -g appium
118+
- run: |
119+
appium driver install uiautomator2
120+
appium driver install espresso
121+
appium plugin install images
122+
appium plugin install execute-driver
123+
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors 2>&1 > appium.log &
124+
125+
- name: Enable KVM group perms
126+
run: |
127+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
128+
sudo udevadm control --reload-rules
129+
sudo udevadm trigger --name-match=kvm
130+
131+
- name: AVD cache
132+
uses: actions/cache@v3
133+
id: avd-cache
134+
with:
135+
path: |
136+
~/.android/avd/*
137+
~/.android/adb*
138+
key: avd-${{ env.API_LEVEL }}
139+
- name: create AVD and generate snapshot for caching
140+
if: steps.avd-cache.outputs.cache-hit != 'true'
141+
uses: reactivecircus/android-emulator-runner@v2
142+
with:
143+
api-level: ${{ env.API_LEVEL }}
144+
arch: ${{ env.ARCH }}
145+
target: google_apis
146+
force-avd-creation: false
147+
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
148+
disable-animations: false
149+
script: echo "Generated AVD snapshot for caching."
150+
151+
- name: Set up Python 3.9
152+
uses: actions/setup-python@v3
153+
with:
154+
python-version: 3.9
155+
156+
- name: run tests
157+
uses: reactivecircus/android-emulator-runner@v2
158+
with:
159+
api-level: ${{ env.API_LEVEL }}
160+
arch: ${{ env.ARCH }}
161+
script: |
162+
# Separate 'run' creates differnet pipenv env. Does them in one run for now.
163+
pip install --upgrade pip
164+
pip install --upgrade pipenv
165+
pipenv lock --clear
166+
pipenv install -d --system
167+
pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
168+
target: google_apis
169+
profile: Nexus 5X
170+
disable-spellchecker: true
171+
disable-animations: true
172+
173+
env:
174+
ANDROID_SDK_VERSION: ${{ env.API_LEVEL }}
175+
APPIUM_DRIVER: ${{matrix.test_targets.automation_name}}
176+
IGNORE_VERSION_SKIP: true
177+
CI: true
178+
179+
- name: Save server output
180+
if: ${{ always() }}
181+
uses: actions/upload-artifact@master
182+
with:
183+
name: appium-android-${{matrix.test_targets.name}}.log
184+
path: appium.log

azure-pipelines.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@
44
# https://docs.microsoft.com/azure/devops/pipelines/languages/xcode
55
jobs:
66
- template: ./ci-jobs/functional_test.yml
7-

ci-jobs/functional_test.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ parameters:
66
CI: true
77

88
jobs:
9-
- template: ./functional/run_android_test.yml
10-
parameters:
11-
name: 'func_test_android1'
12-
vmImage: ${{ parameters.vmImage }}
13-
pytestOpt: ${{ parameters.pytestOpt }}
14-
testFiles: 'device_time_tests.py search_context/find_by_*.py'
15-
sdkVer: ${{ parameters.androidSdkVer }}
16-
CI: ${{ parameters.ci }}
179
- template: ./functional/run_android_test.yml
1810
parameters:
1911
name: 'func_test_android2'
-2.59 KB
Loading

test/functional/android/search_context/find_by_image_tests.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ def setup_method(self) -> None:
3232

3333
# relax template matching
3434
self.driver.update_settings(
35-
{'fixImageFindScreenshotDims': False, 'fixImageTemplateSize': True, 'autoUpdateImageElementPosition': True}
35+
{
36+
'fixImageFindScreenshotDims': False,
37+
'fixImageTemplateSize': True,
38+
'autoUpdateImageElementPosition': True,
39+
'fixImageTemplateScale': True,
40+
'imageMatchThreshold': 0.8,
41+
}
3642
)
3743

3844
def teardown_method(self) -> None:

test/functional/android/search_context/find_by_view_matcher_tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ def test_find_single_element_using_hamcrest_matcher(self) -> None:
6565
# androidx.test.espresso.AmbiguousViewMatcherException:
6666
# 'with text: a string containing "Access"' matches multiple views in the hierarchy.
6767
def test_find_multiple_elements(self) -> None:
68-
with pytest.raises(WebDriverException):
69-
self.driver.find_elements(
70-
by=AppiumBy.ANDROID_VIEW_MATCHER,
71-
value=json.dumps({'name': 'withSubstring', 'args': ['Access'], 'class': 'ViewMatchers'}),
72-
)
68+
el = self.driver.find_element(
69+
by=AppiumBy.ANDROID_VIEW_MATCHER,
70+
value=json.dumps({'name': 'withSubstring', 'args': ['Access'], 'class': 'ViewMatchers'}),
71+
)
72+
assert el.text == "Access'ibility"

0 commit comments

Comments
 (0)