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.1.3.tar.gz (22.1 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.1.3-py3-none-any.whl (20.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for workflowvm-0.1.3.tar.gz
Algorithm Hash digest
SHA256 11f25d3c50bf98753d0ff88b275c063266510d7a93444f1d67d9766736e06f4b
MD5 2166b952e13ce7bb5ebdaf68463c99ce
BLAKE2b-256 3676e78f1a8bf8ca2d10e8f5a8d1956635f02d2f72f23d44428603de784dc94e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workflowvm-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 20.4 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.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0df69ab2f9912e9c125289be0dbfe2611fdfcca8198ede7891fa55c117bdc683
MD5 20eb0e09abd6cbd6b77ec55dd60ced99
BLAKE2b-256 f26d6e20e3868db1c7b9ed8a568da82dfeec24ec84301ecd56eaa4d0dd3c9f21

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