fix: optimize GitHub Actions workflows — fix slow CI (1h 48m) and broken freeze cache - #297
Merged
Merged
Conversation
…ze cache Problems fixed: 1. [P0] quarto-publish-update-cache.yml: Add pre-render all non-frozen QMDs step before babelquarto, so the saved freeze cache is fully populated (~500+ JSON entries) instead of nearly empty. Reduces warm-cache runs from ~1h48m to ~20m. 2. [P0] quarto-publish-update-cache.yml: Fix concurrency group name collision. The nightly had the same group as the main push workflow (which has cancel-in-progress:true), causing nightly builds to be cancelled on every push to main before they could save the cache. 3. [P1] quarto-publish-update-cache.yml: Increase timeout 150 -> 240 minutes to accommodate the new pre-render step on cold cache (first run ~140 min). 4. [P1] quarto-publish-update-cache.yml: Unified cache key prefix to freeze-<OS>-nightly- so both main and nightly workflows share the same pool. Use weekly date key to cap cache growth (~7 entries per week max). Fix restore primary key to use run_id (not sha) for stable matching. 5. [P2] quarto-publish.yml: Exclude **/*.zh.qmd from push trigger paths-ignore to prevent auto-translate PRs (touching only .zh.qmd) from triggering a full 2+ hour site rebuild. Agent-Logs-Url: https://github.com/openbiox/Bizard/sessions/21837366-bf38-48eb-87a5-49e1981f4b5f Co-authored-by: ShixiangWang <25057508+ShixiangWang@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
ShixiangWang
May 8, 2026 06:58
View session
Contributor
✅ QMD Format CheckNo new QMD tutorial files to check.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题背景
Github Pageworkflow 中 "Pre-render all non-frozen QMD files" 步骤耗时 1h 48m,整个 CI 运行超过 2 小时。经根因分析,共发现 5 个相互关联的 workflow 配置问题。根本原因分析
核心问题:nightly 保存的 freeze 缓存几乎为空
babelquarto::render_website()在临时目录(withr::local_tempdir())中渲染,在那里生成_freeze,然后只把_site复制回工作区,临时目录(及其_freeze)被丢弃。因此 nightly workflow 调用 babelquarto 后,工作区_freeze几乎没有任何 R 文件的输出,保存的缓存无效。当 main workflow 恢复了这个无效缓存后,仍需从头重新渲染所有 60+ 个 R QMD 文件,耗时 1h 48m。修复内容
P0:
quarto-publish-update-cache.yml— 添加 Pre-render 步骤(根本修复)在 nightly 调用 babelquarto 之前,加入与 main workflow 相同的 "Pre-render all non-frozen QMD files" 步骤,将所有 R QMD 的输出写入工作区
_freeze。这样:P0:
quarto-publish-update-cache.yml— 修复并发组名称冲突原 nightly 并发组为
quarto-build-Github Page-refs/heads/main,与 main workflow 的并发组完全相同。main workflow 设置了cancel-in-progress: true,导致每次有 PR 合并到 main,正在运行的 nightly 就会被取消,缓存无法保存。修复:将 nightly 并发组改为独立名称
quarto-build-nightly-cache-update。P1:
quarto-publish-update-cache.yml— 增加 timeout 到 240 分钟首次冷启动加入 pre-render 步骤后,总耗时约 140 min(Julia setup + pre-render ~80 min + babelquarto ~20 min + 其他 ~40 min)。原 150 min timeout 已不够。
P1:
quarto-publish-update-cache.yml— 统一缓存键前缀,限制缓存增长github.sha(每次 commit 都变化,从不命中),改用run_id-run_attempt确保同一 run 的 retry 能直接命中自己的缓存freeze-<OS>-nightly-前缀,使 main workflow 的restore-keys: freeze-<OS>-能稳定匹配YYYY-WNN)每周最多创建 ~7 条缓存条目,旧条目在 7 天未使用后被 GitHub 自动清除P2:
quarto-publish.yml— 排除.zh.qmd文件触发自动翻译 PR 只修改
.zh.qmd文件,但仍会触发完整 2+ 小时站点构建。在 push 触发的paths-ignore中加入**/*.zh.qmd可避免此类不必要的构建。预期效果