Skip to content

[codex] Support DataToolkit project header actions #114

[codex] Support DataToolkit project header actions

[codex] Support DataToolkit project header actions #114

Workflow file for this run

# ZeroEngine 单元测试 CI
# 在每次 Push 和 PR 时运行 EditMode 测试
#
# ⚠️ 前置条件:需要在 GitHub 仓库设置中配置以下 Secrets:
# - UNITY_LICENSE: Unity 许可证文件内容 (.ulf)
# - UNITY_EMAIL: Unity 账号邮箱
# - UNITY_PASSWORD: Unity 账号密码
#
# 获取许可证: https://game.ci/docs/github/activation
name: Unity Tests
on:
push:
branches: [main, develop]
paths:
- 'com.zerogamestudio.zeroengine*/**'
- '.github/workflows/tests.yml'
pull_request:
branches: [main, develop]
paths:
- 'com.zerogamestudio.zeroengine*/**'
- '.github/workflows/tests.yml'
# 允许手动触发
workflow_dispatch:
# 需要写权限来发布测试报告
permissions:
contents: read
checks: write
pull-requests: write
jobs:
test:
name: Run Unity Tests
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: true
# 创建最小 Unity 项目结构,将包作为本地包引用
- name: Setup Unity Project
run: |
mkdir -p TestProject/Assets
mkdir -p TestProject/Packages
mkdir -p TestProject/ProjectSettings
# 复制包到 TestProject/Packages(避免符号链接在 Docker 中失效)
for pkg in com.zerogamestudio.zeroengine*; do
if [ -d "$pkg" ]; then
cp -r "$pkg" "TestProject/Packages/"
fi
done
# 构建 manifest.json,使用 file: 引用本地包
DEPS='"com.unity.test-framework": "1.3.9"'
# 添加必需的 Unity 模块
DEPS="$DEPS, \"com.unity.modules.physics\": \"1.0.0\""
DEPS="$DEPS, \"com.unity.modules.physics2d\": \"1.0.0\""
DEPS="$DEPS, \"com.unity.modules.ai\": \"1.0.0\""
DEPS="$DEPS, \"com.unity.modules.animation\": \"1.0.0\""
DEPS="$DEPS, \"com.unity.modules.audio\": \"1.0.0\""
DEPS="$DEPS, \"com.unity.modules.imgui\": \"1.0.0\""
DEPS="$DEPS, \"com.unity.modules.ui\": \"1.0.0\""
DEPS="$DEPS, \"com.unity.modules.particlesystem\": \"1.0.0\""
DEPS="$DEPS, \"com.unity.modules.tilemap\": \"1.0.0\""
for pkg in TestProject/Packages/com.zerogamestudio.zeroengine*; do
if [ -d "$pkg" ]; then
PKG_NAME=$(basename "$pkg")
DEPS="$DEPS, \"$PKG_NAME\": \"file:$PKG_NAME\""
fi
done
cat > TestProject/Packages/manifest.json << EOF
{
"dependencies": {
$DEPS
},
"testables": [
"com.zerogamestudio.zeroengine"
]
}
EOF
# 创建 ProjectSettings
cat > TestProject/ProjectSettings/ProjectVersion.txt << 'EOF'
m_EditorVersion: 2022.3.62f1
EOF
- name: Cache Unity Library
uses: actions/cache@v4
with:
path: TestProject/Library
key: Library-${{ hashFiles('com.zerogamestudio.zeroengine*/package.json') }}
restore-keys: |
Library-
# 使用 GameCI Unity Test Runner
- name: Run EditMode Tests
uses: game-ci/unity-test-runner@v4
id: testRunner
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
with:
unityVersion: 2022.3.62f1
projectPath: TestProject
testMode: EditMode
artifactsPath: TestResults
checkName: EditMode Test Results
- name: Upload Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: Test Results
path: TestResults
if-no-files-found: warn
retention-days: 14
- name: Publish Test Report
uses: EnricoMi/publish-unit-test-result-action@v2
if: always()
with:
files: TestResults/*.xml
check_name: Unity Test Report