ci: add automated test workflow
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
name: Tests
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Python 3.11 / Windows
|
||||
runs-on: windows-latest
|
||||
env:
|
||||
QT_QPA_PLATFORM: offscreen
|
||||
PYTHONUTF8: "1"
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.11"
|
||||
cache: pip
|
||||
cache-dependency-path: requirements.txt
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install -r requirements.txt
|
||||
|
||||
- name: Syntax check
|
||||
run: python -m compileall app main.py
|
||||
|
||||
- name: Unit and GUI tests
|
||||
run: python -m unittest discover -s tests
|
||||
@@ -50,6 +50,7 @@
|
||||
| 语法检查 | `python -m compileall app main.py` |
|
||||
| 启动 GUI | `python main.py` / `python -m app` |
|
||||
| 单元测试(T-006 后) | `python -m unittest discover -s tests` |
|
||||
| CI 自动验证 | GitHub Actions `.github/workflows/tests.yml`(Windows + Python 3.11 + `QT_QPA_PLATFORM=offscreen`) |
|
||||
| 跑单账号演示 | `python prototypes/demo.py`(分步)/ `set AUTO=1 && python prototypes/demo.py`(自动) |
|
||||
| 提交更新(真改线上) | `set UPDATE=1 && python prototypes/demo.py` |
|
||||
| 读取某账号 Cookie(调试) | `python prototypes/cookies.py` |
|
||||
@@ -83,5 +84,6 @@ set AUTO=1 && python prototypes/demo.py
|
||||
| 语法 | 正式代码包与入口 | `python -m compileall app main.py` |
|
||||
| 单元 | `appconfig/db/excel/prompts/config/chrome` 的纯逻辑 | T-006 建立 `tests/` 后运行 `python -m unittest discover -s tests`,使用临时目录/临时 SQLite/样例 Excel |
|
||||
| GUI 轻测 | PySide6 主窗口可创建、Tab 数量、worker signal 基本行为 | 可用 unittest 构造 `QApplication`,不连真实 Shopee |
|
||||
| CI | push / pull_request 自动跑语法 + 全量 unittest | `.github/workflows/tests.yml` 安装 `requirements.txt`,运行 `python -m compileall app main.py` 与 `python -m unittest discover -s tests`;不连真实 Shopee/AI |
|
||||
| 集成 | CDP/editor 操作 Shopee 测试商品 | 手动跑 `prototypes/demo.py` 或后续专用集成脚本 |
|
||||
| 外部 AI | 模型连接、文本/图像生成 | 默认 mock;真实调用只在手动验证时跑,避免成本和限流 |
|
||||
|
||||
+1
-1
@@ -110,7 +110,7 @@
|
||||
| ID | 任务 | 依赖 | 验收要点 | 状态 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| T-521 | 依赖清单(锁版本 requirements) | T-006 | 依据 `docs/engineering-review.md` P0。新增锁版本的 `requirements.txt`(或 `pyproject.toml`)声明 PySide6/openpyxl/websocket-client/requests 及版本,与 `docs/03-tech-stack.md` 依赖纪律对齐;README/文档补安装说明;不引入新运行时依赖、不改业务代码 | DONE |
|
||||
| T-522 | CI:自动跑语法 + 单元/ GUI 测试 | T-006, T-521 | 依据 `docs/engineering-review.md` P1。加 GitHub Actions,在 push/PR 上按 `requirements.txt` 安装依赖并跑 `python -m compileall app main.py` + `python -m unittest discover -s tests`(含 PySide6 环境下的 GUI 测试,`QT_QPA_PLATFORM=offscreen`);不连真实 Shopee/AI;失败即红灯,把"改完必跑测试"变强制门禁 | TODO |
|
||||
| T-522 | CI:自动跑语法 + 单元/ GUI 测试 | T-006, T-521 | 依据 `docs/engineering-review.md` P1。加 GitHub Actions,在 push/PR 上按 `requirements.txt` 安装依赖并跑 `python -m compileall app main.py` + `python -m unittest discover -s tests`(含 PySide6 环境下的 GUI 测试,`QT_QPA_PLATFORM=offscreen`);不连真实 Shopee/AI;失败即红灯,把"改完必跑测试"变强制门禁 | DONE |
|
||||
| T-523 | 拆分 `app/gui.py` 为 `app/gui/` 包 | T-511, T-514, T-515, T-516, T-517 | 依据 `docs/engineering-review.md` P0。把 6317 行 God-file 拆为包:`models.py`(3 个 TableModel)、`tabs/`(①~⑤各一文件)、`workers.py`(Generate/Apply/Collect/WriteBack/AccountLoginCheck/AIModelTest 从 gui 挪出,与 `app/workers.py` 基类归拢)、`widgets.py`(色板常量、空状态卡、批次总览等 helper)、`main_window.py`。纯结构重构、对外行为与公开符号不变(保留 `from app import gui` 及 `MainWindow`/各 Tab/Worker 的导入路径或提供兼容再导出),保留 PySide6 缺失优雅降级;68 个 GUI 测试全绿、不删减断言 | TODO |
|
||||
| T-524 | PyInstaller 打包为免安装 exe | T-521 | 依据 `docs/engineering-review.md` P1。新增 PyInstaller spec/脚本,产出 Windows 免安装 `.exe`;打包排除并绝不内置 `config.json`/`config/ai_models.json`/`cmshopee.db*`/`chrome_user_data_dir/`/`images/`/`logs/` 等本地数据与密钥;首次运行按现有默认值在本地生成配置;文档补打包与分发步骤 | TODO |
|
||||
| T-525 | 引入 ruff(lint + format)+ 可选 pre-commit | T-006 | 依据 `docs/engineering-review.md` P1。加 `ruff` 配置(lint + format),先以现状为基线不做大规模风格重排,只开启安全规则(未用 import/变量、明显错误);可选 `.pre-commit-config.yaml`;不改业务逻辑;CI(T-522)可串入 ruff 检查。数据模型渐进上 mypy 作为后续可选 | TODO |
|
||||
|
||||
@@ -35,6 +35,9 @@ python -m unittest discover -s tests
|
||||
```
|
||||
|
||||
`requirements.txt` 只锁定运行所需第三方依赖;`config.json`、`config/ai_models.json`、SQLite、图片、登录态和运营 Excel 仍是本地数据,不提交版本库。
|
||||
|
||||
GitHub Actions 工作流见 `.github/workflows/tests.yml`,在 push / pull_request 上使用 Windows + Python 3.11 安装 `requirements.txt`,并自动运行语法检查和全量单元/GUI 测试。
|
||||
|
||||
## 任务 / 进度 / 当前状态
|
||||
|
||||
- `06-tasks.md` 维护任务看板:任务 ID、依赖、验收要点和状态。
|
||||
|
||||
File diff suppressed because one or more lines are too long
+5
-1
@@ -1025,4 +1025,8 @@
|
||||
|
||||
- 代码/配置:新增根目录 `requirements.txt`,锁定当前直接运行依赖:PySide6==6.5.3、openpyxl==3.1.3、requests==2.31.0、websocket-client==1.6.1、Pillow==9.5.0;不新增运行时依赖,不改业务代码。
|
||||
- 文档:`docs/03-tech-stack.md` 的安装命令改为 `python -m pip install -r requirements.txt`,并补充依赖纪律;`docs/README.md` 增加运行环境安装命令;`docs/06-tasks.md` 标记 T-521 DONE;`docs/current-state.md` 同步当前快照和下一任务 T-522。
|
||||
- 验证:`python -c "import PySide6, openpyxl, requests, websocket, PIL; ..."` 确认当前版本;`python -m pip install --no-index -r requirements.txt` 确认当前环境已满足锁定依赖且不触网;`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过(159 tests)。`python -m pip check` 在全局环境发现 albumentations/paddleocr/flask-babel 等非本项目包的既有依赖冲突,非 T-521 新增依赖导致;本项目锁定的 5 个直接依赖可正常 import。
|
||||
- 验证:`python -c "import PySide6, openpyxl, requests, websocket, PIL; ..."` 确认当前版本;`python -m pip install --no-index -r requirements.txt` 确认当前环境已满足锁定依赖且不触网;`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过(159 tests)。`python -m pip check` 在全局环境发现 albumentations/paddleocr/flask-babel 等非本项目包的既有依赖冲突,非 T-521 新增依赖导致;本项目锁定的 5 个直接依赖可正常 import。
|
||||
## 【2026-07-02】T-522 完成 · CI 自动跑语法 + 单元 / GUI 测试
|
||||
- 配置:新增 `.github/workflows/tests.yml`,在 push / pull_request 上使用 `windows-latest` + Python 3.11,安装 `requirements.txt`,设置 `QT_QPA_PLATFORM=offscreen`,运行 `python -m compileall app main.py` 与 `python -m unittest discover -s tests`。
|
||||
- 文档:同步 `docs/03-tech-stack.md`、`docs/README.md`、`docs/current-state.md`;`docs/06-tasks.md` 将 T-522 标为 DONE,下一个可领取任务更新为 T-523。
|
||||
- 验证:`python -m compileall app main.py` 通过;`python -m unittest discover -s tests` 通过(159 tests);`git diff --check` 无空白错误(仅 LF/CRLF 提示)。本地未执行 GitHub Actions 远端 runner,workflow 已按同等命令配置。
|
||||
Reference in New Issue
Block a user