Skip to content

fix(libkrun-ci): use patches in cache key - #910

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-sop
Jul 22, 2026
Merged

fix(libkrun-ci): use patches in cache key#910
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-sop

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 22, 2026

Copy link
Copy Markdown
Member

Include patch files in libkrun macOS cache key to trigger rebuilds on patch changes

The action.yml composite action now hashes all *.patch files under vendor/libkrun/patches and incorporates the resulting patches_hash into both the cache key and the persistent prefix path. Previously, adding, removing, or modifying patches would not invalidate the cache, causing stale builds to be used.

📊 Macroscope summarized ca6120f. 1 file reviewed, 0 issues evaluated, 0 issues filtered, 0 comments posted

🗂️ Filtered Issues

No issues evaluated.

Summary by CodeRabbit

  • Bug Fixes
    • Improved macOS build caching to detect changes in bundled libkrun patches.
    • Prevented stale cached builds from being reused when the pinned source, build script, or patches change.
    • Preserved existing verification to ensure the required libkrun functionality is available.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The macOS libkrun setup action now hashes patch contents and includes that digest in the generated prefix and GitHub Actions cache key, alongside the pinned commit and build-script hash.

Changes

libkrun cache invalidation

Layer / File(s) Summary
Patch-aware prefix and cache key
.github/actions/setup-libkrun-macos/action.yml
The action computes a deterministic patches_hash, adds it to the generated prefix, exports it as an output, and includes it in the hosted cache key.

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

Possibly related issues

  • gominimal/minimal#902 — Addresses the stale cache problem by including libkrun patch contents in the prefix and cache key.
  • gominimal/inbox#340 — Addresses stale macOS libkrun caches through the new patches_hash.

Suggested reviewers: norrietaylor

Poem

I hashed each patch beneath the moon,
And keyed the cache in tune.
No stale libkrun shall hide,
With commit and script beside.
A bunny hops through builds anew!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description includes a summary, but it is missing the required Testing and Checklist sections from the template. Add a Testing section with commands or evidence, and complete the Checklist items, including docs and BREAKING CHANGE status if applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title is a clear Conventional Commit subject that matches the cache-key change.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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

@twitchyliquid64
twitchyliquid64 enabled auto-merge (squash) July 22, 2026 17:02
# file emits `<hash> <path>`; sort pins a stable order, then a final
# digest folds them into one value. No patches => digest of empty input,
# still deterministic.
patches_hash="$(find vendor/libkrun/patches -name '*.patch' -type f -exec shasum -a 256 {} + 2>/dev/null | sort | shasum -a 256 | cut -d' ' -f1)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High setup-libkrun-macos/action.yml:34

When all carried patches are removed, Git deletes the empty vendor/libkrun/patches directory, so find exits nonzero. Because GitHub Actions' default shell uses -e -o pipefail, the patches_hash assignment aborts the step instead of producing the documented "digest of empty input." The build fails on the exact case this change is supposed to support. Consider guarding the directory, e.g. patches_hash="$([ -d vendor/libkrun/patches ] && find vendor/libkrun/patches -name '*.patch' -type f -exec shasum -a 256 {} + | sort | shasum -a 256 | cut -d' ' -f1 || echo -n | shasum -a 256 | cut -d' ' -f1)".

Suggested change
patches_hash="$(find vendor/libkrun/patches -name '*.patch' -type f -exec shasum -a 256 {} + 2>/dev/null | sort | shasum -a 256 | cut -d' ' -f1)"
patches_hash="$([ -d vendor/libkrun/patches ] && find vendor/libkrun/patches -name '*.patch' -type f -exec shasum -a 256 {} + | sort | shasum -a 256 | cut -d' ' -f1 || echo -n | shasum -a 256 | cut -d' ' -f1)"
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file @.github/actions/setup-libkrun-macos/action.yml around line 34:

When all carried patches are removed, Git deletes the empty `vendor/libkrun/patches` directory, so `find` exits nonzero. Because GitHub Actions' default shell uses `-e -o pipefail`, the `patches_hash` assignment aborts the step instead of producing the documented "digest of empty input." The build fails on the exact case this change is supposed to support. Consider guarding the directory, e.g. `patches_hash="$([ -d vendor/libkrun/patches ] && find vendor/libkrun/patches -name '*.patch' -type f -exec shasum -a 256 {} + | sort | shasum -a 256 | cut -d' ' -f1 || echo -n | shasum -a 256 | cut -d' ' -f1)"`.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/actions/setup-libkrun-macos/action.yml:
- Line 34: Update the patches_hash computation to invoke locale-independent
sorting by setting LC_ALL=C on the sort command. Preserve the existing file
hashing and final digest pipeline while ensuring identical patch sets produce
the same hash across runner locales.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 76a34d99-dd4b-483a-9732-476f3714a6d7

📥 Commits

Reviewing files that changed from the base of the PR and between 6d239bc and ca6120f.

📒 Files selected for processing (1)
  • .github/actions/setup-libkrun-macos/action.yml

# file emits `<hash> <path>`; sort pins a stable order, then a final
# digest folds them into one value. No patches => digest of empty input,
# still deterministic.
patches_hash="$(find vendor/libkrun/patches -name '*.patch' -type f -exec shasum -a 256 {} + 2>/dev/null | sort | shasum -a 256 | cut -d' ' -f1)"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win

Pin the sorting locale for a stable digest.

sort is locale-sensitive, and its ordering feeds the final SHA-256. Different runner locales can therefore produce different patches_hash values for identical patches, causing avoidable cache misses and divergent prefixes. Use LC_ALL=C sort.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/actions/setup-libkrun-macos/action.yml at line 34, Update the
patches_hash computation to invoke locale-independent sorting by setting
LC_ALL=C on the sort command. Preserve the existing file hashing and final
digest pipeline while ensuring identical patch sets produce the same hash across
runner locales.

@twitchyliquid64
twitchyliquid64 merged commit a7094ee into main Jul 22, 2026
29 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/session-sop branch July 22, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants