Skip to content

ci(build): 添加CI/CD工作流并修复包依赖配置#247

Merged
GeWuYou merged 2 commits intomainfrom
ci/cicd-workflow
Apr 17, 2026
Merged

ci(build): 添加CI/CD工作流并修复包依赖配置#247
GeWuYou merged 2 commits intomainfrom
ci/cicd-workflow

Conversation

@GeWuYou
Copy link
Copy Markdown
Owner

@GeWuYou GeWuYou commented Apr 17, 2026

  • 配置CI工作流支持PR时执行代码质量检查、构建和测试
  • 设置发布工作流支持标签推送时自动打包发布到NuGet和GitHub Packages
  • 修复源代码生成器项目的包依赖配置,统一使用GFramework.SourceGenerators.Common命名
  • 配置多版本.NET SDK支持及相应的缓存策略
  • 实现并行测试执行和统一的测试报告生成机制
  • 添加安全扫描和代码质量检查集成

Summary by CodeRabbit

发布说明

  • 改进与优化
    • 强化了持续集成流程的错误检测与失败上报,构建与测试更可靠
    • 优化了测试执行与并发控制,能更准确汇总并返回测试结果状态
    • 引入包产物校验步骤,确保生成的发布包集合准确且完整

- 配置CI工作流支持PR时执行代码质量检查、构建和测试
- 设置发布工作流支持标签推送时自动打包发布到NuGet和GitHub Packages
- 修复源代码生成器项目的包依赖配置,统一使用GFramework.SourceGenerators.Common命名
- 配置多版本.NET SDK支持及相应的缓存策略
- 实现并行测试执行和统一的测试报告生成机制
- 添加安全扫描和代码质量检查集成
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 17, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4e9c260d-4ac9-4699-8f5f-9c3bf05808e9

📥 Commits

Reviewing files that changed from the base of the PR and between 7296eda and cfa4957.

📒 Files selected for processing (1)
  • .github/workflows/ci.yml
