Skip to content

Commit

Permalink
提交工作流
Browse files Browse the repository at this point in the history
  • Loading branch information
kaluluosi committed Nov 23, 2023
1 parent e7eb7e0 commit 558ba93
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 65 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

name: publish-docs
on:
push:
paths:
- "docs/**"
pull_request:
paths:
- "docs/**"

workflow_call:
inputs:
deploy:
Expand All @@ -25,17 +32,17 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
- name: Checkout-检出项目
uses: actions/checkout@v4

- name: Env Setup
uses: ./.github/actions/env_setup

- uses: actions/cache@v3
with:
key: mkdocs-material-${{env.cache_id}}
path: .cache
restore-keys:
mkdocs-material-
- run: pip install mkdocs-material
- run: mkdocs gh-deploy --force
- name: Build-生成文档
run: |
poetry run mkdocs build
- name: Deploy-部署文档
if: github.event.inputs.deploy == true
run: |
poetry run mkdocs gh-deploy --force
42 changes: 25 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ name: Upload Python Package
on:
release:
types: [published]
workflow_dispatch:
inputs:
version:
description: 'Version'
type: string
required: true

jobs:
test:
Expand All @@ -21,24 +27,26 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

- name: Env Setup
uses: ./.github/actions/env_setup

- name: 将Tag版本号填写到toml配置中
if: github.event.release.tag_name
run: poetry version ${{github.event.release.tag_name}}

- name: 将version参数更新到toml配置中
if: github.event.inputs.version
run: poetry version ${{github.event.inputs.version}}

- name: Install dependencies
run: |
poetry install
- name: Build package
run: poetry build
- name: Publish package
run: |
poetry publish --username __token__ --password ${{ secrets.PYPI_API_TOKEN }}
docs:
needs: [ deploy ]
uses: ./.github/workflows/docs.yml
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,33 @@ jobs:

test-android:
runs-on: windows-latest

services:
avd:
image: budtmo/docker-android:emulator_11.0
ports:
- 6080:6080
- 5554:5554
- 5555:5555
env:
EMULATOR_DEVICE: "Samsung Galaxy S10"
WEB_VNC: false
options:
--device /dev/kvm

steps:
- name: Wait For AVD To Startup-等待模拟器启动
uses: jakejarvis/[email protected]
with:
time: '60s'

- name: Checkout-检出项目
uses: actions/checkout@v4

- name: Env Setup
uses: ./.github/actions/env_setup

- name: unittest
run: |
poetry run -m unittest discover -s ./tests/ -p "test_*.py"
poetry run robot tests
30 changes: 17 additions & 13 deletions robotframework_airtest/poco/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

# 查询信息hh
class QueryInfo(NamedTuple):
name: str
name: Optional[str] = None
attrs: Dict[str, Any] = {}


Expand Down Expand Up @@ -68,13 +68,13 @@ def parse_url_to_queryinfos(url: Optional[PocoURL], **attrs) -> List[QueryInfo]:
# logger.console("parsing:{} {}".format(path, attrs))
query_infos: list[QueryInfo] = []
if url is None:
query_info = QueryInfo("", attrs=attrs)
query_info = QueryInfo(None, attrs=attrs)
query_infos.append(query_info)
else:
urls: list[str] = url.split("\\")
for index, url in enumerate(urls):
d = urlparse(url)
path = d.path if d.path else ""
path = d.path if d.path else None
ext_attrs = dict(parse_qsl(d.query))
query_info = QueryInfo(name=path, attrs=ext_attrs)
if index == len(urls) - 1:
Expand Down Expand Up @@ -164,7 +164,7 @@ def poco(self) -> StdPoco:
return self._poco

