From 95eb9dfe8bb2cca361522ec93436afebcb998f2a Mon Sep 17 00:00:00 2001 From: Andrew Heard Date: Fri, 20 Sep 2024 19:45:22 -0400 Subject: [PATCH] [Vertex AI] Use `actions/cache` in workflow (#13687) --- .github/workflows/vertexai.yml | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/.github/workflows/vertexai.yml b/.github/workflows/vertexai.yml index 3a33c8ded29..cc97d6bf32f 100644 --- a/.github/workflows/vertexai.yml +++ b/.github/workflows/vertexai.yml @@ -15,9 +15,31 @@ concurrency: cancel-in-progress: true jobs: + spm-package-resolved: + runs-on: macos-14 + outputs: + cache_key: ${{ steps.generate_cache_key.outputs.cache_key }} + env: + FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1 + steps: + - uses: actions/checkout@v4 + - name: Generate Swift Package.resolved + id: swift_package_resolve + run: | + swift package resolve + - name: Generate cache key + id: generate_cache_key + run: | + cache_key="${{ runner.os }}-spm-${{ hashFiles('**/Package.resolved') }}" + echo "cache_key=${cache_key}" >> "$GITHUB_OUTPUT" + - uses: actions/cache/save@v4 + id: cache + with: + path: .build + key: ${{ steps.generate_cache_key.outputs.cache_key }} + spm-unit: strategy: - max-parallel: 1 matrix: target: [iOS, macOS, catalyst, tvOS, visionOS, watchOS] os: [macos-14] @@ -25,10 +47,15 @@ jobs: - os: macos-14 xcode: Xcode_15.2 runs-on: ${{ matrix.os }} + needs: spm-package-resolved env: FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1 steps: - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: .build + key: ${{needs.spm-package-resolved.outputs.cache_key}} - name: Clone mock responses run: scripts/update_vertexai_responses.sh - name: Xcode @@ -45,7 +72,6 @@ jobs: spm-integration: strategy: - max-parallel: 1 matrix: target: [iOS] os: [macos-14] @@ -53,12 +79,17 @@ jobs: - os: macos-14 xcode: Xcode_15.2 runs-on: ${{ matrix.os }} + needs: spm-package-resolved env: TEST_RUNNER_VertexAIRunIntegrationTests: 1 FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1 plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }} steps: - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: .build + key: ${{needs.spm-package-resolved.outputs.cache_key}} - name: Install Secret GoogleService-Info.plist run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/vertexai-integration.plist.gpg \ FirebaseVertexAI/Tests/Integration/Resources/GoogleService-Info.plist "$plist_secret" @@ -108,14 +139,17 @@ jobs: - os: macos-14 xcode: Xcode_15.2 runs-on: ${{ matrix.os }} + needs: spm-package-resolved env: FIREBASECI_USE_LATEST_GOOGLEAPPMEASUREMENT: 1 steps: - uses: actions/checkout@v4 + - uses: actions/cache/restore@v4 + with: + path: .build + key: ${{needs.spm-package-resolved.outputs.cache_key}} - name: Xcode run: sudo xcode-select -s /Applications/${{ matrix.xcode }}.app/Contents/Developer - - name: Initialize xcodebuild - run: xcodebuild -list - name: Placeholder GoogleService-Info.plist for build testing run: cp FirebaseCore/Tests/Unit/Resources/GoogleService-Info.plist FirebaseVertexAI/Sample/ - uses: nick-fields/retry@v3