mirror of
https://github.com/GeWuYou/GFramework.git
synced 2026-05-13 06:04:30 +08:00
feat(ci): 添加CI/CD工作流配置文件
- 配置pull request触发的构建和测试流程 - 集成代码质量检查和安全扫描功能 - 设置.NET多版本SDK环境支持 - 配置NuGet包和dotnet工具缓存优化 - 实现Node.js和Bun运行时环境搭建 - 添加配置工具依赖安装和测试执行 - 配置项目构建和单元测试执行流程 - 集成测试报告生成和发布功能 - 实现失败测试项目的错误处理机制
This commit is contained in:
parent
5cb5a2270b
commit
1145f455f3
38
.github/workflows/ci.yml
vendored
38
.github/workflows/ci.yml
vendored
@ -159,25 +159,28 @@ jobs:
|
|||||||
"GFramework.SourceGenerators.Tests/GFramework.SourceGenerators.Tests.csproj:sg"
|
"GFramework.SourceGenerators.Tests/GFramework.SourceGenerators.Tests.csproj:sg"
|
||||||
"GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj:cqrs"
|
"GFramework.Cqrs.Tests/GFramework.Cqrs.Tests.csproj:cqrs"
|
||||||
"GFramework.Ecs.Arch.Tests/GFramework.Ecs.Arch.Tests.csproj:ecs-arch"
|
"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"
|
"GFramework.Godot.SourceGenerators.Tests/GFramework.Godot.SourceGenerators.Tests.csproj:godot-sg"
|
||||||
)
|
)
|
||||||
|
|
||||||
failed=0
|
failed=0
|
||||||
failed_projects=()
|
failed_projects=()
|
||||||
|
failed_log_paths=()
|
||||||
|
|
||||||
for entry in "${test_projects[@]}"; do
|
for entry in "${test_projects[@]}"; do
|
||||||
project="${entry%%:*}"
|
project="${entry%%:*}"
|
||||||
name="${entry##*:}"
|
name="${entry##*:}"
|
||||||
|
log_path="TestResults/${name}.console.log"
|
||||||
|
|
||||||
echo "::group::dotnet test $project"
|
echo "::group::dotnet test $project"
|
||||||
if ! dotnet test "$project" \
|
if ! dotnet test "$project" \
|
||||||
-c Release \
|
-c Release \
|
||||||
--no-build \
|
--no-build \
|
||||||
--logger "trx;LogFileName=${name}.trx" \
|
--logger "trx;LogFileName=${name}.trx" \
|
||||||
--results-directory TestResults; then
|
--results-directory TestResults \
|
||||||
|
2>&1 | tee "$log_path"; then
|
||||||
failed=1
|
failed=1
|
||||||
failed_projects+=("$project")
|
failed_projects+=("$project")
|
||||||
|
failed_log_paths+=("$log_path")
|
||||||
echo "::error title=Test project failed::$project returned a non-zero exit code."
|
echo "::error title=Test project failed::$project returned a non-zero exit code."
|
||||||
fi
|
fi
|
||||||
echo "::endgroup::"
|
echo "::endgroup::"
|
||||||
@ -195,8 +198,13 @@ jobs:
|
|||||||
printf '%s\n' "${failed_projects[@]}"
|
printf '%s\n' "${failed_projects[@]}"
|
||||||
fi
|
fi
|
||||||
echo "EOF"
|
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"
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Generate CTRF report
|
- name: Generate CTRF report
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ctrf
|
mkdir -p ctrf
|
||||||
@ -211,6 +219,20 @@ jobs:
|
|||||||
-d ctrf \
|
-d ctrf \
|
||||||
-f "$name.json"
|
-f "$name.json"
|
||||||
done
|
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'
|
if: always() && steps.test_all_projects.outputs.failed == '1'
|
||||||
env:
|
env:
|
||||||
FAILED_PROJECTS: ${{ steps.test_all_projects.outputs.failed_projects }}
|
FAILED_PROJECTS: ${{ steps.test_all_projects.outputs.failed_projects }}
|
||||||
|
FAILED_LOG_PATHS: ${{ steps.test_all_projects.outputs.failed_log_paths }}
|
||||||
run: |
|
run: |
|
||||||
echo "The following test projects returned non-zero exit codes:"
|
echo "The following test projects returned non-zero exit codes:"
|
||||||
printf '%s\n' "$FAILED_PROJECTS"
|
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
|
exit 1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user