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.4.tar.gz (22.6 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.4-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: workflowvm-0.1.4.tar.gz
  • Upload date:
  • Size: 22.6 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.4.tar.gz
Algorithm Hash digest
SHA256 ec7206a8734b25a35a4d2957cb5d3a6d88e1ecd7887c13c636cb9f0b7c67ed5b
MD5 7eb5dce3415e113c405994bd01a94021
BLAKE2b-256 60a53bd1cd1d178eda78203450d912142986f9924dc6db5907cba784e188b531

See more details on using hashes here.

File details

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

File metadata

  • Download URL: workflowvm-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 20.5 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9e32e3d33df7d624520a5f8dde416c4090af2051ae2d0b6e2e27cc217b1c768a
MD5 261e7eeb2932c25bde1d7c5aa23a4662
BLAKE2b-256 80e830f3d464e9a67a94828bc247869e271e6b82ca342bc3cb41062b35f70397

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