From ed8e202eb56a2675da00738d39e6d211b7424c8a Mon Sep 17 00:00:00 2001 From: Daniil Gusev Date: Mon, 23 Nov 2026 17:19:15 +0100 Subject: [PATCH] ci(swift): save the package cache only from main (AI-3610) A pull request's copy of the Swift package cache (about 1.1 GB) is readable only by that pull request. These copies push the repo cache over its limit, and GitHub then deletes entries of all workflows, main's Swift entry included. Pull requests now restore main's entry. --- .github/workflows/client-sdks.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/client-sdks.yml b/.github/workflows/client-sdks.yml index f803c55bad..35d7f28727 100644 --- a/.github/workflows/client-sdks.yml +++ b/.github/workflows/client-sdks.yml @@ -237,9 +237,13 @@ jobs: xcodebuild -project SwiftDemo.xcodeproj -scheme SwiftDemo -destination 'generic/platform=iOS Simulator' \ -clonedSourcePackagesDirPath "$RUNNER_TEMP/spm" -derivedDataPath "$RUNNER_TEMP/DerivedData" build - # Saved even when a test fails, so a red run still leaves the next one a warm cache. + # Saved even when a test fails, so a red run still leaves the next one a warm cache. Only + # a push to main saves it: a pull request's copy serves that pull request alone and fills + # the cache that all workflows of the repository share. - uses: actions/cache/save@v4 - if: always() && steps.packages.outcome == 'success' && steps.packages.outputs.cache-hit != 'true' + if: >- + always() && github.event_name == 'push' && steps.packages.outcome == 'success' + && steps.packages.outputs.cache-hit != 'true' with: path: ${{ runner.temp }}/spm key: ${{ steps.packages.outputs.cache-primary-key }}