fix(ci): disable target/ cache for Swift packaging job#314
Conversation
The macos-26 pin in #312 produced byte-identical libmdk_uniffi.a archives because Swatinem/rust-cache restored the previous macos-15 target/ on a cache hit. Its key is (Darwin-arm64, Cargo.lock hash, Rust version), none of which change when we bump the runner image, so the already-compiled libsqlite3-sys and secp256k1-sys object files (tagged sdk=18.5 from the Xcode 16.4 build) got reused as-is. Cargo had no Rust-side reason to recompile them, and the resulting xcframework was indistinguishable from the pre-#312 one. Setting cache-targets: false on the Swatinem step keeps the registry / crate-source cache (cheap; harmless) but forces a clean compile of every crate, so cc-driven C deps are always tagged with the current Xcode SDK. Build time goes from ~1 min (with cache hit) to ~10 min, which is the correct cost for shippable artifacts. Relates to marmot-protocol/mdk-swift#1
|
Ready to review this PR? Stage has broken it down into 2 individual chapters for you:
Chapters generated by Stage for commit 69d5a32 on May 21, 2026 2:54pm UTC. |
📝 WalkthroughWalkthroughThis PR disables Rust build target caching in the Swift packaging GitHub Actions workflow to prevent stale iOS SDK artifacts from being restored on the macOS runner, and documents this fix in the changelog. ChangesSwift Packaging Rust Cache Target Disabling
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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 `@crates/mdk-uniffi/CHANGELOG.md`:
- Line 43: The changelog entry that starts "Swift packaging now rebuilds C
dependencies..." ends with an issue link; change that trailing reference to the
corresponding PR reference (use the PR number and PR URL for mdk-swift) so the
entry follows policy of referencing PRs not issues—update the final
parenthetical reference at the end of that paragraph to point to the PR (e.g.,
marmot-protocol/mdk-swift#<PR_NUMBER>) instead of the issue link.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 19777588-b0c3-4f80-a09d-5123d6b33d36
📒 Files selected for processing (2)
.github/workflows/package-mdk-bindings.ymlcrates/mdk-uniffi/CHANGELOG.md
The macos-26 runner pin in #312 looked right but didn't actually change anything: the auto-republished
libmdk_uniffi.aonmdk-swift@maincame out byte-for-byte identical to the pre-#312 archive (same LFS SHA, same 115864704 bytes), and here's why.What happened
The
package-swiftjob runsSwatinem/rust-cache. Its default key is(Darwin-arm64, Cargo.lock hash, Rust version). None of those changed when we bumped frommacos-latest(15) tomacos-26-arm64, so the cache forpackage-swiftfrom PR #309's run on macos-15 hit cleanly on PR #312's run on macos-26 and restored the entiretarget/directory.The actions log on PR #312's package-swift job tells the story:
A clean Rust + SQLCipher + secp256k1 compile takes about 10 minutes. 77 seconds means cargo found everything pre-built in
target/, relinked the same object files, and walked out the door whistling. The C deps (libsqlite3-sys,secp256k1-sys) had been compiled against the Xcode 16.4 iPhoneSimulator 18.5 SDK in the previous macos-15 run, so they kept theirsdk=18.5Mach-O tags even though the host machine now had Xcode 26.2 available.The fix
Set
cache-targets: falseon theSwatinem/rust-cachestep inpackage-swift. That keeps registry / crate-source caching (cheap and harmless, saves thecargo fetchstep) but forcestarget/to rebuild from scratch every push. The C deps then always compile against whatever Xcode the current runner has, so the resulting archive matches the toolchain it claims to come from.Tradeoff: build time goes from about 1 minute (cache hit) to about 10 minutes (clean compile). That is the correct cost for a job that publishes a shippable artifact, and it's a once-per-push job on a macos-26 runner, so the wall-clock impact is fine.
Scope
This only touches the
package-swiftjob. Python, Ruby, and Kotlin jobs keep their cache because their published artifacts aren't sensitive to Xcode SDK tags (Python / Ruby ship a.dylib; Kotlin runs on Linux).Verification plan
master.package-mdk-bindings.ymlwith the new YAML, which meanscache-targets: falsetakes effect on this very run.mdk-swift@mainshould land with a fresh LFS SHA forBinary/mdk_uniffi.xcframework/ios-arm64-simulator/libmdk_uniffi.a(NOT5b918c5b51145f4ee6a0a16a40ed79dd8e1676acb928f4e3ad5d438864b89006).sdk=26.xinstead of the previous 5 stragglers atsdk=18.5.I'll spot-check the new archive once the workflow lands and update marmot-protocol/mdk-swift#1.
Relates to marmot-protocol/mdk-swift#1, follow-up to #312.
This PR fixes the Swift packaging GitHub Actions workflow to disable caching of Rust build targets, ensuring that C dependencies are rebuilt against the current Xcode SDK on each run rather than reusing pre-compiled objects cached from a different macOS runner version. The change prevents SDK tag mismatches that could result in binary artifacts with stale Mach-O SDK references.
What changed:
cache-targets: falseconfiguration to theSwatinem/rust-cachestep in thepackage-swiftjob within.github/workflows/package-mdk-bindings.yml, with explanatory comments documenting why target directory caching must be disabledcrates/mdk-uniffi/CHANGELOG.mdwith a "Fixed" entry documenting this workflow behavior change