From 33a860bcc1af4503604c4701086f271e1b3495ee Mon Sep 17 00:00:00 2001 From: AJ Beck Date: Mon, 7 Sep 2026 10:43:41 +0100 Subject: [PATCH] perf(ci): share Xcode package caches --- .github/workflows/release.yml | 39 ++++++++++++++++++++++++++++++++-- .github/workflows/validate.yml | 35 ++++++++++++++++++++++-------- 2 files changed, 63 insertions(+), 11 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index abdc36f..281c044 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,6 +25,7 @@ jobs: steps: - name: Verify Xcode 27 toolchain + id: xcode run: | xcode_version="$(xcodebuild -version | awk '/^Xcode / { print $2 }')" xcodebuild -version @@ -34,6 +35,12 @@ jobs: exit 1 fi + { + echo "package_cache_path=$RUNNER_TEMP/quorra-package-cache" + echo "source_packages_path=$RUNNER_TEMP/quorra-source-packages" + echo "version=$xcode_version" + } >> "$GITHUB_OUTPUT" + - name: Create release automation token id: release-token uses: actions/create-github-app-token@v3 @@ -108,6 +115,19 @@ jobs: with: ref: ${{ steps.release-context.outputs.tag }} + - name: Restore Swift package cache + id: swift-package-cache + if: ${{ steps.release-context.outputs.tag != '' }} + uses: actions/cache/restore@v6 + with: + path: | + ${{ steps.xcode.outputs.package_cache_path }} + ${{ steps.xcode.outputs.source_packages_path }} + key: >- + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-packages-${{ hashFiles('Quorra.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'Packages/QuorraCore/Package.swift') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-packages- + - name: Import distribution signing assets if: ${{ steps.release-context.outputs.tag != '' }} env: @@ -148,7 +168,9 @@ jobs: - name: Archive and export application if: ${{ steps.release-context.outputs.tag != '' }} env: + PACKAGE_CACHE_PATH: ${{ steps.xcode.outputs.package_cache_path }} RELEASE_VERSION: ${{ steps.release-context.outputs.version }} + SOURCE_PACKAGES_PATH: ${{ steps.xcode.outputs.source_packages_path }} run: | archive_path="$RUNNER_TEMP/quorra.xcarchive" export_path="$RUNNER_TEMP/export" @@ -183,7 +205,8 @@ jobs: -scheme QuorraApp \ -configuration Release \ -destination 'generic/platform=macOS' \ - -clonedSourcePackagesDirPath "$RUNNER_TEMP/SourcePackages" \ + -clonedSourcePackagesDirPath "$SOURCE_PACKAGES_PATH" \ + -packageCachePath "$PACKAGE_CACHE_PATH" \ -skipPackagePluginValidation \ -archivePath "$archive_path" \ QUORRA_PROVISIONING_PROFILE_SPECIFIER="$PROVISIONING_PROFILE_UUID" \ @@ -199,6 +222,17 @@ jobs: echo "EXPORTED_APP_PATH=$export_path/quorra.app" >> "$GITHUB_ENV" + - name: Save Swift package cache + if: >- + ${{ steps.release-context.outputs.tag != '' && steps.swift-package-cache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v6 + with: + path: | + ${{ steps.xcode.outputs.package_cache_path }} + ${{ steps.xcode.outputs.source_packages_path }} + key: >- + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-packages-${{ hashFiles('Quorra.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'Packages/QuorraCore/Package.swift') }} + - name: Verify packaged application version if: ${{ steps.release-context.outputs.tag != '' }} env: @@ -328,10 +362,11 @@ jobs: if: ${{ steps.release-context.outputs.tag != '' }} env: RELEASE_TAG: ${{ steps.release-context.outputs.tag }} + SOURCE_PACKAGES_PATH: ${{ steps.xcode.outputs.source_packages_path }} SPARKLE_PRIVATE_KEY: ${{ secrets.SPARKLE_PRIVATE_KEY }} run: | updates_directory="$RUNNER_TEMP/sparkle-updates" - generate_appcast="$RUNNER_TEMP/SourcePackages/artifacts/sparkle/Sparkle/bin/generate_appcast" + generate_appcast="$SOURCE_PACKAGES_PATH/artifacts/sparkle/Sparkle/bin/generate_appcast" release_url="https://github.com/$GITHUB_REPOSITORY/releases/tag/$RELEASE_TAG" download_url_prefix="https://github.com/$GITHUB_REPOSITORY/releases/download/$RELEASE_TAG/" diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 9b0f264..d26b773 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -66,18 +66,27 @@ jobs: echo "source_packages_path=$RUNNER_TEMP/quorra-source-packages" >> "$GITHUB_OUTPUT" echo "version=$(xcodebuild -version | awk '/^Xcode / { print $2 }')" >> "$GITHUB_OUTPUT" - - name: Restore Xcode build cache - id: xcode-cache + - name: Restore Swift package cache + id: swift-package-cache uses: actions/cache/restore@v6 with: path: | - ${{ steps.xcode.outputs.derived_data_path }} ${{ steps.xcode.outputs.package_cache_path }} ${{ steps.xcode.outputs.source_packages_path }} key: >- - ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-${{ hashFiles('Quorra.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'Quorra.xcodeproj/project.pbxproj', 'Packages/QuorraCore/Package.swift') }} + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-packages-${{ hashFiles('Quorra.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'Packages/QuorraCore/Package.swift') }} restore-keys: | - ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra- + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-packages- + + - name: Restore validation build cache + id: validation-build-cache + uses: actions/cache/restore@v6 + with: + path: ${{ steps.xcode.outputs.derived_data_path }} + key: >- + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-derived-data-${{ hashFiles('Quorra.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'Quorra.xcodeproj/project.pbxproj', 'Packages/QuorraCore/Package.swift') }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-derived-data- - name: Build and test env: @@ -98,17 +107,25 @@ jobs: -resultBundlePath "$RUNNER_TEMP/quorra-tests.xcresult" CODE_SIGNING_ALLOWED=NO - - name: Save Xcode build cache + - name: Save Swift package cache if: >- - ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.xcode-cache.outputs.cache-hit != 'true' }} + ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.swift-package-cache.outputs.cache-hit != 'true' }} uses: actions/cache/save@v6 with: path: | - ${{ steps.xcode.outputs.derived_data_path }} ${{ steps.xcode.outputs.package_cache_path }} ${{ steps.xcode.outputs.source_packages_path }} key: >- - ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-${{ hashFiles('Quorra.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'Quorra.xcodeproj/project.pbxproj', 'Packages/QuorraCore/Package.swift') }} + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-packages-${{ hashFiles('Quorra.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'Packages/QuorraCore/Package.swift') }} + + - name: Save validation build cache + if: >- + ${{ success() && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.validation-build-cache.outputs.cache-hit != 'true' }} + uses: actions/cache/save@v6 + with: + path: ${{ steps.xcode.outputs.derived_data_path }} + key: >- + ${{ runner.os }}-${{ runner.arch }}-xcode-${{ steps.xcode.outputs.version }}-quorra-derived-data-${{ hashFiles('Quorra.xcworkspace/xcshareddata/swiftpm/Package.resolved', 'Quorra.xcodeproj/project.pbxproj', 'Packages/QuorraCore/Package.swift') }} - name: Upload test results if: ${{ failure() }}