Feature/editor optimization (#251)

* refactor: 编辑器/运行时架构拆分与构建系统升级

* feat(core): 层级系统重构与UI变换矩阵修复

* refactor: 移除 ecs-components 聚合包并修复跨包组件查找问题

* fix(physics): 修复跨包组件类引用问题

* feat: 统一运行时架构与浏览器运行支持

* feat(asset): 实现浏览器运行时资产加载系统

* fix: 修复文档、CodeQL安全问题和CI类型检查错误

* fix: 修复文档、CodeQL安全问题和CI类型检查错误

* fix: 修复文档、CodeQL安全问题、CI类型检查和测试错误

* test: 补齐核心模块测试用例,修复CI构建配置

* fix: 修复测试用例中的类型错误和断言问题

* fix: 修复 turbo build:npm 任务的依赖顺序问题

* fix: 修复 CI 构建错误并优化构建性能
This commit is contained in:
YHH
2025-12-01 22:28:51 +08:00
committed by GitHub
parent 189714c727
commit b42a7b4e43
468 changed files with 18301 additions and 9075 deletions

View File

@@ -8,6 +8,7 @@ on:
- 'package.json'
- 'pnpm-lock.yaml'
- 'tsconfig.json'
- 'turbo.json'
- 'jest.config.*'
- '.github/workflows/ci.yml'
pull_request:
@@ -17,11 +18,12 @@ on:
- 'package.json'
- 'pnpm-lock.yaml'
- 'tsconfig.json'
- 'turbo.json'
- 'jest.config.*'
- '.github/workflows/ci.yml'
jobs:
test:
ci:
runs-on: ubuntu-latest
steps:
@@ -39,22 +41,47 @@ jobs:
node-version: '20.x'
cache: 'pnpm'
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
# 缓存 Rust 编译结果
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
workspaces: packages/engine
cache-on-failure: true
# 缓存 wasm-pack
- name: Cache wasm-pack
uses: actions/cache@v4
with:
path: ~/.cargo/bin/wasm-pack
key: wasm-pack-${{ runner.os }}
- name: Install wasm-pack
run: |
if ! command -v wasm-pack &> /dev/null; then
cargo install wasm-pack
fi
- name: Install dependencies
run: pnpm install
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
# 缓存 Turbo
- name: Cache Turbo
uses: actions/cache@v4
with:
path: .turbo
key: turbo-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
turbo-${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }}-
turbo-${{ runner.os }}-
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Build core package first
run: pnpm run build:core
- name: Build engine WASM package
run: |
cd packages/engine
pnpm run build
# 构建所有包
- name: Build all packages
run: pnpm run build
- name: Copy WASM files to ecs-engine-bindgen
run: |
@@ -64,30 +91,15 @@ jobs:
cp packages/engine/pkg/es_engine_bg.wasm packages/ecs-engine-bindgen/src/wasm/
cp packages/engine/pkg/es_engine_bg.wasm.d.ts packages/ecs-engine-bindgen/src/wasm/
- name: Build dependent packages for type declarations
run: |
cd packages/platform-common && pnpm run build
cd ../asset-system && pnpm run build
cd ../components && pnpm run build
cd ../editor-core && pnpm run build
cd ../ui && pnpm run build
cd ../editor-runtime && pnpm run build
cd ../behavior-tree && pnpm run build
cd ../tilemap && pnpm run build
cd ../physics-rapier2d && pnpm run build
cd ../node-editor && pnpm run build
cd ../blueprint && pnpm run build
- name: Build ecs-engine-bindgen
run: |
cd packages/ecs-engine-bindgen && pnpm run build
# 类型检查
- name: Type check
run: pnpm run type-check
# Lint 检查
- name: Lint check
run: pnpm run lint
# 测试
- name: Run tests with coverage
run: pnpm run test:ci
@@ -100,39 +112,16 @@ jobs:
name: codecov-umbrella
fail_ci_if_error: false
build:
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build project
run: pnpm run build
- name: Build npm package
# 构建 npm 包
- name: Build npm packages
run: pnpm run build:npm
# 上传构建产物
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts
path: |
bin/
dist/
packages/*/dist/
packages/*/bin/
retention-days: 7

