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

ci: use gha instead of Azure for iOS in Azure #987

Merged
merged 37 commits into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
05ba618
initial commit for gha
KazuCocoa May 2, 2024
89ab442
use working-directory
KazuCocoa May 2, 2024
f0426d5
Merge branch 'master' into gha
KazuCocoa May 2, 2024
3fe8cca
Merge branch 'master' into gha
KazuCocoa May 2, 2024
557b1ef
add matrix.
KazuCocoa May 2, 2024
7ad866c
tweak
KazuCocoa May 4, 2024
3af6f3e
add pytest
KazuCocoa May 4, 2024
5015b67
add pipenv
KazuCocoa May 4, 2024
20e70ba
add pipenv
KazuCocoa May 4, 2024
9248492
tweak
KazuCocoa May 4, 2024
02f7897
tweak order
KazuCocoa May 4, 2024
c109943
remove python -m
KazuCocoa May 4, 2024
551cb27
run pip list
KazuCocoa May 4, 2024
3b8c500
add pipenv run
KazuCocoa May 4, 2024
f33c9da
tweak the order
KazuCocoa May 4, 2024
c9f6af5
tweak
KazuCocoa May 4, 2024
f920237
tweak
KazuCocoa May 4, 2024
e9c1800
tweak
KazuCocoa May 4, 2024
2f529ef
tweak
KazuCocoa May 4, 2024
d05a8bf
tweak
KazuCocoa May 4, 2024
54c103d
tweak
KazuCocoa May 4, 2024
78dc25d
tweak
KazuCocoa May 4, 2024
5b5d385
tweak
KazuCocoa May 4, 2024
abf5efd
tweak
KazuCocoa May 4, 2024
26347b2
add ffmpeg
KazuCocoa May 4, 2024
4746315
tweak test code
KazuCocoa May 4, 2024
324ee5a
tweak test code
KazuCocoa May 4, 2024
2326f52
Update functional-test.yml
KazuCocoa May 4, 2024
458d658
modify code for ios 17.4
KazuCocoa May 5, 2024
8ae6c8b
run another ios tests
KazuCocoa May 6, 2024
9aec0d3
fix path
KazuCocoa May 6, 2024
f59f03a
split
KazuCocoa May 6, 2024
b4e8e1a
teak
KazuCocoa May 6, 2024
a94d289
fix lint
KazuCocoa May 6, 2024
f52b984
remove unnecessary code modification
KazuCocoa May 6, 2024
dca4e2b
add comment more
KazuCocoa May 6, 2024
673aabd
modify the reference
KazuCocoa May 6, 2024
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
20 changes: 16 additions & 4 deletions .github/workflows/functional-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ jobs:
fail-fast: false
matrix:
test_targets:
- target: search_context/find_by_*.py remote_fs_tests.py safari_tests.py execute_driver_tests.py
- target: test/functional/ios/search_context/find_by_*.py test/functional/ios/remote_fs_tests.py test/functional/ios/safari_tests.py test/functional/ios/execute_driver_tests.py
name: func_test_ios1
- target: test/functional/ios/applications_tests.py test/functional/ios/hw_actions_tests.py test/functional/ios/keyboard_tests.py
name: func_test_ios2
- target: test/functional/ios/screen_record_tests.py test/functional/ios/webdriver_tests.py
name: func_test_ios3

runs-on: macos-14

Expand All @@ -43,21 +47,29 @@ jobs:
model: 'iPhone 15 Plus'
os_version: '17.4'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes sense to extract these values and keep them in a single place, for example env variables
The reason for it is that when we need to change iOS version this also usually requires to change phone model and macOS version

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, similar thing will occur in Android as well, I believe. So firsly I move Azure to GHA without such definition and will do for Android and iOS both later. Then perhaps it would make sense to modify python code side as well to refer to them.


# needed?
- run: brew install ffmpeg

