name: CI on: push: branches: [main, develop] pull_request: branches: [main, develop] workflow_dispatch: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: # ───────────────────────────────────────────────────────────── # lint:代码风格与格式检查(单平台即可) # ───────────────────────────────────────────────────────────── lint: name: Lint (ruff) 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: Ruff 检查 run: uv run ruff check src tests examples - name: Ruff 格式检查 run: uv run ruff format --check src tests examples # ───────────────────────────────────────────────────────────── # typecheck:mypy 严格类型检查 # ───────────────────────────────────────────────────────────── typecheck: name: Typecheck (mypy) 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: Mypy 严格类型检查 run: uv run mypy # ───────────────────────────────────────────────────────────── # test:多平台 × 多 Python 版本矩阵测试 + 覆盖率 # ───────────────────────────────────────────────────────────── test: name: Test (${{ matrix.os }} / py${{ matrix.python-version }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] 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 ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: 安装依赖 run: uv sync --extra dev --frozen - name: 运行测试(含覆盖率,强制 100%) run: uv run pytest -v --cov=pyflowx --cov-report=xml --cov-report=term-missing --cov-fail-under=100 - name: 运行示例冒烟测试 run: | uv run python examples/etl_pipeline.py uv run python examples/parallel_run.py uv run python examples/async_aggregation.py - 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 检查通过"