ci: 完善CI/CD流程,添加测试覆盖率与并行测试配置
1. 为tox测试命令添加并行执行、覆盖率报告和JUnit结果输出 2. 拆分CI工作流为lint、格式检查、类型检查、安全审计、多矩阵测试和覆盖率汇总 3. 新增release前的预测试步骤,让build依赖测试通过 4. 移除低效的依赖策略测速测试用例 5. 配置多Python版本跨平台测试矩阵并上传测试 artifacts
This commit is contained in:
+101
-14
@@ -3,14 +3,16 @@ name: CI
|
||||
on:
|
||||
push:
|
||||
branches: [ main, develop ]
|
||||
pull_request:
|
||||
branches: [ main, develop ]
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint-and-typecheck:
|
||||
name: Lint & Typecheck
|
||||
lint:
|
||||
name: Lint (Ruff)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@@ -25,15 +27,10 @@ jobs:
|
||||
|
||||
- run: uv sync
|
||||
- run: uv run ruff check src tests
|
||||
- run: uv run pyrefly check .
|
||||
|
||||
test:
|
||||
name: Test (${{ matrix.os }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
format-check:
|
||||
name: Format Check (Ruff)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
@@ -43,8 +40,98 @@ jobs:
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: |
|
||||
3.8
|
||||
3.13
|
||||
python-version: '3.13'
|
||||
|
||||
- run: uvx tox run -e py38,py313
|
||||
- run: uv sync
|
||||
- run: uv run ruff format --check src tests
|
||||
|
||||
typecheck:
|
||||
name: Typecheck (Pyrefly)
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.13'
|
||||
|
||||
- run: uv sync
|
||||
- run: uv run pyrefly check .
|
||||
|
||||
security-audit:
|
||||
name: Security Audit
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.13'
|
||||
|
||||
- run: uv sync
|
||||
- run: uv tool run pip-audit --desc on
|
||||
|
||||
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.10', '3.13']
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Run tests
|
||||
run: uvx tox run -e py${{ matrix.python-version }}
|
||||
|
||||
- name: Upload test results
|
||||
uses: actions/upload-artifact@v7
|
||||
if: always()
|
||||
with:
|
||||
name: test-results-${{ matrix.os }}-py${{ matrix.python-version }}
|
||||
path: |
|
||||
test-results-*.xml
|
||||
coverage-*.xml
|
||||
if-no-files-found: ignore
|
||||
|
||||
coverage:
|
||||
name: Coverage Summary
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
if: always()
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/download-artifact@v8
|
||||
with:
|
||||
path: artifacts
|
||||
|
||||
- name: Collect coverage files
|
||||
run: |
|
||||
find artifacts -name "coverage-*.xml" -exec cp {} . \;
|
||||
ls -la coverage-*.xml 2>/dev/null || echo "No coverage files found"
|
||||
|
||||
- name: Publish test results
|
||||
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||
if: always() && github.event_name == 'pull_request'
|
||||
with:
|
||||
files: artifacts/**/test-results-*.xml
|
||||
comment_mode: off
|
||||
fail_on: nothing
|
||||
|
||||
@@ -9,7 +9,25 @@ permissions:
|
||||
id-token: write
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Pre-release Test
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: astral-sh/setup-uv@v5
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.13'
|
||||
|
||||
- run: uv sync
|
||||
- run: uv run pytest -m "not slow" -n auto --cov=pyflowx
|
||||
|
||||
build:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
version: ${{ steps.version.outputs.version }}
|
||||
|
||||
Reference in New Issue
Block a user