2 Commits

Author SHA1 Message Date
zhou 5293831165 Merge pull request 'feat(cli/dev/envdev): 为Linux环境添加Docker安装配置相关任务' (#1) from develop into main
CI / Lint & Typecheck (push) Failing after 30s
CI / Test (ubuntu-latest) (push) Failing after 30s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
Reviewed-on: #1
2026-07-02 05:26:08 +00:00
zhou 87606d152a feat(cli/dev/envdev): 为Linux环境添加Docker安装配置相关任务
CI / Lint & Typecheck (push) Failing after 6m4s
CI / Test (ubuntu-latest) (push) Failing after 1m31s
CI / Test (macos-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
新增Linux系统下安装docker-compose-v2、添加用户到docker组以及刷新docker用户组的任务流程,完善开发环境配置步骤
2026-07-02 10:58:12 +08:00
11 changed files with 4805 additions and 220 deletions
-47
View File
@@ -1,47 +0,0 @@
# 版本控制
.git
.gitignore
.github
# Python 缓存与构建产物
__pycache__
*.pyc
*.pyo
*.pyd
*.egg-info
*.egg
dist
build
.eggs
# 测试与覆盖率
.pytest_cache
.coverage
htmlcov
.tox
coverage.xml
# 虚拟环境
.venv
venv
env
# 工具缓存
.uv-cache
.ruff_cache
.pyrefly_cache
.mypy_cache
# IDE 与编辑器
.idea
.vscode
*.swp
*.swo
# 文档与示例(按需保留)
docs
examples
# 系统文件
.DS_Store
Thumbs.db
+34 -18
View File
@@ -9,26 +9,42 @@ concurrency:
cancel-in-progress: true
jobs:
ci:
name: Lint, Typecheck & Test
lint-and-typecheck:
name: Lint & Typecheck
runs-on: ubuntu-latest
container:
image: pyflowx-ci:latest
env:
UV_LINK_MODE: copy
# ---- 国内源 ----
PIP_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
PIP_TRUSTED_HOST: pypi.tuna.tsinghua.edu.cn
UV_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
UV_TRUSTED_HOST: pypi.tuna.tsinghua.edu.cn
steps:
- uses: http://gitea:3000/zhou/checkout.git@main
- uses: actions/checkout@v4
- name: Sync dependencies
run: uv sync --frozen
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- name: Ruff check
run: ruff check src tests
- uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Tox test (py38, py313)
run: uvx tox run -e py38,py313
- 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]
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
- uses: actions/setup-python@v5
with:
python-version: |
3.8
3.13
- run: uvx tox run -e py38,py313
+45 -42
View File
@@ -6,53 +6,56 @@ on:
permissions:
contents: write
id-token: write
jobs:
release:
name: Build, Publish & Release
build:
runs-on: ubuntu-latest
container:
image: pyflowx-ci:latest
env:
UV_LINK_MODE: copy
# ---- 国内源 ----
PIP_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
PIP_TRUSTED_HOST: pypi.tuna.tsinghua.edu.cn
UV_INDEX_URL: https://pypi.tuna.tsinghua.edu.cn/simple
UV_TRUSTED_HOST: pypi.tuna.tsinghua.edu.cn
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: http://gitea:3000/zhou/checkout.git@v4
- uses: actions/checkout@v4
- name: Build distributions
run: uv build
- name: Publish to pypi
run: uv publish --token '${{ secrets.PYPI_TOKEN }}'
- name: Create Gitea Release & Upload Assets
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
REPO: ${{ github.repository }}
GITEA_URL: http://10.0.16.16:3000
run: |
set -e
# 1. 创建 Release
RELEASE_ID=$(curl -sS -X POST "$GITEA_URL/api/v1/repos/$REPO/releases" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG_NAME\",\"name\":\"Release $TAG_NAME\",\"body\":\"Automated release from CI\",\"draft\":false,\"prerelease\":false}" \
| python3 -c "import sys,json;print(json.load(sys.stdin)['id'])")
- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
echo "Created release id=$RELEASE_ID"
- uses: actions/setup-python@v5
with:
python-version: '3.13'
# 2. 上传 dist/ 下所有文件作为附件
for f in dist/*; do
echo "Uploading $f ..."
curl -sS -X POST "$GITEA_URL/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$(basename $f)" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary "@$f"
done
- run: uv build
- id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
publish-pypi:
needs: build
runs-on: ubuntu-latest
environment: pypi
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
release:
needs: [build, publish-pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v8
with:
name: dist
path: dist
- uses: softprops/action-gh-release@v2
with:
files: dist/*
generate_release_notes: true
-63
View File
@@ -1,63 +0,0 @@
# 使用国内镜像源拉取基础镜像
# 备选镜像源前缀:docker.1ms.run / dockerpull.com / docker.xuanyuan.me
FROM docker.m.daocloud.io/python:3.13-slim
# 国内镜像源(清华)
ENV PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
ENV PIP_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
ENV UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple
ENV UV_TRUSTED_HOST=pypi.tuna.tsinghua.edu.cn
# 环境变量:非交互 + 路径配置
ENV DEBIAN_FRONTEND=noninteractive \
LANG=C.UTF-8 \
LC_ALL=C.UTF-8 \
UV_LINK_MODE=copy \
UV_CACHE_DIR=/uv-cache \
UV_PYTHON_INSTALL_DIR=/uv-python \
UV_PROJECT_ENVIRONMENT=/opt/venv \
PATH="/opt/venv/bin:${PATH}"
# 配置 apt 国内镜像(阿里云)并安装系统依赖
RUN sed -i 's|deb.debian.org|mirrors.aliyun.com|g' /etc/apt/sources.list.d/debian.sources \
&& apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
curl \
git \
jq \
build-essential \
&& rm -rf /var/lib/apt/lists/*
# 配置 pip 国内镜像(阿里云)
RUN mkdir -p /etc/pip \
&& printf '[global]\nindex-url = https://mirrors.aliyun.com/pypi/simple/\ntrusted-host = mirrors.aliyun.com\n' \
> /etc/pip/pip.conf \
&& mkdir -p /root/.config/pip \
&& ln -sf /etc/pip/pip.conf /root/.config/pip/pip.conf
# 安装 uv 并预装 Python 3.8 / 3.13
RUN pip install --no-cache-dir uv -i https://mirrors.aliyun.com/pypi/simple/ \
&& uv python install 3.8 3.13
# 安装 Node.js 20.xactions/checkout 需要)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
apt-get install -y nodejs && \
node --version
# 预装项目 dev 依赖(仅复制依赖描述文件,利用 Docker 层缓存)
WORKDIR /workspace
COPY pyproject.toml tox.ini README.md ./
COPY src/ ./src/
# 同步依赖到 /opt/venv(CI 时直接复用)
RUN uv sync --frozen --no-install-project 2>/dev/null || uv sync --no-install-project
# 预装 tox 环境(py38 + py313
RUN uvx tox run -e py38,py313 --notest 2>/dev/null || true
# 持久化 uv 缓存目录(CI 可挂载到宿主机加速)
VOLUME ["/uv-cache"]
# 默认入口
CMD ["/bin/bash"]
+6 -7
View File
@@ -21,12 +21,11 @@ license = { text = "MIT" }
name = "pyflowx"
readme = "README.md"
requires-python = ">=3.8"
version = "0.3.4"
version = "0.3.0"
[project.scripts]
autofmt = "pyflowx.cli.autofmt:main"
bumpversion = "pyflowx.cli.bumpversion:main"
dockercmd = "pyflowx.cli.dev.dockercmd:main"
emlman = "pyflowx.cli.emlmanager:main"
filedate = "pyflowx.cli.filedate:main"
filelvl = "pyflowx.cli.filelevel:main"
@@ -38,8 +37,8 @@ msdown = "pyflowx.cli.llm.msdownload:main"
packtool = "pyflowx.cli.packtool:main"
pdftool = "pyflowx.cli.pdftool:main"
piptool = "pyflowx.cli.piptool:main"
pxp = "pyflowx.cli.profiler:main"
pymake = "pyflowx.cli.pymake:main"
pxp = "pyflowx.cli.profiler:main"
reseticon = "pyflowx.cli.reseticoncache:main"
scrcap = "pyflowx.cli.screenshot:main"
sglang = "pyflowx.cli.llm.sglang:main"
@@ -67,6 +66,9 @@ dev = [
"tox-uv>=1.13.1",
"tox>=4.25.0",
]
llm = [
"sglang[all]==0.5.10rc0; python_version >= '3.10' and sys_platform == 'linux'",
]
office = [
"pillow>=10.4.0",
"pymupdf>=1.24.11",
@@ -78,9 +80,6 @@ office = [
build-backend = "hatchling.build"
requires = ["hatchling"]
[tool.uv]
required-version = ">=0.5.0"
[[tool.uv.index]]
default = true
url = "https://mirrors.aliyun.com/pypi/simple/"
@@ -95,7 +94,7 @@ packages = ["src/pyflowx"]
pyflowx = { workspace = true }
[dependency-groups]
dev = ["pyflowx[dev,office]"]
dev = ["pyflowx[dev,office,llm]"]
[tool.coverage.run]
branch = true
+1 -1
View File
@@ -100,7 +100,7 @@ from .task import (
task_template,
)
__version__ = "0.4.4"
__version__ = "0.4.0"
__all__ = [
"IS_LINUX",
-26
View File
@@ -1,26 +0,0 @@
from __future__ import annotations
from typing import Literal
import pyflowx as px
DockerMirrorType = Literal["tencent"]
DOCKER_MIRROR_URLS: dict[DockerMirrorType, str] = {"tencent": "ccr.ccs.tencentyun.com"}
def main():
# parser = argparse.ArgumentParser(description="Docker 命令行工具")
# parser.add_argument("--username", nargs="?", default="", type=str, help="Docker 用户名")
# args = parser.parse_args()
tasks: list[px.TaskSpec] = [
px.cmd(["docker", "login", "--username", "xxx", DOCKER_MIRROR_URLS["tencent"]], name="docker_login_tencent"),
]
alias: dict[str, str | list[str | px.TaskSpec] | px.TaskSpec | px.Graph] = {
"login": "docker_login_tencent",
}
runner = px.CliRunner(strategy="sequential", tasks=tasks, aliases=alias)
runner.run_cli()
+1 -1
View File
@@ -287,7 +287,7 @@ def pdf_ocr(input_path: Path, output_path: Path, lang: str = "chi_sim+eng") -> N
new_page.insert_image(new_page.rect, pixmap=pix)
text_rect = fitz.Rect(0, 0, page.rect.width, page.rect.height)
# pyrefly: ignore [bad-argument-type]
new_page.insert_textbox(text_rect, ocr_text, fontname="china-ss", fontsize=11)
new_page.insert_textbox(text_rect, ocr_text)
output_path.parent.mkdir(parents=True, exist_ok=True)
new_doc.save(str(output_path))
-4
View File
@@ -2,7 +2,6 @@
from __future__ import annotations
import os
from pathlib import Path
from unittest.mock import patch
@@ -162,9 +161,6 @@ dependencies = ["lib >= 2.0.0", "other >= 3.0.0"]
def test_file_write_error(self, tmp_path: Path, capsys: pytest.CaptureFixture[str]) -> None:
"""Should handle file write errors."""
if os.geteuid() == 0:
pytest.skip("测试在 root 权限下不适用")
# 在只读目录中创建文件(这个测试在某些系统上可能不适用)
test_file = tmp_path / "readonly.toml"
test_file.write_text('version = "1.0.0"', encoding="utf-8")
+1 -6
View File
@@ -561,12 +561,7 @@ class TestCliRunnerIntegration:
runner = px.CliRunner(aliases={"diamond": graph})
exit_code = runner.run(["diamond"])
assert exit_code == CliExitCode.SUCCESS.value
# dependency 策略并发调度独立任务,b 与 c 的相对顺序非确定;
# 仅校验拓扑约束:a 最先、d 最后、b/c 介于其间。
assert set(order) == {"a", "b", "c", "d"}
assert order[0] == "a"
assert order[-1] == "d"
assert set(order[1:3]) == {"b", "c"}
assert order == ["a", "b", "c", "d"]
def test_mixed_fn_and_cmd_commands(self) -> None:
"""混合 fn 和 cmd 的命令应都能执行."""
Generated
+4717 -5
View File
File diff suppressed because it is too large Load Diff