Files
greptimedb/.github/ci/cache-policy.md
dennis zhuang cafa744e51 ci: save release and dependency-check Rust caches only on main (#10758)
* ci: save release and dependency-check Rust caches only on main

The macOS and Windows release builds and the dependency check saved Rust
caches on every ref, including tags and PRs. Those caches are unreachable
from other refs and evict main's caches. Save them only on main, and
extend the cache policy test to every workflow and composite action.

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

* ci: correct the macOS rust-cache key comment

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>

---------

Signed-off-by: Dennis Zhuang <killme2008@gmail.com>
2026-11-30 15:36:51 +00:00

2.8 KiB

CI cache policy

Checks, Rust CI, Integration CI, and Nightly CI use one explicit Rust cache per build job. Disable the implicit cache in setup-rust-toolchain when adding an explicit cache: otherwise its independent save policy can write PR-scoped caches even when the explicit cache only saves on main.

Integration CI's existing weekday schedule runs the fuzz builds and suites, including the profile-CI binary and Kafka helper, to populate main caches. To warm these caches manually after deployment, run Integration CI on main with fuzz_profile: all; no internal ci_command marker is required.

Rust CI's existing weekday schedule warms the Windows and RISC-V compilation caches. Nightly CI's existing schedule warms its Windows runtime test caches. A manual Rust CI run on main can warm the compilation caches sooner. These jobs keep their separate keys and existing runner types; no extra warmup job is added. Coverage caches are not warmed by these schedules. PR, merge-group, and non-main manual runs restore caches without saving them. The same applies to Rust build caches in every other workflow and composite action. Release builds save the macOS and Windows caches only from main (the scheduled nightly release or a manual run on main); tag builds restore them. GitHub lets a run restore only caches saved by its own ref or the default branch, so a Rust cache saved by a tag or PR cannot be reused elsewhere and only evicts main's caches. Fuzz binaries still flow to downstream jobs through workflow artifacts on every run; only the persistent binary cache is main-written. Re-running a PR cannot reuse a newly saved PR-specific binary cache under this policy.

Keep helper version variables outside the CARGO* and RUST* prefixes unless they affect the compilation being cached. rust-cache includes those prefixes in its environment hash. Fuzz tool versions remain explicitly included in the fuzz cache keys. Compiler versions, Cargo manifests, flags, OS, and architecture remain part of the existing cache isolation.

This policy reduces duplicate and PR-only writes; it does not guarantee that all build caches fit in the repository quota. Renamed environment variables cause an initial cold restore until main produces the new keys. Existing caches are not deleted by this change. Coverage warming and additional runner capacity are not introduced.

Validate the policy with:

node --test .github/scripts/tests/ci-cache-policy.test.cjs

After deployment, compare the same commit and runner image across repeated runs. Record exact versus fallback restores, archive size, restore/save duration, and compilation duration. Verify main writes the keys consumed by PRs and that no implicit post-action uploads remain. Local policy tests do not establish a runtime speedup or long-term cache hit rate.