From 09c2c55acfd71409c5f26e598fd01df7bcc2b486 Mon Sep 17 00:00:00 2001 From: Ricardo Colombo Oliveira Date: Fri, 23 Oct 2026 11:23:38 +0200 Subject: [PATCH] ci: cache the Cocoa SDK build The macOS build job and the iOS device tests build the Cocoa SDK from the sentry-cocoa submodule on every run. In the macOS Build step on main, that takes 12.2 of 23.7 minutes on one MSBuild node, and the other two nodes go idle waiting for the Cocoa bindings. version7 caches it since #5746, and this brings the same steps to main. The key covers the selected Xcode, build-sentry-cocoa.sh, sentry-cocoa.xcconfig and the submodule commit. Pushes to main save the cache, so pull requests restore it from there. Release branches still build it from source, because it ships in the Sentry.Bindings.Cocoa package. Co-Authored-By: Claude Opus 5.5 --- .github/actions/cocoa-cache-key/action.yml | 13 ++++++++++++ .github/workflows/build.yml | 24 ++++++++++++++++++++++ .github/workflows/device-tests-ios.yml | 19 +++++++++++++++++ 3 files changed, 56 insertions(+) create mode 100644 .github/actions/cocoa-cache-key/action.yml diff --git a/.github/actions/cocoa-cache-key/action.yml b/.github/actions/cocoa-cache-key/action.yml new file mode 100644 index 0000000000..1862eaa9e2 --- /dev/null +++ b/.github/actions/cocoa-cache-key/action.yml @@ -0,0 +1,13 @@ +name: Cocoa SDK cache key +description: Computes the cache key for the Cocoa SDK that Sentry.Bindings.Cocoa builds from the sentry-cocoa submodule +outputs: + key: + description: Covers the selected Xcode, build-sentry-cocoa.sh, sentry-cocoa.xcconfig and the submodule commit + value: ${{ steps.key.outputs.key }} +runs: + using: composite + + steps: + - id: key + shell: bash + run: echo "key=sentry-cocoa-$(xcodebuild -version | tr -cs '[:alnum:].' '-')-${{ hashFiles('scripts/build-sentry-cocoa.sh', 'scripts/sentry-cocoa.xcconfig') }}-${{ hashFiles('.git/modules/modules/sentry-cocoa/HEAD') }}" >> "$GITHUB_OUTPUT" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 52976f9593..b3b3ad321b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -209,6 +209,22 @@ jobs: fail-on-cache-miss: true enableCrossOsArchive: true + # The Cocoa SDK is built from the submodule by the Sentry.Bindings.Cocoa project, which takes ~15 minutes + # on a hosted runner. build-sentry-cocoa.sh skips the build when the restored stamp matches. + # Release builds always build it from source, because it ships in the Sentry.Bindings.Cocoa package. + - name: Get Cocoa SDK cache key + id: cocoa-key + if: runner.os == 'macOS' + uses: ./.github/actions/cocoa-cache-key + + - name: Restore Cocoa SDK + id: cache-cocoa + if: runner.os == 'macOS' && !startsWith(github.ref_name, 'release/') + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: modules/sentry-cocoa/Carthage + key: ${{ steps.cocoa-key.outputs.key }} + - name: Build Native Dependencies if: ${{ !matrix.container && !env.NO_MOBILE }} uses: ./.github/actions/buildnative @@ -220,6 +236,14 @@ jobs: id: build run: dotnet build ${{ matrix.slnf }} -c Release --no-restore --nologo -v:minimal -flp:logfile=build.log -p:CopyLocalLockFileAssemblies=true -bl:build.binlog + # Only a completed Cocoa build writes the stamp, so a failed one is never cached. + - name: Save Cocoa SDK + if: ${{ !cancelled() && steps.cache-cocoa.outputs.cache-primary-key != '' && steps.cache-cocoa.outputs.cache-hit != 'true' && hashFiles('modules/sentry-cocoa/Carthage/.built-from-sha') != '' }} + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: modules/sentry-cocoa/Carthage + key: ${{ steps.cache-cocoa.outputs.cache-primary-key }} + - name: Upload build logs if: ${{ always() }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 diff --git a/.github/workflows/device-tests-ios.yml b/.github/workflows/device-tests-ios.yml index bbc751bcbe..222f969c52 100644 --- a/.github/workflows/device-tests-ios.yml +++ b/.github/workflows/device-tests-ios.yml @@ -75,9 +75,28 @@ jobs: - name: Setup Environment uses: ./.github/actions/environment + # See build.yml + - name: Get Cocoa SDK cache key + id: cocoa-key + uses: ./.github/actions/cocoa-cache-key + + - name: Restore Cocoa SDK + id: cache-cocoa + uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: modules/sentry-cocoa/Carthage + key: ${{ steps.cocoa-key.outputs.key }} + - name: Build iOS Test App run: pwsh ./scripts/device-test.ps1 ios -Build + - name: Save Cocoa SDK + if: ${{ !cancelled() && steps.cache-cocoa.outputs.cache-hit != 'true' && hashFiles('modules/sentry-cocoa/Carthage/.built-from-sha') != '' }} + uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: modules/sentry-cocoa/Carthage + key: ${{ steps.cache-cocoa.outputs.cache-primary-key }} + - name: Run Tests id: first-test-run continue-on-error: true