Skip to main content

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

Project description

WorkflowVM

将 GitHub Actions 免费 Ubuntu runner 作为可调度 Python 沙盒,通过 WebSocket 远程对象协议从服务器端透明操作远程 Python 环境。

快速开始

1. 配置账号池

编辑 accounts.yml

accounts:
  - username: your-github-username
    token: ghp_YOUR_CLASSIC_PAT  # 需要 repo + workflow scope
    runner_repo: wvm-runner
    max_concurrent: 5

server:
  host: 0.0.0.0
  port: 8765
  api_token: "your-server-api-token"

2. 初始化 runner repo(自动)

workflowvm setup --config accounts.yml

setup 命令会自动为 accounts.yml 中的每个账号创建 runner repo(若不存在)并推送 workflow 文件。workflowvm serve 启动时也会自动执行此初始化。

3. 启动服务器

方式 A:直接安装运行

pip install workflowvm
workflowvm serve --config accounts.yml

方式 B:Docker

mkdir config
cp accounts.yml config/
# 将 docker-compose.yml 中的 OWNER 替换为你的 GitHub 用户名
docker compose up -d

4. 使用 SDK

import sys; sys.path.insert(0, '.')
import workflowvm

ctrl = workflowvm.Controller(
    "wss://your-server:8765",
    token="your-server-api-token",
    config_path="accounts.yml",
)

vm = ctrl.acquire(timeout=120, max_duration=300)

# 透明远程对象操作
vm.os = vm.__import__("os")
print(vm.os.system("whoami"))      # 在 GitHub Actions runner 上执行

f = vm.open("/etc/hostname")
content = f.read()
print(vm._repr(content))           # → 'runner-hostname\n'

vm.release()

Classic PAT 权限

在 GitHub Settings → Developer settings → Personal access tokens → Generate new token (classic) 中勾选:

  • repo - 完整仓库访问
  • workflow - 触发 workflow_dispatch(必需)

架构

SDK (调用方)
  └─ Controller.acquire() → RemoteVM
        └─ 服务器 (WebSocket server + 账号池 + 实例池)
              └─ GitHub API workflow_dispatch
                    └─ GitHub Actions Ubuntu runner
                          └─ agent.py → 反连 WebSocket

测试

pytest tests/ -v

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.2.2.tar.gz (23.3 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.2.2-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: workflowvm-0.2.2.tar.gz
  • Upload date:
  • Size: 23.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for workflowvm-0.2.2.tar.gz
Algorithm Hash digest
SHA256 2641c4ce574eb1021c73870bb4ecacf3212720075a45915b2abcd748dacdc411
MD5 38241dcd9bdbed795c3695686c2694d1
BLAKE2b-256 6e21d7963e10ddeeae283b9f7eb3c031780e502f650b774e96bb9181aa89a4ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workflowvm-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for workflowvm-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eaa58797eddcfc58982655152b80340dd0dee1404da9c000b9b09eeb6f45dcec
MD5 89627f1e3981015b8f944e9346aca62e
BLAKE2b-256 2d2384fe0ae4eeb372159708c9136c1f5064d5d2fab98dd33c3668a9b9025f82

See more details on using hashes here.

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