@property
def focusing_element(self) -> UIObjectProxy:
def focusing_element(self):
"""获取当前聚焦元素
Returns:
Expand All @@ -174,8 +174,6 @@ def focusing_element(self) -> UIObjectProxy:
if self.focusing_elements:
# 栈顶元素就是当前聚焦的元素
return self.focusing_elements[-1]
# 不然就返回根元素
return self.poco()

@property
def airtest_log_dir(self) -> str:
Expand Down Expand Up @@ -341,10 +339,16 @@ def _query(

node = None
# 在当前聚焦元素下查询第一个元素
node = self.focusing_element.offspring(queryinfo.name, **queryinfo.attrs)
if self.focusing_element:
node = self.focusing_element.offspring(
name=queryinfo.name, # type:ignore
**queryinfo.attrs,
)
else:
node = self.poco(name=queryinfo.name, **queryinfo.attrs) # type: ignore

for queryinfo in queryinfos[1:]:
node = node.offspring(queryinfo.name, **queryinfo.attrs)
node = node.offspring(queryinfo.name, **queryinfo.attrs) # type: ignore
# 接着往下查询
return node

Expand Down Expand Up @@ -458,12 +462,12 @@ def focus_element(
element = self._query(target)
self.focusing_elements.append(element)

logger.debug(
"聚焦元素 {} {}".format(
self.focusing_element, self.focusing_element.get_name()
if self.focusing_element:
logger.debug(
"聚焦元素 {} {}".format(
self.focusing_element, self.focusing_element.get_name()
)
)
)
logger.debug(self.focusing_elements)

@deco.keyword("结束聚焦元素")
def end_focus_element(self):
Expand Down
42 changes: 21 additions & 21 deletions tests/demo/com.netease.poco.u3d.tutorial_Data/output_log.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@ Direct3D:
Vendor: NVIDIA
VRAM: 24156 MB
Begin MonoManager ReloadAssembly
Platform assembly: c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.dll (this message is harmless)
Loading c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.dll into Unity Child Domain
Platform assembly: c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\Assembly-CSharp.dll (this message is harmless)
Loading c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\Assembly-CSharp.dll into Unity Child Domain
Platform assembly: c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.UI.dll (this message is harmless)
Loading c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.UI.dll into Unity Child Domain
Platform assembly: c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.Networking.dll (this message is harmless)
Loading c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.Networking.dll into Unity Child Domain
Platform assembly: c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\Newtonsoft.Json.dll (this message is harmless)
Loading c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\Newtonsoft.Json.dll into Unity Child Domain
- Completed reload, in 0.024 seconds
Platform assembly: c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\System.Core.dll (this message is harmless)
Platform assembly: c:\Users\john\Documents\Projects\Github\xtester_robot\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\System.dll (this message is harmless)
Platform assembly: C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.dll (this message is harmless)
Loading C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.dll into Unity Child Domain
Platform assembly: C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\Assembly-CSharp.dll (this message is harmless)
Loading C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\Assembly-CSharp.dll into Unity Child Domain
Platform assembly: C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.UI.dll (this message is harmless)
Loading C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.UI.dll into Unity Child Domain
Platform assembly: C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.Networking.dll (this message is harmless)
Loading C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\UnityEngine.Networking.dll into Unity Child Domain
Platform assembly: C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\Newtonsoft.Json.dll (this message is harmless)
Loading C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\Newtonsoft.Json.dll into Unity Child Domain
- Completed reload, in 0.032 seconds
Platform assembly: C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\System.Core.dll (this message is harmless)
Platform assembly: C:\Users\kalul\Documents\GitHub\robotframework-airtest\tests\demo\com.netease.poco.u3d.tutorial_Data\Managed\System.dll (this message is harmless)
<RI> Initializing input.
<RI> Input initialized.
desktop: 5120x1440 120Hz; virtual: 5120x1440 at 0,0
<RI> Initialized touch support.
UnloadTime: 0.342800 ms
UnloadTime: 0.341600 ms
Tcp server started

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

a3fa9accefc1a12e3a7eb344b9a7e040
1e0d25cd307f5ca045c1c3631f95cceb

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

Expand All @@ -45,9 +45,9 @@ SocketException: 由于套接字没有连接并且(当使用一个 sendto 调用
(Filename: Line: -1)

Setting up 6 worker threads for Enlighten.
Thread -> id: 9894 -> priority: 1
Thread -> id: 9740 -> priority: 1
Thread -> id: 6fe4 -> priority: 1
Thread -> id: 9698 -> priority: 1
Thread -> id: 836c -> priority: 1
Thread -> id: 5500 -> priority: 1
Thread -> id: 2f44 -> priority: 1
Thread -> id: 5c60 -> priority: 1
Thread -> id: 60f8 -> priority: 1
Thread -> id: 7e60 -> priority: 1
Thread -> id: 2994 -> priority: 1
Thread -> id: 6e3c -> priority: 1
Expand Down
2 changes: 1 addition & 1 deletion tests/test_device_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class TestAppManage(unittest.TestCase):
def setUpClass(cls):
cls.dev_lib = DeviceLibrary(device_uri="android:///")
cls.dev_lib.connect_device()
cls.dev_lib.install_app(APP_PACKAGE)
cls.dev_lib.install_app(APP_PATH)

@classmethod
def tearDownClass(cls):
Expand Down

0 comments on commit 558ba93

Please sign in to comment.