Skip to main content

GitHub Actions runner as a schedulable Python sandbox via WebSocket remote objects

Project description

WorkflowVM

将 GitHub Actions 化为可调度的云端 Python 沙盒

License Workflow Status Release PyPI version

Docker Image version Docker Image size Last Commit

LINUX DO


WorkflowVM 通过 rpyc classic 模式,将 GitHub Actions Runner 变成可远程操控的 Python 环境。所有 Python 协议(withfor、运算符、len()bool() 等)均透明支持,无需手动序列化。

核心特性

  • 免费云算力:无缝对接 GitHub Actions,零成本调度 Ubuntu Runner。
  • 透明 RPC:基于 rpyc NetRef,在本地像操作本地对象一样使用远端 Python 对象,上下文管理器、迭代器、运算符自动透传。
  • 自动生命周期:自动分配、保活和释放 Runner 资源。

警告:请合理使用,使用本工具可能导致 github 账号被永久封禁。

警告:请合理使用,使用本工具可能导致 github 账号被永久封禁。

警告:请合理使用,使用本工具可能导致 github 账号被永久封禁。


前置准备:GitHub Token

你需要一个具有特定权限的 Classic PAT (Personal Access Token)。 前往 GitHub Developer Settings 生成 Token,并确保勾选以下权限:

  • repo - 完整仓库访问权限(用于创建 runner 仓库)。
  • workflow - 触发 workflow_dispatch(必需,用于调度 Runner)。

快速开始

1. 配置账号池

创建一个 accounts.yml 文件:

accounts:
  - username: your-github-username
    token: ghp_YOUR_CLASSIC_PAT  # 必须包含 repo + workflow 权限
    runner_repo: wvm-runner      # 将自动创建此仓库
    max_concurrent: 5            # 最大并发 runner 数量

server:
  host: 0.0.0.0
  port: 8765
  api_token: "your-server-api-token"
  # ws_url: "wss://your-domain.com"  # 反代时配置;默认 ws://host:port

2. 初始化 Runner 仓库

workflowvm setup --config accounts.yml

提示workflowvm serve 启动时也会自动执行初始化检测。

3. 启动服务器

选项 A:直接安装运行

pip install workflowvm
workflowvm serve --config accounts.yml

选项 B:使用 Docker

docker compose up -d

4. SDK 调用示例

from workflowvm import Controller

ctrl = Controller("wss://your-server:8765", token="your-server-api-token")
conn = ctrl.acquire(timeout=120, max_duration=300)

# 访问远端模块
os = conn.modules.os
print(os.system("whoami"))         # 在 GitHub Actions runner 上执行

# 上下文管理器(自动透明)
camoufox = conn.modules.camoufox
with camoufox.SyncCamoufox() as browser:
    page = browser.new_page()
    page.goto("https://example.com")
    print(page.title())

conn.close()

rpyc 的 async_() 包装器可用于处理异步方法:

import rpyc
async_fn = rpyc.async_(browser.some_async_method)
result = async_fn()
result.wait()
value = result.value

架构

SDK (调用方)
  └─ Controller.acquire() → 返回 rpyc.Connection
        └─ 调度服务器 (WebSocket Server + 账号池 + Session 管理)
              └─ 调用 GitHub API (workflow_dispatch)
                    └─ 启动 GitHub Actions Ubuntu runner
                          └─ agent.py → 主动反连服务器,暴露 rpyc SlaveService
SDK ─── WebSocket ──→ Server ─── WebSocket ──→ Agent
       (acquire协商)   (字节隧道)              (rpyc classic SlaveService)
                  ←─── rpyc 协议字节流 ─────────

Server 仅负责 acquire 握手阶段,之后变为纯字节隧道,rpyc 协议端到端运行在 SDK 与 Agent 之间。SDK 通过 rpyc.Connection 直接访问 Agent 的 Python 环境。


CLI 命令参考

命令 功能说明
workflowvm serve --config <file> 启动 WebSocket 调度服务器
workflowvm setup --config <file> 初始化并验证所有 Runner 仓库状态
workflowvm-agent --server <url> --token <tok> --duration <sec> 在 Runner 内运行 Agent(通常由 GitHub Workflow 自动执行)

安全说明

rpyc classic 模式暴露完整 Python 环境(任意代码执行)。WorkflowVM 的使用场景是一次性 GitHub Actions Runner,这是可接受的——用户本来就完全控制 runner 环境。生产部署中,api_token 是唯一访问控制,请妥善保管。


测试

pip install -e ".[dev]"
pytest tests/ -v

Linux DO

LINUX DO

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

workflowvm-0.3.2.tar.gz (21.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

workflowvm-0.3.2-py3-none-any.whl (19.7 kB view details)

Uploaded Python 3

File details

Details for the file workflowvm-0.3.2.tar.gz.

File metadata

  • Download URL: workflowvm-0.3.2.tar.gz
  • Upload date:
  • Size: 21.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for workflowvm-0.3.2.tar.gz
Algorithm Hash digest
SHA256 f6f66f02571c0080a543294960667954d0db0dfab829aee7434e7f503df5f5e6
MD5 f9f13a6f2dd339de413382b6dd088df4
BLAKE2b-256 ea2d8ff87f9c32c6b02ffeff74c48d25ec77597930d2de1af50a12e9bbca72a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for workflowvm-0.3.2.tar.gz:

Publisher: release.yml on gitpetyr/workflowVM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file workflowvm-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: workflowvm-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 19.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for workflowvm-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 46392d94f001f25b0a56281bc0fd2aa8cfb0da42fcf4d3dfd5dcf1b58b4abb6f
MD5 034f01cdba94a8606ad55e474bcdbac0
BLAKE2b-256 8f2057f6698daca36ad74fb437f6ba22e5b2a017b4a9a885ae442c8a81704c8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for workflowvm-0.3.2-py3-none-any.whl:

Publisher: release.yml on gitpetyr/workflowVM

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page