Skip to content

Commit 37637de

Browse files
committed
ci(github-actions): 添加自动化测试工作流
- 新增 .github/workflows/test.yml 配置文件 - 在 Windows 环境下配置 Python 3.12 自动化测试 - 设置 UTF-8 编码环境并自动运行 tests 目录下的测试脚本 test(images): 更新测试基准图像 - 更新 tests/images/iface_ltr.png 二进制文件 - 确保视觉回归测试使用最新的预期图像资源
1 parent 1bfaeb0 commit 37637de

2 files changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/test.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Run Tests
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize ]
6+
7+
jobs:
8+
tests:
9+
name: Run Tests
10+
runs-on: windows-latest
11+
12+
env:
13+
PYTHONIOENCODING: 'UTF-8'
14+
15+
strategy:
16+
matrix:
17+
python-version: [ 3.12 ]
18+
19+
steps:
20+
- name: Configure git
21+
run: |
22+
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
23+
git config --global core.autocrlf false
24+
git config --global core.eol lf
25+
git config --global user.email "110257560+BnanZ0@users.noreply.github.com"
26+
git config --global user.name "RU"
27+
echo "action_state=yellow" >> $env:GITHUB_ENV
28+
echo $env:action_state
29+
30+
- uses: actions/checkout@v6
31+
with:
32+
submodules: true
33+
lfs: true
34+
fetch-depth: 0
35+
36+
- name: Set up Python ${{ matrix.python-version }}
37+
uses: actions/setup-python@v6
38+
with:
39+
python-version: ${{ matrix.python-version }}
40+
41+
- name: Set UTF-8 encoding
42+
run: |
43+
set PYTHONIOENCODING=utf-8
44+
set PYTHONLEGACYWINDOWSSTDIO=utf-8
45+
echo PYTHONIOENCODING=utf-8 >> $GITHUB_ENV
46+
47+
- name: Install Dependencies
48+
run: |
49+
pip install -r requirements.txt
50+
51+
- name: Run tests
52+
run: |
53+
Get-ChildItem -Path ".\tests\*.py" | ForEach-Object {
54+
Write-Host "Running tests in $($_.FullName)"
55+
try {
56+
# Run the Python unittest command
57+
python -m unittest $_.FullName
58+
59+
# Check if the previous command succeeded
60+
if ($LASTEXITCODE -ne 0) {
61+
throw "Tests failed in $($_.FullName)"
62+
}
63+
} catch {
64+
# Stop the loop and return the error
65+
Write-Error $_
66+
exit 1
67+
}
68+
}
69+
70+

tests/images/iface_ltr.png

5.84 MB
Loading

0 commit comments

Comments
 (0)