Cache saves happen in the post phase of the action. Most developers miss these logs. To capture them:
Would you like a different length or to tailor this for a specific CI system?
name: Build project run: make build
name: Save cache (only if build succeeded) if: steps.cache-restore.outputs.cache-hit != 'true' uses: actions/cache/save@v3 with: path: vendor/bundle key: $ runner.os -gems-$ hashFiles('Gemfile.lock')
For deep issues (like file permissions or path mismatches), use a tool like Action-Debugger debug-action-cache
Is USER or HOSTNAME being sucked into the action?
The most common cause of cache issues is non-determinism. If an action generates different outputs when run twice with the exact same inputs, it breaks the cache model. Cache saves happen in the post phase of the action
Your main branch restores a cache from a feature/x branch. This is bad because feature/x might have experimental dependencies. Solution: Prefix your key with $ github.ref_name . Debug: Check the logs. Does it say Cache restored from key: main-node-abc123 or feature/node-abc123 ?
Your first step is to tell your build system to output exactly what it is doing with the cache. name: Build project run: make build name: Save
No specific math was used. If I had to pick a formula that relates, it could be: $$time节省 = cache命中率 \times 调试动作时间$$
What (Node/NPM, Python, Docker, Go) are you currently trying to cache?