feat(ci): 添加CI/CD工作流配置文件

- 配置pull request触发的构建和测试流程
- 集成代码质量检查和安全扫描功能
- 设置.NET多版本SDK环境支持
- 配置NuGet包和dotnet工具缓存优化
- 实现Node.js和Bun运行时环境搭建
- 添加配置工具依赖安装和测试执行
- 配置项目构建和单元测试执行流程
- 集成测试报告生成和发布功能
- 实现失败测试项目的错误处理机制
This commit is contained in:
GeWuYou 2026-04-18 15:18:37 +08:00
parent 5cb5a2270b
commit 1145f455f3

View File

@ -159,25 +159,28 @@ jobs:
"GFramework.SourceGenerators.Tests/GFramework.SourceGenerators.Tests.csproj:sg"
"GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj:cqrs"
"GFramework.Ecs.Arch.Tests/GFramework.Ecs.Arch.Tests.csproj:ecs-arch"
"GFramework.Godot.Tests/GFramework.Godot.Tests.csproj:godot"
"GFramework.Godot.SourceGenerators.Tests/GFramework.Godot.SourceGenerators.Tests.csproj:godot-sg"
)
failed=0
failed_projects=()
failed_log_paths=()
for entry in "${test_projects[@]}"; do
project="${entry%%:*}"
name="${entry##*:}"
log_path="TestResults/${name}.console.log"
echo "::group::dotnet test $project"
if ! dotnet test "$project" \
-c Release \
--no-build \
--logger "trx;LogFileName=${name}.trx" \
--results-directory TestResults; then
--results-directory TestResults \
2>&1 | tee "$log_path"; then
failed=1
failed_projects+=("$project")
failed_log_paths+=("$log_path")
echo "::error title=Test project failed::$project returned a non-zero exit code."
fi
echo "::endgroup::"
@ -195,8 +198,13 @@ jobs:
printf '%s\n' "${failed_projects[@]}"
fi
echo "EOF"
echo "failed_log_paths<<EOF"
if [ "${#failed_log_paths[@]}" -gt 0 ]; then
printf '%s\n' "${failed_log_paths[@]}"
fi
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Generate CTRF report
run: |
mkdir -p ctrf
@ -211,6 +219,20 @@ jobs:
-d ctrf \
-f "$name.json"
done
- name: Run GFramework.Godot.Tests Diagnostics
if: always()
continue-on-error: true
run: |
mkdir -p TestResults
dotnet test GFramework.Godot.Tests/GFramework.Godot.Tests.csproj \
-c Release \
--no-build \
--blame-crash \
--diag TestResults/godot-testhost-diag.log \
--logger "trx;LogFileName=godot-diagnostic.trx" \
--results-directory TestResults \
2>&1 | tee TestResults/godot-diagnostic.console.log
# 生成并发布测试报告,无论测试成功或失败都会执行
@ -242,7 +264,17 @@ jobs:
if: always() && steps.test_all_projects.outputs.failed == '1'
env:
FAILED_PROJECTS: ${{ steps.test_all_projects.outputs.failed_projects }}
FAILED_LOG_PATHS: ${{ steps.test_all_projects.outputs.failed_log_paths }}
run: |
echo "The following test projects returned non-zero exit codes:"
printf '%s\n' "$FAILED_PROJECTS"
echo
echo "Captured dotnet test output:"
while IFS= read -r log_path; do
if [ -n "$log_path" ] && [ -f "$log_path" ]; then
echo "--- BEGIN $log_path ---"
cat "$log_path"
echo "--- END $log_path ---"
fi
done <<< "$FAILED_LOG_PATHS"
exit 1