Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 40f0478146 | |||
| b808b880f8 | |||
| e073ff41ee | |||
| ea0c51de5e |
+17
-96
@@ -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 检查通过"
|
|
||||||
|
|||||||
+21
-153
@@ -2,192 +2,60 @@ name: Release
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
tags:
|
tags: ['v*.*.*']
|
||||||
- 'v*.*.*'
|
|
||||||
workflow_dispatch:
|
|
||||||
inputs:
|
|
||||||
tag:
|
|
||||||
description: '发布版本号(如 v0.1.0)'
|
|
||||||
required: true
|
|
||||||
type: string
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
# Trusted Publishing (OIDC) 上传 PyPI 所需
|
|
||||||
id-token: write
|
id-token: write
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# ─────────────────────────────────────────────────────────────
|
build:
|
||||||
# 预检:版本号校验 + 与 pyproject.toml 一致性检查
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
pre-check:
|
|
||||||
name: Pre-release Check
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.meta.outputs.version }}
|
version: ${{ steps.version.outputs.version }}
|
||||||
tag: ${{ steps.meta.outputs.tag }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
- uses: astral-sh/setup-uv@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: 解析版本号
|
|
||||||
id: meta
|
|
||||||
run: |
|
|
||||||
if [ -n "${{ inputs.tag }}" ]; then
|
|
||||||
TAG="${{ inputs.tag }}"
|
|
||||||
else
|
|
||||||
TAG="${GITHUB_REF#refs/tags/}"
|
|
||||||
fi
|
|
||||||
# 去除前缀 v
|
|
||||||
VERSION="${TAG#v}"
|
|
||||||
echo "tag=$TAG" >> $GITHUB_OUTPUT
|
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "发布版本: $VERSION (tag: $TAG)"
|
|
||||||
|
|
||||||
- name: 校验版本号格式
|
|
||||||
run: |
|
|
||||||
VERSION="${{ steps.meta.outputs.version }}"
|
|
||||||
if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$'; then
|
|
||||||
echo "❌ 版本号格式错误: $VERSION(应为 x.y.z 或 x.y.z-rc.n)"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: 校验 pyproject.toml 版本一致
|
|
||||||
run: |
|
|
||||||
# 精确提取 [project] 段的 version 字段(避免匹配到依赖的 version)
|
|
||||||
PY_VERSION=$(awk '/^\[project\]/{f=1} f&&/^version[[:space:]]*=/{gsub(/[" ]/,"",$3); print $3; exit}' pyproject.toml)
|
|
||||||
echo "pyproject.toml version: $PY_VERSION"
|
|
||||||
if [ "$PY_VERSION" != "${{ steps.meta.outputs.version }}" ]; then
|
|
||||||
echo "❌ pyproject.toml 版本($PY_VERSION) 与 tag 版本(${{ steps.meta.outputs.version }}) 不一致"
|
|
||||||
echo "请先更新 pyproject.toml 中的 version 字段"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
# 构建:wheel + sdist(纯 Python,单平台即可)
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
build:
|
|
||||||
name: Build Artifacts
|
|
||||||
needs: pre-check
|
|
||||||
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
|
enable-cache: true
|
||||||
|
|
||||||
- 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 build
|
||||||
run: uv sync --extra dev --frozen
|
|
||||||
|
|
||||||
- name: 构建 wheel + sdist
|
- id: version
|
||||||
run: uv build
|
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: 校验产物
|
- uses: actions/upload-artifact@v7
|
||||||
run: |
|
|
||||||
echo "待上传产物:"
|
|
||||||
ls -la dist/
|
|
||||||
if [ -z "$(ls -A dist/*.whl dist/*.tar.gz 2>/dev/null)" ]; then
|
|
||||||
echo "❌ 未找到 wheel 或 sdist 产物"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: 上传构建产物
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist/*
|
path: dist/
|
||||||
retention-days: 30
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
# 发布:上传到 PyPI(Trusted Publishing / OIDC)
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
publish-pypi:
|
publish-pypi:
|
||||||
name: Publish to PyPI
|
needs: build
|
||||||
needs: [pre-check, build]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
environment:
|
environment: pypi
|
||||||
name: pypi
|
|
||||||
url: https://pypi.org/project/pyflowx/${{ needs.pre-check.outputs.version }}
|
|
||||||
permissions:
|
|
||||||
id-token: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: 下载构建产物
|
- uses: actions/download-artifact@v8
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: dist
|
path: dist
|
||||||
|
|
||||||
- name: 上传到 PyPI
|
- uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
uses: pypa/gh-action-pypi-publish@release/v1
|
|
||||||
with:
|
|
||||||
attestations: true
|
|
||||||
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
# 发布:创建 GitHub Release
|
|
||||||
# ─────────────────────────────────────────────────────────────
|
|
||||||
release:
|
release:
|
||||||
name: Publish Release
|
needs: [build, publish-pypi]
|
||||||
needs: [pre-check, build, publish-pypi]
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
contents: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- uses: actions/download-artifact@v8
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: 下载构建产物
|
|
||||||
uses: actions/download-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
path: assets
|
path: dist
|
||||||
|
|
||||||
- name: 整理发布产物
|
- uses: softprops/action-gh-release@v2
|
||||||
run: |
|
|
||||||
ls -la assets/
|
|
||||||
|
|
||||||
- name: 生成 Release Notes
|
|
||||||
id: notes
|
|
||||||
run: |
|
|
||||||
{
|
|
||||||
echo "## pyflowx ${{ needs.pre-check.outputs.version }}"
|
|
||||||
echo ""
|
|
||||||
echo "### 下载"
|
|
||||||
echo ""
|
|
||||||
echo "- **Wheel**: \`pyflowx-${{ needs.pre-check.outputs.version }}-py3-none-any.whl\`"
|
|
||||||
echo "- **源码包**: \`pyflowx-${{ needs.pre-check.outputs.version }}.tar.gz\`"
|
|
||||||
echo ""
|
|
||||||
echo "### 安装"
|
|
||||||
echo ""
|
|
||||||
echo '```bash'
|
|
||||||
echo "pip install pyflowx==${{ needs.pre-check.outputs.version }}"
|
|
||||||
echo '```'
|
|
||||||
echo ""
|
|
||||||
echo "### 完整变更日志"
|
|
||||||
} > RELEASE_NOTES.md
|
|
||||||
{
|
|
||||||
echo "content<<EOF"
|
|
||||||
cat RELEASE_NOTES.md
|
|
||||||
echo "EOF"
|
|
||||||
} >> $GITHUB_OUTPUT
|
|
||||||
|
|
||||||
- name: 创建 GitHub Release
|
|
||||||
uses: softprops/action-gh-release@v2
|
|
||||||
with:
|
with:
|
||||||
tag_name: ${{ needs.pre-check.outputs.tag }}
|
files: dist/*
|
||||||
name: pyflowx ${{ needs.pre-check.outputs.version }}
|
|
||||||
body: ${{ steps.notes.outputs.content }}
|
|
||||||
files: assets/*
|
|
||||||
draft: false
|
|
||||||
prerelease: ${{ contains(needs.pre-check.outputs.version, '-') }}
|
|
||||||
generate_release_notes: true
|
generate_release_notes: true
|
||||||
|
|||||||
+4
-2
@@ -21,7 +21,7 @@ license = { text = "MIT" }
|
|||||||
name = "pyflowx"
|
name = "pyflowx"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.8"
|
requires-python = ">=3.8"
|
||||||
version = "0.2.7"
|
version = "0.2.8"
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
autofmt = "pyflowx.cli.autofmt:main"
|
autofmt = "pyflowx.cli.autofmt:main"
|
||||||
@@ -66,7 +66,9 @@ dev = [
|
|||||||
"tox-uv>=1.13.1",
|
"tox-uv>=1.13.1",
|
||||||
"tox>=4.25.0",
|
"tox>=4.25.0",
|
||||||
]
|
]
|
||||||
llm = ["sglang[all]==0.5.10rc0; python_version >= '3.10'"]
|
llm = [
|
||||||
|
"sglang[all]==0.5.10rc0; python_version >= '3.10' and sys_platform == 'linux'",
|
||||||
|
]
|
||||||
office = [
|
office = [
|
||||||
"pillow>=10.4.0",
|
"pillow>=10.4.0",
|
||||||
"pymupdf>=1.24.11",
|
"pymupdf>=1.24.11",
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ from .task import (
|
|||||||
task_template,
|
task_template,
|
||||||
)
|
)
|
||||||
|
|
||||||
__version__ = "0.3.1"
|
__version__ = "0.3.2"
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
"IS_LINUX",
|
"IS_LINUX",
|
||||||
|
|||||||
@@ -39,9 +39,6 @@ resolution-markers = [
|
|||||||
"python_full_version < '3.8.1'",
|
"python_full_version < '3.8.1'",
|
||||||
]
|
]
|
||||||
|
|
||||||
[options]
|
|
||||||
prerelease-mode = "allow"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "addict"
|
name = "addict"
|
||||||
version = "2.4.0"
|
version = "2.4.0"
|
||||||
@@ -6524,7 +6521,7 @@ pycountry = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pyflowx"
|
name = "pyflowx"
|
||||||
version = "0.2.6"
|
version = "0.2.7"
|
||||||
source = { editable = "." }
|
source = { editable = "." }
|
||||||
dependencies = [
|
dependencies = [
|
||||||
{ name = "graphlib-backport", marker = "python_full_version < '3.9'" },
|
{ name = "graphlib-backport", marker = "python_full_version < '3.9'" },
|
||||||
|
|||||||
Reference in New Issue
Block a user