Skip to content

Commit d5ca7e8

Browse files
authored
chore(ci): scope build cache per scheme and save from integration/unit runs (#4198)
PR #4195 keyed the build cache on Package.resolved, which fixed cross-dependency poisoning. A second failure mode remained: the cache was populated exclusively by `build_scheme.yml` building `Amplify-Package` on main. Integration test schemes that link additional frameworks (e.g. SmithyXML via Predictions, S3 via Storage) restored that cache and then failed to link: Undefined symbol: static SmithyXML.Reader.from(data: Foundation.Data) throws -> SmithyXML.Reader Undefined symbol: type metadata accessor for SmithyXML.Reader Root cause: one platform-scoped bucket was shared across schemes with different module graphs. Fix by scoping the cache per scheme and having each test workflow save its own bucket on main after a successful run. Changes: - Append ${{ inputs.scheme }} to the build cache key in build_scheme.yml, run_integration_tests.yml, run_unit_tests.yml. Add literal scheme name in integ_test_auth_webauthn.yml (AuthWebAuthnApp) and integ_test_push_ notifications.yml (PushNotificationHostApp / PushNotificationWatchTests). - Add a `cache/save` step at the end of each test workflow (integration and unit) gated on `github.ref_name == 'main'` and a successful test run, so each scheme populates its own cache bucket on main. The save steps only run on main, so PR branches continue to consume caches without producing them. GitHub's per-repo cache LRU will evict least- recently-used buckets as the per-scheme footprint grows.
1 parent 1c35d54 commit d5ca7e8

5 files changed

Lines changed: 35 additions & 7 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-${{ hashFiles('Package.resolved') }}
71+
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-${{ inputs.scheme }}-build-cache-${{ hashFiles('Package.resolved') }}
7272

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

.github/workflows/integ_test_auth_webauthn.yml

Lines changed: 9 additions & 2 deletions
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-${{ hashFiles('Package.resolved') }}
76+
key: Amplify-iOS-${{ steps.platform.outputs.xcode-version }}-AuthWebAuthnApp-build-cache-${{ hashFiles('Package.resolved') }}
7777

7878
- name: Run Local Server
7979
run: |
@@ -110,4 +110,11 @@ jobs:
110110
generate_coverage: false
111111
cloned_source_packages_path: ~/Library/Developer/Xcode/DerivedData/Amplify
112112
derived_data_path: ${{ github.workspace }}/Build
113-
disable_package_resolution: true
113+
disable_package_resolution: true
114+
115+
- name: Save the build cache
116+
if: steps.build-cache.outputs.cache-hit != 'true' && (steps.run-tests.outcome == 'success' || steps.retry-tests.outcome == 'success')
117+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
118+
with:
119+
path: ${{ github.workspace }}/Build
120+
key: ${{ steps.build-cache.outputs.cache-primary-key }}

.github/workflows/integ_test_push_notifications.yml

Lines changed: 9 additions & 2 deletions
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-${{ hashFiles('Package.resolved') }}
94+
key: Amplify-${{ matrix.platform }}-${{ steps.platform.outputs.xcode-version }}-${{ matrix.platform == 'watchOS' && 'PushNotificationWatchTests' || 'PushNotificationHostApp' }}-build-cache-${{ hashFiles('Package.resolved') }}
9595

9696
- name: Run Local Server
9797
run: |
@@ -128,4 +128,11 @@ jobs:
128128
generate_coverage: false
129129
cloned_source_packages_path: ~/Library/Developer/Xcode/DerivedData/Amplify
130130
derived_data_path: ${{ github.workspace }}/Build
131-
disable_package_resolution: true
131+
disable_package_resolution: true
132+
133+
- name: Save the build cache
134+
if: steps.build-cache.outputs.cache-hit != 'true' && (steps.run-tests.outcome == 'success' || steps.retry-tests.outcome == 'success')
135+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
136+
with:
137+
path: ${{ github.workspace }}/Build
138+
key: ${{ steps.build-cache.outputs.cache-primary-key }}

.github/workflows/run_integration_tests.yml

Lines changed: 8 additions & 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-${{ hashFiles('Package.resolved') }}
97+
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-${{ inputs.scheme }}-build-cache-${{ hashFiles('Package.resolved') }}
9898

9999
- name: Run ${{ inputs.platform }} Integration Tests
100100
id: run-tests
@@ -130,3 +130,10 @@ jobs:
130130
# Only attempt to test without building when we are not using any cache.
131131
test_without_building: ${{ !steps.build-cache.outputs.cache-hit }}
132132
other_flags: -test-iterations 3 -retry-tests-on-failure -parallel-testing-enabled NO -test-repetition-relaunch-enabled YES
133+
134+
- name: Save the build cache
135+
if: steps.build-cache.outputs.cache-hit != 'true' && (steps.run-tests.outcome == 'success' || steps.retry-tests.outcome == 'success')
136+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
137+
with:
138+
path: ${{ github.workspace }}/Build
139+
key: ${{ steps.build-cache.outputs.cache-primary-key }}

.github/workflows/run_unit_tests.yml

Lines changed: 8 additions & 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-${{ hashFiles('Package.resolved') }}
89+
key: Amplify-${{ inputs.platform }}-${{ steps.platform.outputs.xcode-version }}-${{ inputs.scheme }}-build-cache-${{ hashFiles('Package.resolved') }}
9090

9191
- name: Run ${{ inputs.platform }} Unit Tests
9292
id: run-tests
@@ -119,6 +119,13 @@ jobs:
119119
disable_package_resolution: true
120120
other_flags: ${{ inputs.test_iterations_flags }}
121121

122+
- name: Save the build cache
123+
if: steps.build-cache.outputs.cache-hit != 'true' && (steps.run-tests.outcome == 'success' || steps.retry-tests.outcome == 'success')
124+
uses: actions/cache/save@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4.2.0
125+
with:
126+
path: ${{ github.workspace }}/Build
127+
key: ${{ steps.build-cache.outputs.cache-primary-key }}
128+
122129
- name: Store Coverage Report File
123130
if: ${{ inputs.generate_coverage_report == true }}
124131
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392 # v4.0.0

0 commit comments

Comments
 (0)