Skip to content

Commit eb7a293

Browse files
committed
ci: 修复 Python 版本冲突,添加依赖缓存和测试分组
- 修复 Python 矩阵版本从 3.11/3.12/3.13 改为 3.14 - 添加 actions/setup-python 和 uv 缓存优化 - 拆分单元测试和集成测试为独立 job - 更新 Codecov 条件匹配 - Makefile clean 命令跨平台兼容
1 parent ef90d60 commit eb7a293

2 files changed

Lines changed: 37 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,60 @@ jobs:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
14+
- uses: actions/setup-python@v5
15+
with:
16+
python-version: "3.14"
1417
- uses: astral-sh/setup-uv@v4
18+
with:
19+
enable-cache: true
1520
- run: uv sync --all-extras
1621
- run: uv run ruff check .
1722

1823
typecheck:
1924
runs-on: ubuntu-latest
2025
steps:
2126
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.14"
2230
- uses: astral-sh/setup-uv@v4
31+
with:
32+
enable-cache: true
2333
- run: uv sync --all-extras
2434
- run: uv run mypy src/
2535

26-
test:
36+
test-unit:
2737
runs-on: ${{ matrix.os }}
2838
strategy:
39+
fail-fast: false
2940
matrix:
3041
os: [ubuntu-latest, windows-latest, macos-latest]
31-
python-version: ["3.11", "3.12", "3.13"]
42+
python-version: ["3.14"]
3243
steps:
3344
- uses: actions/checkout@v4
45+
- uses: actions/setup-python@v5
46+
with:
47+
python-version: ${{ matrix.python-version }}
3448
- uses: astral-sh/setup-uv@v4
35-
- run: uv sync --python ${{ matrix.python-version }} --all-extras
36-
- run: uv run pytest --cov --cov-report=xml
49+
with:
50+
enable-cache: true
51+
- run: uv sync --all-extras
52+
- run: uv run pytest tests/ -v -m "not integration" --cov --cov-report=xml
3753
- uses: codecov/codecov-action@v4
38-
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
54+
if: matrix.os == 'ubuntu-latest'
3955
with:
4056
files: coverage.xml
57+
flags: unit-tests
58+
59+
test-integration:
60+
runs-on: ubuntu-latest
61+
steps:
62+
- uses: actions/checkout@v4
63+
- uses: actions/setup-python@v5
64+
with:
65+
python-version: "3.14"
66+
- uses: astral-sh/setup-uv@v4
67+
with:
68+
enable-cache: true
69+
- run: uv sync --all-extras
70+
- run: uv run pytest tests/ -v -m "integration"

Makefile

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,9 @@ typecheck:
4040
# 运行所有检查
4141
check: lint typecheck test
4242

43-
# 清理缓存和临时文件
43+
# 清理缓存和临时文件(跨平台兼容)
4444
clean:
45-
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
46-
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
47-
find . -type d -name ".mypy_cache" -exec rm -rf {} + 2>/dev/null || true
48-
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
49-
rm -rf htmlcov/ .coverage 2>/dev/null || true
45+
uv run python -c "import shutil, pathlib; [shutil.rmtree(p, ignore_errors=True) for p in pathlib.Path('.').rglob('__pycache__')]; [shutil.rmtree(p, ignore_errors=True) for p in ['.pytest_cache', '.mypy_cache', '.ruff_cache', 'htmlcov', '.coverage'] if pathlib.Path(p).exists()]"
5046

5147
# 启动文档服务器 (如果有 mkdocs)
5248
docs:

0 commit comments

Comments
 (0)