ci: simplify and merge CI jobs
1. 合并lint和typecheck任务为一个job,减少重复的环境配置步骤 2. 精简测试矩阵,只保留Python3.8和3.13两个版本 3. 移除不必要的覆盖率上传和聚合检查job 4. 简化工作流触发条件,只保留push和手动触发
This commit is contained in:
+16
-95
@@ -3,127 +3,48 @@ name: CI
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ main, develop ]
|
branches: [ main, develop ]
|
||||||
pull_request:
|
|
||||||
branches: [ main, develop ]
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
concurrency:
|
concurrency:
|
||||||
group: ${{ github.workflow }}-${{ github.ref }}
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
cancel-in-progress: true
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# ─────────────────────────────────────────────────────────────
|
lint-and-typecheck:
|
||||||
# lint:代码风格与格式检查(单平台即可)
|
name: Lint & Typecheck
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
lint:
|
|
||||||
name: Lint (ruff)
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 安装 uv
|
- uses: astral-sh/setup-uv@v5
|
||||||
uses: astral-sh/setup-uv@v5
|
|
||||||
with:
|
with:
|
||||||
version: latest
|
|
||||||
enable-cache: true
|
enable-cache: true
|
||||||
cache-dependency-glob: uv.lock
|
|
||||||
|
|
||||||
- name: 设置 Python 3.13
|
- uses: actions/setup-python@v5
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
|
||||||
- name: 安装依赖
|
- run: uv sync
|
||||||
run: uv sync --extra dev --frozen
|
- run: uv run ruff check src tests
|
||||||
|
- run: uv run pyrefly check .
|
||||||
|
|
||||||
- name: Ruff 检查
|
|
||||||
run: uv run ruff check src tests
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
# typecheck:pyrefly 严格类型检查
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
typecheck:
|
|
||||||
name: Typecheck (pyrefly)
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 安装 uv
|
|
||||||
uses: astral-sh/setup-uv@v5
|
|
||||||
with:
|
|
||||||
version: latest
|
|
||||||
enable-cache: true
|
|
||||||
cache-dependency-glob: uv.lock
|
|
||||||
|
|
||||||
- name: 设置 Python 3.13
|
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
|
||||||
python-version: '3.13'
|
|
||||||
|
|
||||||
- name: 安装依赖
|
|
||||||
run: uv sync --extra dev --frozen
|
|
||||||
|
|
||||||
- name: pyrefly 严格类型检查
|
|
||||||
run: uv run pyrefly check .
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
# test:多平台 × 多 Python 版本矩阵测试 + 覆盖率
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
test:
|
test:
|
||||||
name: Test (${{ matrix.os }} / py${{ matrix.python-version }})
|
name: Test (${{ matrix.os }})
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', '3.13' ]
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 安装 uv
|
- uses: astral-sh/setup-uv@v5
|
||||||
uses: astral-sh/setup-uv@v5
|
|
||||||
with:
|
with:
|
||||||
version: latest
|
|
||||||
enable-cache: true
|
enable-cache: true
|
||||||
cache-dependency-glob: uv.lock
|
|
||||||
|
|
||||||
- name: 设置 Python ${{ matrix.python-version }}
|
- uses: actions/setup-python@v5
|
||||||
uses: actions/setup-python@v5
|
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: |
|
||||||
|
3.8
|
||||||
|
3.13
|
||||||
|
|
||||||
- name: 安装依赖
|
- run: uvx tox run -e py38,py313
|
||||||
run: uv sync --extra dev --frozen
|
|
||||||
|
|
||||||
- name: 运行测试
|
|
||||||
run: uv run pytest -v --cov=pyflowx --cov-report=xml --cov-report=term-missing
|
|
||||||
|
|
||||||
- name: 上传覆盖率
|
|
||||||
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.13'
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: coverage-${{ matrix.os }}-py${{ matrix.python-version }}
|
|
||||||
path: coverage.xml
|
|
||||||
retention-days: 7
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
# 聚合:所有检查通过后才标记完成
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
ci-pass:
|
|
||||||
name: CI Pass
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
needs: [ lint, typecheck, test ]
|
|
||||||
if: always()
|
|
||||||
steps:
|
|
||||||
- name: 检查依赖任务结果
|
|
||||||
if: ${{ needs.lint.result != 'success' || needs.typecheck.result != 'success' || needs.test.result != 'success' }}
|
|
||||||
run: |
|
|
||||||
echo "lint: ${{ needs.lint.result }}"
|
|
||||||
echo "typecheck: ${{ needs.typecheck.result }}"
|
|
||||||
echo "test: ${{ needs.test.result }}"
|
|
||||||
exit 1
|
|
||||||
- name: 全部通过
|
|
||||||
run: echo "✅ 所有 CI 检查通过"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user