* feat(rpc,network): 新增 RPC 库并迁移网络模块 ## @esengine/rpc (新增) - 新增类型安全的 RPC 库,支持 WebSocket 通信 - 新增 RpcClient 类:connect/disconnect, call/send/on/off/once 方法 - 新增 RpcServer 类:Node.js WebSocket 服务端 - 新增编解码系统:支持 JSON 和 MessagePack - 新增 TextEncoder/TextDecoder polyfill,兼容微信小游戏平台 - 新增 WebSocketAdapter 接口,支持跨平台 WebSocket 抽象 ## @esengine/network (重构) - 重构 NetworkService:拆分为 RpcService 基类和 GameNetworkService - 新增 gameProtocol:类型安全的 API 和消息定义 - 新增类型安全便捷方法:sendInput(), onSync(), onSpawn(), onDespawn() - 更新 NetworkPlugin 使用新的服务架构 - 移除 TSRPC 依赖,改用 @esengine/rpc ## 文档 - 新增 RPC 模块文档(中英文) - 更新 Network 模块文档(中英文) - 更新侧边栏导航 * fix(network,cli): 修复 CI 构建和更新 CLI 适配器 ## 修复 - 在 tsconfig.build.json 添加 rpc 引用,修复类型声明生成 ## CLI 更新 - 更新 nodejs 适配器使用新的 @esengine/rpc - 生成的服务器代码使用 RpcServer 替代旧的 GameServer - 添加 ws 和 @types/ws 依赖 - 更新 README 模板中的客户端连接示例 * chore: 添加 CLI changeset * fix(ci): add @esengine/rpc to build and check scripts - Add rpc package to CI build step (must build before network) - Add rpc to type-check:framework, lint:framework, test:ci:framework * fix(rpc,network): fix tsconfig for declaration generation - Remove composite mode from rpc (not needed, causes CI issues) - Remove rpc from network project references (resolves via node_modules) - Remove unused references from network tsconfig.build.json
114 lines
3.1 KiB
YAML
114 lines
3.1 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ master, main, develop ]
|
|
paths:
|
|
- 'packages/**'
|
|
- 'package.json'
|
|
- 'pnpm-lock.yaml'
|
|
- 'tsconfig.json'
|
|
- 'turbo.json'
|
|
- 'jest.config.*'
|
|
- '.github/workflows/ci.yml'
|
|
pull_request:
|
|
branches: [ master, main, develop ]
|
|
# Run on all PRs to satisfy branch protection, but skip build if no code changes
|
|
|
|
jobs:
|
|
# Check if we need to run the full CI
|
|
check-changes:
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
should-run: ${{ steps.filter.outputs.code }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: dorny/paths-filter@v3
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
code:
|
|
- 'packages/**'
|
|
- 'package.json'
|
|
- 'pnpm-lock.yaml'
|
|
- 'tsconfig.json'
|
|
- 'turbo.json'
|
|
- 'jest.config.*'
|
|
|
|
ci:
|
|
needs: check-changes
|
|
if: needs.check-changes.outputs.should-run == 'true'
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
|
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install pnpm
|
|
uses: pnpm/action-setup@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20.x'
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --no-frozen-lockfile
|
|
|
|
# 构建 framework 包 (可独立发布的通用库,无外部依赖)
|
|
- name: Build framework packages
|
|
run: |
|
|
pnpm --filter @esengine/ecs-framework build
|
|
pnpm --filter @esengine/ecs-framework-math build
|
|
pnpm --filter @esengine/behavior-tree build
|
|
pnpm --filter @esengine/blueprint build
|
|
pnpm --filter @esengine/fsm build
|
|
pnpm --filter @esengine/timer build
|
|
pnpm --filter @esengine/spatial build
|
|
pnpm --filter @esengine/procgen build
|
|
pnpm --filter @esengine/pathfinding build
|
|
pnpm --filter @esengine/network-protocols build
|
|
pnpm --filter @esengine/rpc build
|
|
pnpm --filter @esengine/network build
|
|
|
|
# 类型检查 (仅 framework 包)
|
|
- name: Type check (framework packages)
|
|
run: pnpm run type-check:framework
|
|
|
|
# Lint 检查 (仅 framework 包)
|
|
- name: Lint check (framework packages)
|
|
run: pnpm run lint:framework
|
|
|
|
# 测试 (仅 framework 包)
|
|
- name: Run tests with coverage
|
|
run: pnpm run test:ci:framework
|
|
|
|
- name: Upload coverage to Codecov
|
|
uses: codecov/codecov-action@v4
|
|
continue-on-error: true
|
|
with:
|
|
file: ./coverage/lcov.info
|
|
flags: unittests
|
|
name: codecov-umbrella
|
|
fail_ci_if_error: false
|
|
|
|
# 构建 npm 包 (core 和 math)
|
|
- name: Build npm packages
|
|
run: |
|
|
pnpm run build:npm:core
|
|
pnpm run build:npm:math
|
|
|
|
# 上传构建产物
|
|
- name: Upload build artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: build-artifacts
|
|
path: |
|
|
packages/framework/**/dist/
|
|
packages/framework/**/bin/
|
|
retention-days: 7
|