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