Cache SetupBuilder artifacts and split CI cache keys#89
Merged
Conversation
Skip redundant `swift build` invocations when the setup package sources haven't changed. SetupCache hashes Package.swift, Package.resolved, and Sources/**/*.swift (plus SDK path and Swift version) to produce a cache key, stores the build result as JSON under .build/previewsmcp-setup-cache/, and validates that all referenced artifacts still exist on load. Also splits the shared CI SPM cache key into per-job keys so build-and-test and ios-tests no longer race on save. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Convert the implementation spec into a technical reference doc under docs/. Strips spec scaffolding (success criteria checklists, rollout plan, open questions) and keeps the cache design, artifact validation, error handling, and CI integration details. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Include Swift toolchain version in hashSources so each toolchain gets its own cache entry instead of thrashing on toolchain switches - Add defense-in-depth guards: verify sourceHash and platform fields in Entry match the lookup parameters, not just the filename - Validate .swiftmodule directory is non-empty (catches partial clean) - Rename test to reflect actual behavior (only hashes Package + Sources) - Use fixed 1s threshold for warm cache assertion instead of flaky ratio - Strengthen invalidation test: assert new cache files are a superset - Add swiftVersion sensitivity test for hashSources Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The 1s threshold was too tight for GitHub Actions shared runners where subprocess overhead (resolveSwiftVersion, hashSources) is higher due to contention. Bump to 3s — still meaningful vs the ~19s cold build on CI. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SetupCachethat skips redundantswift buildwhen setup package sources haven't changed — warmpreview_startdrops from ~3-10s to <100ms for the setup stepPackage.swift+Package.resolved+Sources/**/*.swift+ iOS SDK path + Swift toolchain version.swiftmodule, static libs, and frameworks still exist on diskspm-...-build-/spm-...-ios-) sobuild-and-testandios-testsno longer clobber each otherCloses #81
Test plan
SetupCacheTests— hashing stability/sensitivity, store/load round-trip, corrupt JSON handling, missing artifact detection, read-only filesystem, platform isolation, warm cache speedup, source change invalidationPreviewsCoreTestspass (no regressions)swift-format lintclean🤖 Generated with Claude Code