# Start Appium
- run: npm install -g appium
- run: |
appium driver install xcuitest
appium plugin install images
appium plugin install execute-driver
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors --base-path=/wd/hub > appium.log &
nohup appium --use-plugins=images,execute-driver --relaxed-security --log-timestamp --log-no-colors > appium.log &

- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: 3.9

- run: python -m pytest ${{ test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html
working-directory: test/functional/ios
- run: |
# Separate 'run' creates differnet pipenv env. Does them in one run for now.
pip install --upgrade pip
pip install --upgrade pipenv
pipenv lock --clear
pipenv install -d --system
pytest ${{ matrix.test_targets.target}} --doctest-modules --junitxml=junit/test-results.xml --cov=com --cov-report=xml --cov-report=html

- name: Save server output
if: ${{ always() }}
Expand Down
16 changes: 0 additions & 16 deletions ci-jobs/functional_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,6 @@ parameters:
CI: true

jobs:
- template: ./functional/run_ios_test.yml
parameters:
name: 'func_test_ios1'
vmImage: ${{ parameters.vmImage }}
pytestOpt: ${{ parameters.pytestOpt }}
testFiles: 'search_context/find_by_*.py remote_fs_tests.py safari_tests.py execute_driver_tests.py'
CI: ${{ parameters.ci }}
xcodeForIOS: ${{ parameters.xcodeForIOS }}
- template: ./functional/run_ios_test.yml
parameters:
name: 'func_test_ios2'
vmImage: ${{ parameters.vmImage }}
pytestOpt: ${{ parameters.pytestOpt }}
testFiles: 'applications_tests.py hw_actions_tests.py keyboard_tests.py screen_record_tests.py webdriver_tests.py'
CI: ${{ parameters.ci }}
xcodeForIOS: ${{ parameters.xcodeForIOS }}
- template: ./functional/run_android_test.yml
parameters:
name: 'func_test_android1'
Expand Down
Binary file modified test/apps/UICatalog.app.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions test/functional/ios/helper/desired_capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_desired_capabilities(app: Optional[str] = None) -> Dict[str, Any]:
desired_caps: Dict[str, Any] = {
'deviceName': iphone_device_name(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value should be received from CI env

'platformName': 'iOS',
'platformVersion': '15.5',
'platformVersion': '17.4',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value should be received from CI env

'automationName': 'XCUITest',
'allowTouchIdEnroll': True,
'wdaLocalPort': wda_port(),
Expand Down Expand Up @@ -70,7 +70,7 @@ def wda_port() -> int:


def iphone_device_name() -> str:
prefix = 'iPhone 12'
prefix = 'iPhone 15 Plus'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this value should be received from CI env

if PytestXdistWorker.NUMBER == PytestXdistWorker.gw(0):
return f'{prefix} - 8100'
elif PytestXdistWorker.NUMBER == PytestXdistWorker.gw(1):
Expand Down
2 changes: 2 additions & 0 deletions test/functional/ios/helper/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@


class BaseTestCase(object):
IOS_UICATALOG_APP_NAME = 'UIKitCatalog'

def setup_method(self) -> None:
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
self.driver = webdriver.Remote(SERVER_URL_BASE, options=XCUITestOptions().load_capabilities(desired_caps))
Expand Down
32 changes: 29 additions & 3 deletions test/functional/ios/safari_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,44 @@
class TestSafari:
def setup_method(self) -> None:
caps = get_desired_capabilities()
caps.update({'browserName': 'safari', 'nativeWebTap': True, 'safariIgnoreFraudWarning': True})
caps.update(
{
'bundleId': 'com.apple.mobilesafari',
'nativeWebTap': True,
'safariIgnoreFraudWarning': True,
'webviewConnectTimeout': 100000,
}
)
self.driver = webdriver.Remote(SERVER_URL_BASE, options=AppiumOptions().load_capabilities(caps))

# Fresh iOS 17.4 simulator may not show up the webview context with "safari"
# after a fresh simlator instance creation.
# Re-launch the process could be a workaround in my debugging.
self.driver.terminate_app('com.apple.mobilesafari')
self.driver.activate_app('com.apple.mobilesafari')

def teardown_method(self) -> None:
self.driver.quit()

def test_context(self) -> None:
assert 'NATIVE_APP' == self.driver.contexts[0]
assert self.driver.contexts[1].startswith('WEBVIEW_')
contexts = self.driver.contexts
assert 'NATIVE_APP' == contexts[0]
assert contexts[1].startswith('WEBVIEW_')
self.driver.switch_to.context(contexts[1])
assert 'WEBVIEW_' in self.driver.current_context

def test_get(self) -> None:
ok = False
contexts = self.driver.contexts
for context in contexts:
if context.startswith('WEBVIEW_'):
self.driver.switch_to.context(context)
ok = True
break

if ok is False:
assert False, 'Could not set WEBVIEW context'

self.driver.get('http://google.com')
for _ in range(5):
time.sleep(0.5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@

class TestFindByElementWebelement(BaseTestCase):
def test_find_element_by_path(self) -> None:
el = self.driver.find_element(by=AppiumBy.IOS_PREDICATE, value='wdName == "UICatalog"')
assert 'UICatalog' == el.get_attribute('name')
el = self.driver.find_element(by=AppiumBy.IOS_PREDICATE, value='wdName == "UIKitCatalog"')
Copy link
Contributor

@mykola-mokhnach mykola-mokhnach May 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the constant also be used in the locator? same below

assert self.IOS_UICATALOG_APP_NAME == el.get_attribute('name')

c_el = el.find_elements(by=AppiumBy.IOS_PREDICATE, value='label == "Action Sheets"') # type: list
assert 'Action Sheets' == c_el[0].get_attribute('name')
c_el = el.find_elements(by=AppiumBy.IOS_PREDICATE, value='label == "UIKitCatalog"') # type: list
assert self.IOS_UICATALOG_APP_NAME == c_el[0].get_attribute('name')

c_el = el.find_elements(by=AppiumBy.IOS_CLASS_CHAIN, value='**/XCUIElementTypeStaticText')
assert 'UICatalog' == c_el[0].get_attribute('name')
assert self.IOS_UICATALOG_APP_NAME == c_el[0].get_attribute('name')

c_el = el.find_elements(by=AppiumBy.ACCESSIBILITY_ID, value='UICatalog')
assert 'UICatalog' == c_el[0].get_attribute('name')
c_el = el.find_elements(by=AppiumBy.ACCESSIBILITY_ID, value='UIKitCatalog')
assert self.IOS_UICATALOG_APP_NAME == c_el[0].get_attribute('name')
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@

class TestFindByIOClassChain(BaseTestCase):
def test_find_element_by_path(self) -> None:
el = self.driver.find_element(by=AppiumBy.IOS_CLASS_CHAIN, value='**/XCUIElementTypeNavigationBar')
assert self.IOS_UICATALOG_APP_NAME == el.get_attribute('name')

def test_find_multiple_elements_by_path(self) -> None:
els = self.driver.find_elements(
by=AppiumBy.IOS_CLASS_CHAIN, value='XCUIElementTypeWindow/**/XCUIElementTypeStaticText'
)
assert 35 == len(els)
assert 'UICatalog' == els[0].get_attribute('name')

def test_find_multiple_elements_by_path(self) -> None:
el = self.driver.find_elements(by=AppiumBy.IOS_CLASS_CHAIN, value='XCUIElementTypeWindow/*/*/*')
assert 2 == len(el)
assert 'UICatalog' == el[0].get_attribute('name')
assert el[1].get_attribute('name') is None
assert 37 == len(els)
assert self.IOS_UICATALOG_APP_NAME == els[0].get_attribute('name')
Loading