From e073ff41ee5059644eb698577aaa23970c38e1f5 Mon Sep 17 00:00:00 2001 From: gooker_young Date: Sat, 27 Jun 2026 15:43:24 +0800 Subject: [PATCH] ci: simplify and merge CI jobs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 合并lint和typecheck任务为一个job,减少重复的环境配置步骤 2. 精简测试矩阵,只保留Python3.8和3.13两个版本 3. 移除不必要的覆盖率上传和聚合检查job 4. 简化工作流触发条件,只保留push和手动触发 --- .github/workflows/ci.yml | 113 ++++++--------------------------------- 1 file changed, 17 insertions(+), 96 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0357fb1..a5c93af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,127 +3,48 @@ 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) + lint-and-typecheck: + name: Lint & Typecheck runs-on: ubuntu-latest 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: - version: latest enable-cache: true - cache-dependency-glob: uv.lock - - name: 设置 Python 3.13 - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: python-version: '3.13' - - name: 安装依赖 - run: uv sync --extra dev --frozen + - run: uv sync + - 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: - name: Test (${{ matrix.os }} / py${{ matrix.python-version }}) + name: Test (${{ matrix.os }}) 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' ] + os: [ubuntu-latest, windows-latest, macos-latest] 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: - version: latest enable-cache: true - cache-dependency-glob: uv.lock - - name: 设置 Python ${{ matrix.python-version }} - uses: actions/setup-python@v5 + - uses: actions/setup-python@v5 with: - python-version: ${{ matrix.python-version }} + python-version: | + 3.8 + 3.13 - - name: 安装依赖 - 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 检查通过" + - run: uvx tox run -e py38,py313