Fix stale dependent framework caches by propagating dependency cache keys#271
Conversation
0dc268b to
3cab5ce
Compare
|
Thanks for the fix — the propagation approach via 1.
|
3cab5ce to
df83ef2
Compare
|
@giginet Thanks for the feedback. I addressed the points. Please re-review the changes. |
This change addresses stale cache reuse in dependent frameworks by including direct dependency cache key checksums in SwiftPMCacheKey and computing keys in dependency order. It also preserves backward compatibility for existing version files, stabilizes dependency checksum ordering, and keeps historical behavior when cache policies are disabled (no restore/save/version file generation). Tests were extended to cover backward-compatible decoding, dependency checksum propagation, and cache key invalidation cascading when dependency build state changes. Co-authored-by: Codex <noreply@openai.com>
Move helper methods into an extension without behavior changes to keep FrameworkProducer within SwiftLint type_body_length limits. Co-authored-by: Codex <noreply@openai.com>
When cache key graph precomputation fails, fallback to cache-disabled behavior for the run and continue building targets. This restores expected behavior for fixtures without repository version metadata and avoids failing tests before the intended compile-failure path. Co-authored-by: Codex <noreply@openai.com>
Keep FrameworkProducer helper definitions aligned with the order they are used from processAllTargets while preserving behavior. Co-authored-by: Codex <noreply@openai.com>
Copy the PartialCacheTestPackage fixture into a temporary git repository and tag it before calculating cache keys. This keeps the tests stable in CI merge checkouts where the repository itself does not expose the fixture as a tagged package revision. Co-authored-by: Codex <noreply@openai.com>
Keep the no-cache fallback for local package revisions that cannot be resolved, but propagate other cache key errors such as compiler or Xcode version detection failures. Co-authored-by: Codex <noreply@openai.com>
Fetch clang and Xcode versions once for graph-wide cache key calculation and pass the shared environment into each target key calculation. Co-authored-by: Codex <noreply@openai.com>
Process cache key calculation from leaf nodes upward and calculate targets in the same dependency layer concurrently while keeping parent targets blocked until all child keys are available. Co-authored-by: Codex <noreply@openai.com>
Copy the TestingPackage fixture into a per-test temporary directory and derive project and local disk cache paths from that isolated location so Swift Testing can keep running cases in parallel without cache cleanup races. Co-authored-by: Codex <noreply@openai.com>
df83ef2 to
a39eca0
Compare
Keep cache keys for targets whose revisions are available when another target cannot resolve its revision. Propagate unavailable status to dependents so only the affected cache participation is skipped, and cover the behavior with a regression test. Co-authored-by: Codex <noreply@openai.com>
Check that a cache key exists before logging a framework cache save, so targets intentionally excluded from cache participation are not reported as cached. Co-authored-by: Codex <noreply@openai.com>
Report the same VersionFile warning when a target has no precomputed cache key, instead of silently skipping version file generation. Co-authored-by: Codex <noreply@openai.com>
Remove the keyless generateVersionFile API, which cannot represent dependency cache key checksums for non-leaf targets. Migrate RunnerTests to calculate one cache key map from the resolved dependency graph and pass explicit keys when generating version files. Co-authored-by: Codex <noreply@openai.com>
Cap AsyncOperations asyncMap to CacheSystem.defaultParallelNumber while preserving parallel processing for same-level graph nodes. Co-authored-by: Codex <noreply@openai.com>
Calculate graph cache keys directly from FrameworkProducer now that revision failures are handled per target by CacheSystem. Remove the redundant helper and its do-catch wrapper so non-revision errors propagate unchanged. Co-authored-by: Codex <noreply@openai.com>
Identify the framework when VersionFile generation is skipped because its cache key is unavailable or the version file cannot be written. Co-authored-by: Codex <noreply@openai.com>
Omit empty dependency checksum lists from serialized cache keys so legacy dependency-free artifacts remain compatible. Add coverage for decoding and re-encoding the legacy format.
Keep graph traversal and cache state management in calculateCacheKeys while isolating concurrent per-layer calculation.
Use the graph-based cache key API throughout the production tests and update revision-missing expectations to match partial graph results.
a39eca0 to
3fd4dc3
Compare
Summary
This PR fixes stale cache reuse for dependent frameworks by including dependency build state in cache keys.
Previously, a downstream target could keep reusing a cached artifact even after a dependency was rebuilt with incompatible changes.
Related issue: #265
What Changed
Tests
Impact