From 1145f455f335ebed664e50f9f34c53312d6c5018 Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Sat, 18 Apr 2026 15:18:37 +0800 Subject: [PATCH] =?UTF-8?q?feat(ci):=20=E6=B7=BB=E5=8A=A0CI/CD=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=B5=81=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 配置pull request触发的构建和测试流程 - 集成代码质量检查和安全扫描功能 - 设置.NET多版本SDK环境支持 - 配置NuGet包和dotnet工具缓存优化 - 实现Node.js和Bun运行时环境搭建 - 添加配置工具依赖安装和测试执行 - 配置项目构建和单元测试执行流程 - 集成测试报告生成和发布功能 - 实现失败测试项目的错误处理机制 --- .github/workflows/ci.yml | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c62726a5..963c3e52 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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<> "$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