@@ -211,6 +211,7 @@ runs:
211211 HOST_DIR : ${{ steps.warp-cache-key.outputs.host-dir }}
212212 MATCHED_KEY : ${{ steps.warp-cache-restore.outputs.cache-matched-key }}
213213 COLLECTION : ${{ steps.warp-cache-key.outputs.collection }}
214+ CACHE_MODE : ${{ inputs.warp-cache }}
214215 run : |
215216 set -euo pipefail
216217 mkdir -p "$HOST_DIR"
@@ -228,9 +229,13 @@ runs:
228229 echo "Warp cache hit: ${MATCHED_KEY}"
229230 echo "WARP_CACHE_HIT=${MATCHED_KEY}" >> "$GITHUB_ENV"
230231 fi
231- echo "WARP_CACHE_MB_BEFORE =$(du -sm "$HOST_DIR" | cut -f1)" >> "$GITHUB_ENV"
232+ echo "WARP_CACHE_BYTES_BEFORE =$(du -sb "$HOST_DIR" | cut -f1)" >> "$GITHUB_ENV"
232233
233234 python3 .github/actions/run-package-tests/warp_cache_inventory.py "$HOST_DIR" "Warp cache restored"
235+ if [ "$CACHE_MODE" = "save" ]; then
236+ fingerprint="$(python3 .github/actions/run-package-tests/warp_cache_inventory.py "$HOST_DIR" --fingerprint)"
237+ echo "WARP_CACHE_FINGERPRINT_BEFORE=$fingerprint" >> "$GITHUB_ENV"
238+ fi
234239
235240 - name : Setup wheelhouse registry authentication
236241 if : inputs.wheelhouse-image != ''
@@ -333,15 +338,16 @@ runs:
333338 exit 1
334339 fi
335340
336- # Growth is the coverage signal: it is exactly the kernels this job needed
337- # that the collection did not already hold. Reporting only - no thresholds,
338- # since we have no measured basis for one yet .
341+ # Net growth is a useful coverage signal for missing kernels. The writer
342+ # also fingerprints the tree because recompilation can replace an existing
343+ # artifact without changing the total size .
339344 - name : Report Warp cache growth
340345 if : always() && inputs.warp-cache != ''
341346 id : warp-cache-growth
342347 shell : bash
343348 env :
344349 HOST_DIR : ${{ steps.warp-cache-key.outputs.host-dir }}
350+ CACHE_MODE : ${{ inputs.warp-cache }}
345351 run : |
346352 set -euo pipefail
347353
@@ -351,31 +357,51 @@ runs:
351357 exit 0
352358 fi
353359
354- before="${WARP_CACHE_MB_BEFORE :-0}"
355- after="$(du -sm "$HOST_DIR" | cut -f1)"
360+ before="${WARP_CACHE_BYTES_BEFORE :-0}"
361+ after="$(du -sb "$HOST_DIR" | cut -f1)"
356362 grew=$(( after - before ))
363+ before_mb=$(( before / 1000000 ))
364+ after_mb=$(( after / 1000000 ))
365+ grew_mb=$(( grew / 1000000 ))
357366
358367 if [ "${WARP_CACHE_HIT:-miss}" = "miss" ]; then
359368 verdict="cold run, nothing restored"
360369 elif [ "$grew" -le 0 ]; then
361- verdict="fully covered "
370+ verdict="no net growth "
362371 else
363372 verdict="compiled $(( grew * 100 / (before > 0 ? before : 1) ))% beyond the restored cache"
364373 fi
365374
366- echo "Warp cache: restored ${before } MB, ended at ${after } MB (+${grew } MB) - ${verdict}"
367- echo "🔵 Warp cache: ${before } -> ${after } MB (+${grew }) - ${verdict}" >> "$GITHUB_STEP_SUMMARY"
375+ echo "Warp cache: restored ${before_mb } MB, ended at ${after_mb } MB (+${grew_mb } MB) - ${verdict}"
376+ echo "🔵 Warp cache: ${before_mb } -> ${after_mb } MB (+${grew_mb }) - ${verdict}" >> "$GITHUB_STEP_SUMMARY"
368377 python3 .github/actions/run-package-tests/warp_cache_inventory.py "$HOST_DIR" "Warp cache final"
369378
370379 # Publishing an empty tree would replace a good snapshot with nothing.
371- [ "$after" -lt 1 ] && echo "empty=true" >> "$GITHUB_OUTPUT" || echo "empty=false" >> "$GITHUB_OUTPUT"
380+ if [ -z "$(find "$HOST_DIR" -type f -print -quit)" ]; then
381+ echo "::warning::Warp cache contains no files; skipping publish"
382+ echo "empty=true" >> "$GITHUB_OUTPUT"
383+ echo "changed=false" >> "$GITHUB_OUTPUT"
384+ else
385+ echo "empty=false" >> "$GITHUB_OUTPUT"
386+ if [ "$CACHE_MODE" = "save" ] && [ "${WARP_CACHE_HIT:-miss}" != "miss" ]; then
387+ fingerprint="$(python3 .github/actions/run-package-tests/warp_cache_inventory.py "$HOST_DIR" --fingerprint)"
388+ if [ "$fingerprint" = "${WARP_CACHE_FINGERPRINT_BEFORE:-}" ]; then
389+ echo "Warp cache contents are unchanged; skipping duplicate snapshot"
390+ echo "changed=false" >> "$GITHUB_OUTPUT"
391+ else
392+ echo "changed=true" >> "$GITHUB_OUTPUT"
393+ fi
394+ else
395+ echo "changed=true" >> "$GITHUB_OUTPUT"
396+ fi
397+ fi
372398
373399 # Not success(): the product is compiled kernels, and those stay valid when a
374400 # test assertion fails. Gating on success() let one failing env silently
375401 # discard the whole cache. Cancellation still skips, so a tree Warp was
376402 # mid-write on is never published.
377403 - name : Save Warp kernel cache
378- if : ' !cancelled() && inputs.warp-cache == '' save'' && steps.warp-cache-growth.outputs.empty != '' true'' '
404+ if : ' !cancelled() && inputs.warp-cache == '' save'' && steps.warp-cache-growth.outputs.empty != '' true'' && steps.warp-cache-growth.outputs.changed == '' true '' '
379405 uses : actions/cache/save@v4
380406 with :
381407 path : ${{ steps.warp-cache-key.outputs.host-dir }}
0 commit comments