Skip to content

Commit 1c35d54

Browse files
authored
chore(ci): scope build cache to Package.resolved hash (#4195)
The workflow build cache key was `Amplify-<platform>-<xcode-version>-build-cache`, which is stable per platform+Xcode forever. When `aws-sdk-swift` (or any SPM dependency) is bumped, `Package.resolved` changes and newly-generated source references symbols in modules like `SmithyXML` that do not exist in the cached `AWSClientRuntime.framework` from a prior commit. The result is linker errors such as: Undefined symbol: static SmithyXML.Reader.from(data: Foundation.Data) -> Reader Undefined symbol: type metadata accessor for SmithyXML.Reader Ld .../AWSClientRuntime.framework/AWSClientRuntime The SPM dependencies cache already includes `hashFiles('Package.resolved')` in its key, so it self-invalidates correctly. Apply the same pattern to the build cache key so a `Package.resolved` change moves to a fresh cache bucket, and stale buckets expire naturally under GitHub's cache LRU. Updates every workflow that reads or writes the build cache: - build_scheme.yml - run_integration_tests.yml - run_unit_tests.yml - integ_test_auth_webauthn.yml - integ_test_push_notifications.yml The save step in build_scheme.yml uses `steps.build-cache.outputs.cache-primary-key`, so it automatically writes to the new hashed bucket. The existing "Delete the old build cache" step continues to remove only the matching bucket before overwriting.
1 parent 05a9726 commit 1c35d54

5 files changed

Lines changed: 5 additions & 5 deletions

File tree

.github/workflows/build_scheme.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
6969
with:
7070
path: ${{ github.workspace }}/Build
71-
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-build-cache
71+
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-build-cache-${{ hashFiles('Package.resolved') }}
7272

7373
- name: Build ${{ inputs.scheme }}
7474
id: build-package

.github/workflows/integ_test_auth_webauthn.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
7474
with:
7575
path: ${{ github.workspace }}/Build
76-
key: Amplify-iOS-${{ steps.platform.outputs.xcode-version }}-build-cache
76+
key: Amplify-iOS-${{ steps.platform.outputs.xcode-version }}-build-cache-${{ hashFiles('Package.resolved') }}
7777

7878
- name: Run Local Server
7979
run: |

.github/workflows/integ_test_push_notifications.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
9292
with:
9393
path: ${{ github.workspace }}/Build
94-
key: Amplify-${{ matrix.platform }}-${{ steps.platform.outputs.xcode-version }}-build-cache
94+
key: Amplify-${{ matrix.platform }}-${{ steps.platform.outputs.xcode-version }}-build-cache-${{ hashFiles('Package.resolved') }}
9595

9696
- name: Run Local Server
9797
run: |

.github/workflows/run_integration_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
9595
with:
9696
path: ${{ github.workspace }}/Build
97-
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-build-cache
97+
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-build-cache-${{ hashFiles('Package.resolved') }}
9898

9999
- name: Run ${{ inputs.platform }} Integration Tests
100100
id: run-tests

.github/workflows/run_unit_tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ jobs:
8686
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
8787
with:
8888
path: ${{ github.workspace }}/Build
89-
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-build-cache
89+
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-build-cache-${{ hashFiles('Package.resolved') }}
9090

9191
- name: Run ${{ inputs.platform }} Unit Tests
9292
id: run-tests

0 commit comments

Comments
 (0)