📜 Recent review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build and Test
  • GitHub Check: Code Quality & Security
  • GitHub Check: Analyze (C#)
  • GitHub Check: submit-nuget
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests

Applied to files:

  • .github/workflows/ci.yml
🔇 Additional comments (3)
.github/workflows/ci.yml (3)

120-120: 显式对 GFramework.sln 执行 restore/build 的改动是正确的。

这能避免默认项目发现带来的不确定性,CI 行为更稳定可预期。

Also applies to: 145-145


150-186: 并行测试 + 失败聚合输出的实现合理。

当前实现会等待所有测试完成并统一汇总失败状态,同时不提前中断后续报告步骤,流程设计清晰。


228-230: 将最终失败判定后置到报告步骤之后是正确的。

这个收口步骤能确保测试报告先发布,再用统一状态让 Job 失败,符合 CI 可观测性预期。


📝 Walkthrough

Walkthrough

更新 CI 和发布工作流以显式针对 GFramework.sln 执行 restore/build/pack;将 CI 中并行测试的硬编码调用替换为循环并聚合失败状态;发布流程新增对生成的 .nupkg 列表的验证;以及更新源生成器项目的 NuGet 打包输入路径。

Changes

Cohort / File(s) Summary
CI 工作流变更
.github/workflows/ci.yml
dotnet restore / dotnet build 限定为 GFramework.sln;将并行测试的硬编码 dotnet test 调用改为对显式测试项目列表的 shell 循环;引入 set -euo pipefail、PID 跟踪与确定性等待、聚合 failed 标志并通过 GITHUB_OUTPUT 导出,最终步骤根据该标志决定 job 失败与否。
发布(pack)工作流增强
.github/workflows/publish.yml
dotnet restore / dotnet pack 指向 GFramework.sln;新增“Validate packed modules”步骤,枚举 ./packages 下的 .nupkg、规范化为包 ID 并与固定期望列表做差异比较,差异则失败。
源生成器打包配置
GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
调整 NuGet 打包输入:将原先以 $(AssemblyName).Common.dll(及 .xml)打包的项替换为显式 GFramework.SourceGenerators.Common.dll(及 .xml),影响 analyzers/dotnet/cslib/netstandard2.0 两个包路径条目。

Sequence Diagram(s)

(无 — 本次变更为 CI/打包工作流与 csproj 打包配置调整,未引入需绘制的多组件新控制流)

代码审查工作量估算

🎯 3 (中等复杂度) | ⏱️ ~20 分钟

可能相关的PR

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题用中文表述了CI/CD工作流配置和包依赖修复,与changeset中的CI工作流更新、发布工作流配置和源代码生成器项目包依赖修复相符,准确概括了主要变更内容。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/cicd-workflow

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/ci.yml:
- Around line 151-184: The script currently exits early with exit "$failed" at
the end of the test loop which short-circuits downstream report steps; instead,
do not call exit in this script—capture the exit state in the failed variable
and publish it as the step output (use the failed variable name and the test
loop that builds pids/test_projects) so downstream steps always run and
TRX/./ctrf/*.json are produced; then add a separate workflow step after the
report generation (e.g., "Fail if any test project failed") that uses if:
always() && steps.<this-test-step-id>.outputs.failed == '1' and exits 1 to fail
the job only after reports are published.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cbb889ee-f83d-4b9e-a16f-ff4c23149642

📥 Commits

Reviewing files that changed from the base of the PR and between c721c5a and 7296eda.

📒 Files selected for processing (3)
  • .github/workflows/ci.yml
  • .github/workflows/publish.yml
  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📜 Review details
⏰ Context from checks skipped due to timeout of 900000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Analyze (C#)
  • GitHub Check: Build and Test
  • GitHub Check: Code Quality & Security
  • GitHub Check: submit-nuget
🧰 Additional context used
📓 Path-based instructions (1)
**/*.csproj

📄 CodeRabbit inference engine (AGENTS.md)

**/*.csproj: Follow the repository defaults with ImplicitUsings disabled, Nullable enabled, GenerateDocumentationFile enabled for shipped libraries, and LangVersion generally preview in the main libraries and abstractions
Minimize new package dependencies. Add them only when necessary and keep scope narrow

Files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
🧠 Learnings (12)
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : When generator behavior changes intentionally, update snapshots together with the implementation

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.cs : Keep source generators deterministic and free of hidden environment or network dependencies

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Source generator changes MUST be covered by generator tests

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.SourceGenerators.Tests.cs : Preserve snapshot-based verification patterns already used in the repository for source generator tests

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-16T13:25:59.124Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 235
File: GFramework.SourceGenerators.Tests/Rule/ContextAwareGeneratorSnapshotTests.cs:1-3
Timestamp: 2026-04-16T13:25:59.124Z
Learning: In the GeWuYou/GFramework repository, the test project `GFramework.SourceGenerators.Tests` provides `global using NUnit.Framework;` via its `GlobalUsings.cs`. Do not flag missing `using NUnit.Framework;` directives in test files within this project, as the global using already covers it. The project-wide GlobalUsings.cs pattern is used broadly to supply common namespaces (including NUnit, System.IO, etc.) without per-file imports.

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Public API changes must be covered by unit or integration tests

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
  • .github/workflows/ci.yml
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.csproj : Minimize new package dependencies. Add them only when necessary and keep scope narrow

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-16T11:55:23.931Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.931Z
Learning: Applies to **/*.csproj : Follow the repository defaults with `ImplicitUsings` disabled, `Nullable` enabled, `GenerateDocumentationFile` enabled for shipped libraries, and `LangVersion` generally `preview` in the main libraries and abstractions

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-06T12:45:47.739Z
Learnt from: GeWuYou
Repo: GeWuYou/GFramework PR: 190
File: GFramework.Game/Config/GameConfigBootstrap.cs:1-3
Timestamp: 2026-04-06T12:45:47.739Z
Learning: In the GFramework repository (GeWuYou/GFramework), even though `ImplicitUsings` is disabled in the `.csproj` files, the project uses a manual `GlobalUsings.cs` file with `global using` directives to provide common System namespaces (e.g., System, System.Threading, System.Threading.Tasks) project-wide. Do not flag missing System-level `using` imports in C# files within this repository, as they are covered by GlobalUsings.cs.

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Any change to public API, lifecycle semantics, module behavior, or extension points MUST update the related XML docs

Applied to files:

  • GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.cs : Preserve deterministic behavior in registries, lifecycle orchestration, and generated outputs

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2026-04-16T11:55:23.932Z
Learnt from: CR
Repo: GeWuYou/GFramework PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-04-16T11:55:23.932Z
Learning: Applies to **/*.Tests.csproj : Every non-trivial feature, bug fix, or behavior change MUST include tests or an explicit justification for why a test is not practical

Applied to files:

  • .github/workflows/ci.yml
🔇 Additional comments (4)
GFramework.Core.SourceGenerators/GFramework.Core.SourceGenerators.csproj (1)

55-65: 这里的包内依赖名修正是对的。

现在 analyzerslib/netstandard2.0 都统一打包 GFramework.SourceGenerators.Common.*,和其它 SourceGenerators 项目的约定保持一致,也避免了继续产出不存在的 $(AssemblyName).Common.* 文件名。

.github/workflows/publish.yml (2)

55-79: 显式绑定到 GFramework.sln 很好。

这里把 restore/pack 都收敛到解决方案级别,能避免依赖默认发现逻辑,和 CI 流水线也保持了一致。


81-116: 这个打包结果白名单校验很有价值。

发布前先比对实际产物和预期模块列表,能更早发现漏包、误包或命名漂移,对这次 SourceGenerators 依赖名修复尤其有帮助。

.github/workflows/ci.yml (1)

120-145: 显式用 GFramework.sln 做 restore/build 是个好改动。

这样 CI 不会再依赖默认项目发现,行为更稳定,也更符合这个仓库的多项目结构。

Comment thread .github/workflows/ci.yml Outdated
- 为测试步骤添加id标识以便后续引用
- 将测试失败状态通过GITHUB_OUTPUT传递给后续步骤
- 添加失败检查步骤确保测试失败时工作流正确终止
- 优化了错误状态的传递机制
@GeWuYou GeWuYou merged commit 6b4631e into main Apr 17, 2026
6 checks passed
@GeWuYou GeWuYou deleted the ci/cicd-workflow branch April 17, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant