Skip to content

ci: 复用构建缓存并避免 master 合并后重复运行 CI - #34

Merged
LangLang03 merged 1 commit into
masterfrom
dev
Sep 23, 2026
Merged

LangLang03 merged 1 commit into
masterfrom
dev

Conversation

@LangLang03

@LangLang03 LangLang03 commented Sep 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

合并版本更新到受保护的 master 时,同一个变更已在 dev 通过 CI,却又同时启动完整 CI 和 Release。Android CI 与 Release 还把“生成 HuxerUI 依赖图”交给 huxerui build android --profile debug;该命令会先完整构建 Debug APK,再由工作流运行 Gradle。上次 dev CI 中,这一步耗时约 4 分 46 秒;CI 后续的 Debug 构建多数任务已是 up-to-date,但 Release 仍会额外构建一次 Debug 变体。

本 PR 让自动 CI 只监听 dev,master 保留按版本文件变化触发的 Release;用共用脚本执行 HuxerUI 的仅生成依赖图 CMake 配置,再由各工作流只构建其需要的 Android 变体。原生测试使用 ccache;Gradle 的现有 setup-gradle 缓存允许 dev 写入,并让 CI 与 Release 的 Gradle 命令启用构建缓存。

User-visible behavior

应用界面和 APK 版本不变。合入后的工作流行为:

  • 推送到 dev:运行 C++ 测试和 Android lint/Debug APK;后续提交可复用 ccache 与 Gradle 缓存。
  • PR 合并到 master:不再重复运行完整 CI;若合并包含 platform/android/app/build.gradle 的版本变更,仍按原条件运行签名 Release。
  • Android CI 与 Release:只生成 Gradle 所需的 HuxerUI 依赖图,不会为了生成图先额外构建一次 Debug APK。

GitHub Actions 缓存有分支作用域:master 的缓存可供 dev 读取,dev 写入的缓存不能直接由 master 读取。因此这里让两个长期分支各自维护可复用的缓存,而不依赖无法命中的跨分支缓存。

Screenshots or recordings

仅修改工作流与构建脚本,没有界面变化;不适用。

Validation

  • GoogleTest suite passes with Ninja and -j8:本次远端 dev CI 已通过。
  • Fake AI server tests pass:本次远端 dev CI 已通过。
  • Android lint passes:本地和远端 :app:lintDebug 均成功。
  • Android debug build succeeds:本地和远端 :app:assembleDebug --build-cache 均成功;远端构建有 4 个任务命中缓存,并上传 Debug APK。
  • Verified on a device or emulator, or explained why this is not applicable:仅构建工作流变更,无设备端行为变化。

Commands and environment used:

HUXERUI_HOME=/home/LangLang/.local/share/HuxerUI \
  bash tools/generate_android_library_graph.sh
  -> CMake configure successful; graph contains SQLite and WebView

HUXERUI_HOME=/home/LangLang/.local/share/HuxerUI \
  ./platform/android/gradlew -p platform/android \
  :app:lintDebug :app:assembleDebug --build-cache --offline \
  --no-daemon --max-workers=8 --console=plain
  -> BUILD SUCCESSFUL; 1 task from cache

bash -n tools/generate_android_library_graph.sh
git diff --check
  -> both clean

两份 workflow 已用 YAML 解析核对:CI 只监听 dev,Release 只监听 master 的版本文件变更,两边都调用共用依赖图脚本。本次远端 dev CI 的 C++ 与 Android 作业均通过。首次运行写入了 ccache-gcc16.2-Linux-... 与 Gradle 的缓存条目;C++ 449 次可缓存编译调用中有 161 次命中。此 PR 不更改版本文件,因此单独合入不会触发一次新发布;1.3.1 Release 已成功完成。

Design and safety checklist

  • The change keeps domain, application, infrastructure, platform, and presentation responsibilities separated. 应用代码未变。
  • New behavior is behind an abstraction or data-driven descriptor where extension is expected; it does not grow a UI if chain. 两个工作流共用一份依赖图脚本。
  • New or changed behavior has GoogleTest coverage. 本次仅修改工作流;缓存与触发条件由工作流自身验证,没有对应的 GoogleTest。
  • No credential, signing key, personal data, generated build output, or incompatible third-party code is included.
  • User-facing text is available in both English and Chinese where applicable. 无新增界面文案。
  • UI changes preserve the intended LineCode behavior and have been visually checked. 无 UI 改动。

CLA — required

CLA Signature: @LangLang03

@sourcery-ai

sourcery-ai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

审查者指南

本 PR 调整 GitHub Actions 触发范围,避免 master 合并后的重复 CI;通过共用的 configure-only 脚本生成 HuxerUI Android 依赖图,并为 C++ 与 Gradle 构建启用可写、可复用缓存,同时保持应用和 APK 版本行为不变。

文件级变更

变更 详细信息 文件
将自动 CI 限制在 dev,并保留 master 上按版本变更触发的 Release,避免合并后重复执行完整 CI。
  • 移除 master 的 CI push 触发,仅监听 dev。
  • 保持 Release 仅由 master 上版本文件变化触发。
.github/workflows/ci.yml
.github/workflows/release.yml
引入共用的仅配置 CMake 脚本生成 HuxerUI Android 依赖图,避免为生成依赖图额外构建 Debug APK。
  • 新增脚本执行 configure-only 模式并校验 libraries.json 非空。
  • CI 与 Release 改为调用共用脚本。
tools/generate_android_library_graph.sh
.github/workflows/ci.yml
.github/workflows/release.yml
为原生编译和 Gradle 构建启用可复用缓存。
  • 安装并配置 ccache,使用 actions/cache 恢复编译缓存并输出统计信息。
  • 允许 dev 与 master 的 Gradle setup-gradle 缓存写回,并为 Android 构建命令启用 --build-cache。
.github/workflows/ci.yml
.github/workflows/release.yml

提示与命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以使用 @sourcery-ai issue 回复审查评论,以便根据该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置输入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以便随时(重新)生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中你希望插入摘要的位置输入 @sourcery-ai summary,即可随时在该位置生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以便随时(重新)生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论,不想再看到它们,这项功能会很有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从头开始新的审查,这项功能尤其有用——别忘了评论 @sourcery-ai review 以触发新的审查!

自定义使用体验

访问你的控制面板:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

本 PR 调整 GitHub Actions 触发范围,避免 master 合并后的重复 CI;通过共用的 configure-only 脚本生成 HuxerUI Android 依赖图,并为 C++ 与 Gradle 构建启用可写、可复用缓存,同时保持应用和 APK 版本行为不变。

File-Level Changes

Change Details Files
将自动 CI 限制在 dev,并保留 master 上按版本变更触发的 Release,避免合并后重复执行完整 CI。
  • 移除 master 的 CI push 触发,仅监听 dev。
  • 保持 Release 仅由 master 上版本文件变化触发。
.github/workflows/ci.yml
.github/workflows/release.yml
引入共用的仅配置 CMake 脚本生成 HuxerUI Android 依赖图,避免为生成依赖图额外构建 Debug APK。
  • 新增脚本执行 configure-only 模式并校验 libraries.json 非空。
  • CI 与 Release 改为调用共用脚本。
tools/generate_android_library_graph.sh
.github/workflows/ci.yml
.github/workflows/release.yml
为原生编译和 Gradle 构建启用可复用缓存。
  • 安装并配置 ccache,使用 actions/cache 恢复编译缓存并输出统计信息。
  • 允许 dev 与 master 的 Gradle setup-gradle 缓存写回,并为 Android 构建命令启用 --build-cache。
.github/workflows/ci.yml
.github/workflows/release.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

嘿——我已经审阅了你的更改,整体看起来很棒!

Sourcery 评估

需要人工审阅。 如果工作流或构建缓存的更改存在问题,合并到 master 时可能会跳过预期的 CI 检查,或者构建可能会使用不正确的缓存/生成结果。回滚可以恢复之前的工作流行为,任何受影响的缓存也可以清除或重新构建,因此后果是有限且可修复的。


Sourcery 对开源项目免费——如果你喜欢我们的审阅,请考虑分享 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Needs a human reviewer. If the workflow or build-cache changes are wrong, master merges may skip the intended CI check or a build may use an incorrect cached/generated result. Reverting restores the previous workflow behavior, and any affected caches can be cleared or rebuilt, so the consequences are bounded and repairable.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@LangLang03
LangLang03 merged commit a12b77b into master Sep 23, 2026
7 checks passed
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