View File

@@ -71,39 +71,13 @@ jobs:
node -e "const pkg=require('./package.json'); pkg.version='${{ github.event.inputs.version }}'; require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2)+'\n')"
node scripts/sync-version.js
# ===== 第一层:基础包(无依赖) =====
- name: Build core package
run: pnpm run build:core
- name: Build math package
run: |
cd packages/math
pnpm run build
- name: Build platform-common package
run: |
cd packages/platform-common
pnpm run build
# ===== 第二层:依赖 core 的包 =====
- name: Build asset-system package
run: |
cd packages/asset-system
pnpm run build
- name: Build components package
run: |
cd packages/components
pnpm run build
# ===== 第三层Rust WASM 引擎 =====
- name: Install wasm-pack
run: cargo install wasm-pack
- name: Build engine package (Rust WASM)
run: |
cd packages/engine
pnpm run build
# 使用 Turborepo 自动按依赖顺序构建所有包
# 这会自动处理core -> asset-system -> editor-core -> ui -> 等等
- name: Build all packages with Turborepo
run: pnpm run build
- name: Copy WASM files to ecs-engine-bindgen
shell: bash
@@ -114,60 +88,6 @@ jobs:
cp packages/engine/pkg/es_engine_bg.wasm packages/ecs-engine-bindgen/src/wasm/
cp packages/engine/pkg/es_engine_bg.wasm.d.ts packages/ecs-engine-bindgen/src/wasm/
- name: Build ecs-engine-bindgen package
run: |
cd packages/ecs-engine-bindgen
pnpm run build
# ===== 第四层:依赖 ecs-engine-bindgen/asset-system 的包 =====
- name: Build editor-core package
run: |
cd packages/editor-core
pnpm run build
# ===== 第五层:依赖 editor-core 的包 =====
- name: Build UI package
run: |
cd packages/ui
pnpm run build
- name: Build tilemap package
run: |
cd packages/tilemap
pnpm run build
- name: Build editor-runtime package
run: |
cd packages/editor-runtime
pnpm run build
- name: Build node-editor package
run: |
cd packages/node-editor
pnpm run build
# ===== 第六层:依赖 editor-runtime 的包 =====
- name: Build behavior-tree package
run: |
cd packages/behavior-tree
pnpm run build
- name: Build physics-rapier2d package
run: |
cd packages/physics-rapier2d
pnpm run build
- name: Build blueprint package
run: |
cd packages/blueprint
pnpm run build
# ===== 第七层:平台包(依赖 ui, tilemap, behavior-tree, physics-rapier2d =====
- name: Build platform-web package
run: |
cd packages/platform-web
pnpm run build
- name: Bundle runtime files for Tauri
run: |
cd packages/editor-app
@@ -220,16 +140,16 @@ jobs:
delete-branch: true
title: "chore(editor): Release v${{ github.event.inputs.version }}"
body: |
## 🚀 Release v${{ github.event.inputs.version }}
## Release v${{ github.event.inputs.version }}
This PR updates the editor version after successful release build.
### Changes
- Updated `packages/editor-app/package.json` → `${{ github.event.inputs.version }}`
- Updated `packages/editor-app/src-tauri/tauri.conf.json` → `${{ github.event.inputs.version }}`
- Updated `packages/editor-app/package.json` → `${{ github.event.inputs.version }}`
- Updated `packages/editor-app/src-tauri/tauri.conf.json` → `${{ github.event.inputs.version }}`
### Release
- 📦 [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/editor-v${{ github.event.inputs.version }})
- [GitHub Release](https://github.com/${{ github.repository }}/releases/tag/editor-v${{ github.event.inputs.version }})
---
*This PR was automatically created by the release workflow.*