Skip to content

ci: reclaim extracted dependencies between tidy checks - #2698

Merged
liuzengh merged 1 commit into
trpc-group:mainfrom
bytethm:fix/ci-tidy-disk-20261028
Oct 28, 2026
Merged

liuzengh merged 1 commit into
trpc-group:mainfrom
bytethm:fix/ci-tidy-disk-20261028

Conversation

@bytethm

@bytethm bytethm commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Reduce disk usage during the repository-wide go mod tidy check by releasing extracted dependency sources between modules. Downloaded archives and Go toolchains remain available for reuse. Clean up the complete temporary workspace on both success and failure.

Why

The tidy check uses a fresh module cache across all modules. Extracted dependency trees accumulate throughout the job; the check in #2687 failed while extracting dependencies with disk quota exceeded.

The script also reused its temporary-root variable for per-module manifest snapshots, so its exit trap no longer referred to the original cache directory. Separate lifetimes for the temporary root and snapshots make cleanup reliable.

Testing

  • Shell syntax checks and git diff --check.
  • The full repository tidy check and cache-cleanup regression passed on GitHub Actions.
  • An automated fixture verifies that extracted sources are removed between modules, archives and toolchains are retained, and a failed tidy preserves its exit status and removes the temporary workspace. The fixture fails against the previous script and runs before the full tidy check in CI.
  • A separate two-module check with real Go 1.25 verified offline archive reuse after extracted sources were removed, unchanged manifests, and cleanup on exit.

Notes for reviewers

This affects CI tooling only. Downloaded archives still accumulate during the job, and a single large module can still exceed available disk space.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between d51b52b and 510303f.

Files selected for processing: 3
  • .github/scripts/check-go-mod-tidy.sh
  • .github/scripts/verify-check-go-mod-tidy-cache.sh
  • .github/workflows/prc.yml

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Summary

English

The tidy check now uses one temporary workspace for the run. After each module check, it removes extracted module sources from GOMODCACHE while retaining download archives and Go toolchains. The workspace trap cleans up on exit. A fixture test checks cache retention and removal, and checks that a simulated go mod tidy failure preserves its exit status and triggers cleanup. The workflow runs this test before the repository-wide tidy check.

Public API and compatibility: No exported Go API changes. The change affects CI behavior only. It does not change module manifests or application interfaces.

Risks: Downloaded archives and toolchains remain in the cache, so total disk use can still grow during the job. A single module may still exceed available disk space. The fixture test does not establish that the full repository check passes on a GitHub runner.

Recommended validation: Run the fixture test, shell syntax checks, and git diff --check. Then run the full repository tidy check on a GitHub runner and confirm it completes within the runner’s disk quota.

中文

概要

整洁性检查现在会为整个运行过程使用一个临时工作区。每个模块检查完成后,脚本会从 GOMODCACHE 中删除已提取的模块源码,同时保留下载归档和 Go 工具链。退出陷阱会清理整个工作区。新增的夹具测试会检查缓存保留与清理行为,并验证模拟的 go mod tidy 失败会保留退出状态且触发清理。工作流会先运行此测试,再执行全仓库整洁性检查。

公共 API 与兼容性: 未更改任何导出的 Go API。此改动仅影响 CI 行为,不更改模块清单或应用接口。

风险: 下载归档和工具链仍会保留,因此任务运行期间的总磁盘用量仍可能增长。单个模块仍可能占满可用磁盘空间。夹具测试不能证明全仓库检查能在 GitHub runner 上通过。

建议验证: 运行夹具测试、Shell 语法检查和 git diff --check。然后在 GitHub runner 上运行全仓库整洁性检查,并确认任务能在 runner 的磁盘配额内完成。

The tidy-check script now uses a shared temporary root and clears extracted module directories from GOMODCACHE after each module check, while preserving downloaded archives and toolchains. A shell test covers cleanup after success and failure. The pull request workflow runs the test before the tidy check.

Changes: Tidy-check cache lifecycle

Layer / File(s) Summary
Temporary module data and cache cleanup
.github/scripts/check-go-mod-tidy.sh
The script stores each module’s temporary copies under a shared root. After each module check, it removes extracted module cache directories while preserving downloads and toolchains. Existing tidy comparisons and error reporting remain unchanged.
Cleanup validation and workflow integration
.github/scripts/verify-check-go-mod-tidy-cache.sh, .github/workflows/prc.yml
The shell test verifies cleanup after successful checks and after a simulated failure. The check-go-mod-tidy job runs the test before checking whether module files are tidy.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Other

Possibly related PRs

Suggested reviewers: flash-lhr, winechord

Merge Risk: Minimal · up to 51030

No actionable merge-blocking risk remains from the reviewed changes.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly summarizes the main CI change: reclaiming extracted dependencies between Go tidy checks.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description states the change: it releases extracted dependency sources between modules during the repository-wide go mod tidy check, keeps archives and toolchains, and cleans up the temporary wor…
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 2 files. (1 skipped: 1 unsupported.)

Full details: Description check

Explanation

The description states the change: it releases extracted dependency sources between modules during the repository-wide go mod tidy check, keeps archives and toolchains, and cleans up the temporary workspace on success and failure. It gives the reason (disk quota exceeded in #2687), explains the separated temporary root and snapshot lifetimes, lists the tests run, and notes limits. It matches the raw summary and the PR objectives.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@codecov

codecov Bot commented Oct 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.25870%. Comparing base (d51b52b) to head (510303f).

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main       #2698         +/-   ##
===================================================
+ Coverage   90.25742%   90.25870%   +0.00128%     
===================================================
  Files           1290        1290                 
  Lines         234322      234322                 
===================================================
+ Hits          211493      211496          +3     
+ Misses         14245       14243          -2     
+ Partials        8584        8583          -1     
Flag Coverage Δ
unittests 90.25870% <ø> (+0.00128%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@liuzengh
liuzengh merged commit 8d16e9b into trpc-group:main Oct 28, 2026
172 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants