Skip to content

Commit 3bd9891

Browse files
authored
chore(ci): Replace cache-based slice caching with artifact upload/download (#6795)
Replace actions/cache usage for xcframework slices with artifact upload/download to prevent cross-branch cache contamination. Artifacts are scoped to workflow runs and commit SHAs, ensuring proper isolation between branches. Changes: - Remove cache restore/save steps from build-xcframework-variant-slices.yml - Remove cache restore/save steps from assemble-xcframework-variant.yml - Remove all cache-hit conditional logic - Rely entirely on artifact upload/download for inter-job communication This solves the issue where slices from other branches could be used if files were missing in the hash sum calculation used for cache key generation.
1 parent 665642a commit 3bd9891

File tree

2 files changed

+8
-61
lines changed

2 files changed

+8
-61
lines changed

.github/workflows/assemble-xcframework-variant.yml

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -114,46 +114,25 @@ jobs:
114114
echo "XCFRAMEWORK_NAME=$SCHEME$SUFFIX" >> $GITHUB_ENV
115115
fi
116116
117-
- name: Compute cache key
118-
env:
119-
SDKS: ${{ inputs.sdks }}
120-
VARIANT_ID: ${{ inputs.variant-id }}
121-
SIGNED: ${{ inputs.signed }}
122-
VERSION: ${{ env.VERSION }}
123-
run: |
124-
sdks_string="$SDKS"
125-
sdks_string_slugified="${sdks_string//,/_}"
126-
echo "SENTRY_XCFRAMEWORK_CACHE_KEY=${{runner.os}}-xcframework-$VARIANT_ID-$sdks_string_slugified-$SIGNED-$VERSION-${{hashFiles('Sources/**')}}-${{hashFiles('Sentry.xcodeproj/**')}}" >> $GITHUB_ENV
127-
128-
- name: Restore XCFramework cache
129-
id: cache-xcframework
130-
uses: actions/cache@v4
131-
with:
132-
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
133-
path: ${{env.XCFRAMEWORK_NAME}}.xcframework.zip
134-
135117
- name: Download ${{inputs.variant-id}} Slices
136-
if: steps.cache-xcframework.outputs.cache-hit != 'true'
137118
uses: actions/download-artifact@v6
138119
with:
139120
pattern: xcframework-${{inputs.variant-id}}-slice-*
140121
path: xcframework-slices
141122

142123
- name: Unzip slice artifact ZIP archives
143-
if: steps.cache-xcframework.outputs.cache-hit != 'true'
144124
run: |
145125
find xcframework-slices -type f -print0 | xargs -t0I @ unzip @ -d xcframework-slices
146126
shell: bash
147127

148128
- name: Remove excluded archs
149-
if: ${{ steps.cache-xcframework.outputs.cache-hit != 'true' && inputs.excluded-archs != '' }}
129+
if: ${{ inputs.excluded-archs != '' }}
150130
env:
151131
EXCLUDED_ARCHS: ${{ inputs.excluded-archs }}
152132
run: ./scripts/remove-architectures.sh xcframework-slices/ "$EXCLUDED_ARCHS"
153133
shell: bash
154134

155135
- name: Assemble XCFramework
156-
if: steps.cache-xcframework.outputs.cache-hit != 'true'
157136
env:
158137
SCHEME: ${{ inputs.scheme }}
159138
SUFFIX: ${{ inputs.suffix }}
@@ -174,40 +153,34 @@ jobs:
174153
shell: bash
175154

176155
- name: Validate XCFramework structure
177-
# only validate if the xcframework was not cached
178-
if: steps.cache-xcframework.outputs.cache-hit != 'true'
179156
run: ./scripts/validate-xcframework-format.sh "${{env.XCFRAMEWORK_NAME}}.xcframework"
180157
shell: bash
181158
env:
182159
XCFRAMEWORK_NAME: ${{ env.XCFRAMEWORK_NAME }}
183160

184161
- name: Zip XCFramework
185-
if: steps.cache-xcframework.outputs.cache-hit != 'true'
186162
env:
187163
SIGNED: ${{ inputs.signed }}
188164
SCHEME: ${{ inputs.scheme }}
189165
SUFFIX: ${{ inputs.suffix }}
166+
XCFRAMEWORK_NAME: ${{ env.XCFRAMEWORK_NAME }}
190167
run: |
191168
if [ "$SIGNED" = "true" ]; then
192-
./scripts/compress-xcframework.sh --sign "${{env.XCFRAMEWORK_NAME}}"
169+
./scripts/compress-xcframework.sh --sign "$XCFRAMEWORK_NAME"
193170
else
194-
./scripts/compress-xcframework.sh --not-signed "${{env.XCFRAMEWORK_NAME}}"
171+
./scripts/compress-xcframework.sh --not-signed "$XCFRAMEWORK_NAME"
195172
fi
196173
shell: bash
197174

198-
- name: Cache XCFramework
199-
uses: actions/cache@v4
200-
with:
201-
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
202-
path: ${{env.XCFRAMEWORK_NAME}}.xcframework.zip
203-
204175
- name: Upload XCFramework
205176
uses: actions/upload-artifact@v5
177+
env:
178+
XCFRAMEWORK_NAME: ${{ env.XCFRAMEWORK_NAME }}
206179
with:
207180
overwrite: true
208181
name: xcframework-${{github.sha}}-${{inputs.override-name || inputs.variant-id}}
209182
if-no-files-found: error
210-
path: ${{env.XCFRAMEWORK_NAME}}.xcframework.zip
183+
path: ${{ env.XCFRAMEWORK_NAME }}.xcframework.zip
211184
- name: Run CI Diagnostics
212185
if: failure()
213186
run: ./scripts/ci-diagnostics.sh

.github/workflows/build-xcframework-variant-slices.yml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,14 @@ jobs:
8484
fi
8585
shell: sh
8686

87-
- name: Compute cache key
88-
env:
89-
RUNNER_OS: ${{ runner.os }}
90-
VARIANT_ID: ${{ inputs.variant-id }}
91-
MATRIX_SDK: ${{ matrix.sdk }}
92-
VERSION: ${{ env.VERSION }}
93-
run: |
94-
echo "SENTRY_XCFRAMEWORK_CACHE_KEY=${RUNNER_OS}-xcframework-${VARIANT_ID}-slice-${MATRIX_SDK}-${VERSION}-${{hashFiles('Sources/**')}}-${{hashFiles('Sentry.xcodeproj/**')}}" >> $GITHUB_ENV
95-
96-
- name: Restore xcarchive cache
97-
id: cache-xcarchive
98-
uses: actions/cache@v4
99-
with:
100-
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
101-
path: ${{inputs.name}}${{inputs.suffix}}.xcarchive.zip
102-
10387
- name: Bump version
104-
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
10588
env:
10689
VERSION: ${{ env.VERSION }}
10790
run: |
10891
./scripts/ci-select-xcode.sh 16.4
10992
make bump-version TO=$VERSION
11093
11194
- name: Build ${{inputs.name}}${{inputs.suffix}} XCFramework slice for ${{matrix.sdk}}
112-
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
11395
env:
11496
MATRIX_SDK: ${{ matrix.sdk }}
11597
INPUT_NAME: ${{ inputs.name }}
@@ -121,7 +103,7 @@ jobs:
121103

122104
# The SentrySwiftUI archive build also builds Sentry.framework as a byproduct of the dependency. We need to remove that to avoid downstream assembly tasks from tripping on these extra files. In the future we could investigate using this byproduct instead of running a separate task for Sentry.framework, or use the one already built by that other task instead of rebuilding it here.
123105
- name: Remove Sentry.framework from SentrySwiftUI build
124-
if: steps.cache-xcarchive.outputs.cache-hit != 'true' && inputs.name == 'SentrySwiftUI'
106+
if: inputs.name == 'SentrySwiftUI'
125107
env:
126108
GITHUB_WORKSPACE: ${{ github.workspace }}
127109
run: |
@@ -131,7 +113,6 @@ jobs:
131113

132114
# the upload action broke symlinks in the mac sdk slice's xcarchive
133115
- name: Zip xcarchive
134-
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
135116
env:
136117
GITHUB_WORKSPACE: ${{ github.workspace }}
137118
INPUT_NAME: ${{ inputs.name }}
@@ -141,13 +122,6 @@ jobs:
141122
ditto -c -k -X --rsrc --keepParent ${GITHUB_WORKSPACE}/Carthage/archive/${INPUT_NAME}${INPUT_SUFFIX}/${MATRIX_SDK}.xcarchive ${INPUT_NAME}${INPUT_SUFFIX}.xcarchive.zip
142123
shell: bash
143124

144-
- name: Cache xcarchive
145-
if: steps.cache-xcarchive.outputs.cache-hit != 'true'
146-
uses: actions/cache@v4
147-
with:
148-
key: ${{env.SENTRY_XCFRAMEWORK_CACHE_KEY}}
149-
path: ${{inputs.name}}${{inputs.suffix}}.xcarchive.zip
150-
151125
- name: Upload xcarchive
152126
uses: actions/upload-artifact@v5
153127
with:

0 commit comments

Comments
 (0)