diff --git a/.github/workflows/build-and-lint.yml b/.github/workflows/build-and-lint.yml index b7a43cf3e..f75bb0da6 100644 --- a/.github/workflows/build-and-lint.yml +++ b/.github/workflows/build-and-lint.yml @@ -31,8 +31,14 @@ jobs: - name: Select Xcode run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app + - name: Cache Ruby gems + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: ~/.gem + key: gems-xcodeproj-${{ runner.os }} + - name: Update xcodeproj gem - run: sudo gem install xcodeproj + run: gem install xcodeproj --user-install - name: Prevent social URL warnings if twitter is unreachable run: find . -path '*.podspec' -exec perl -pi -e 's/.+\.social_media_url.+//' {} \; diff --git a/.github/workflows/build-kits.yml b/.github/workflows/build-kits.yml index e55962c81..21b06169f 100644 --- a/.github/workflows/build-kits.yml +++ b/.github/workflows/build-kits.yml @@ -25,6 +25,7 @@ jobs: name: Pod Lint ${{ matrix.kit.name }} needs: load-matrix runs-on: macos-15 + timeout-minutes: 30 strategy: fail-fast: false matrix: @@ -34,6 +35,19 @@ jobs: - uses: maxim-lobanov/setup-xcode@v1 with: xcode-version: "26.2" + - name: Compute weekly cache key + run: echo "CACHE_WEEK=$(date +%Y-W%V)" >> $GITHUB_ENV + - name: Cache CocoaPods sources + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: | + ~/.cocoapods + ~/Library/Caches/CocoaPods + key: cocoapods-${{ runner.os }}-${{ matrix.kit.name }}-${{ env.CACHE_WEEK }}-${{ hashFiles(format('{0}/*.podspec', matrix.kit.local_path)) }} + restore-keys: | + cocoapods-${{ runner.os }}-${{ matrix.kit.name }}-${{ env.CACHE_WEEK }}- + cocoapods-${{ runner.os }}-${{ matrix.kit.name }}- + cocoapods-${{ runner.os }}- - name: Pod Lib Lint run: | echo "Linting: ${{ matrix.kit.podspec }}" @@ -49,6 +63,7 @@ jobs: name: Build ${{ matrix.kit.name }} needs: load-matrix runs-on: macOS-latest + timeout-minutes: 30 env: XCODE_VERSION: ${{ matrix.kit.xcode_version || '26.2' }} USE_LOCAL_VERSION: "1" @@ -61,11 +76,32 @@ jobs: - name: Checkout monorepo uses: actions/checkout@v6 with: - fetch-depth: 0 + fetch-depth: 1 - name: Select Xcode run: sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app + - name: Compute DerivedData cache key + id: derived-key + run: | + # Hash kit source files + core SDK files; gracefully handle kits with no .h/.m files + HASH=$( + { + find "${{ matrix.kit.local_path }}" \( -name '*.swift' -o -name '*.m' -o -name '*.h' -o -name 'Package.resolved' \) -print0 2>/dev/null | sort -z | xargs -0 shasum -a 256 2>/dev/null || true + find mParticle-Apple-SDK mParticle-Apple-SDK-Swift \( -name '*.swift' -o -name '*.m' -o -name '*.h' \) -print0 2>/dev/null | sort -z | xargs -0 shasum -a 256 2>/dev/null || true + } | shasum -a 256 | cut -c1-16 + ) + echo "hash=$HASH" >> $GITHUB_OUTPUT + + - name: Cache DerivedData + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: DerivedData + key: derived-${{ runner.os }}-${{ matrix.kit.name }}-${{ env.XCODE_VERSION }}-${{ steps.derived-key.outputs.hash }} + restore-keys: | + derived-${{ runner.os }}-${{ matrix.kit.name }}-${{ env.XCODE_VERSION }}- + derived-${{ runner.os }}-${{ matrix.kit.name }}- + - name: Resolve SPM dependencies run: | SCHEME=$(echo '${{ toJson(matrix.kit.schemes) }}' | jq -r '.[0].scheme') diff --git a/.github/workflows/cross-platform-tests.yml b/.github/workflows/cross-platform-tests.yml index b5f336e27..dedd128e4 100644 --- a/.github/workflows/cross-platform-tests.yml +++ b/.github/workflows/cross-platform-tests.yml @@ -32,8 +32,14 @@ jobs: distribution: "zulu" java-version: "17" cache: "gradle" + - name: Cache Ruby gems + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: ~/.gem + key: gems-cocoapods-${{ runner.os }}-${{ hashFiles('**/Podfile.lock') }} + restore-keys: gems-cocoapods-${{ runner.os }} - name: "Install Cocoapods" - run: sudo gem install cocoapods; sudo gem install cocoapods-generate + run: gem install cocoapods cocoapods-generate --user-install && echo "$(ruby -e 'puts Gem.user_dir')/bin" >> $GITHUB_PATH - name: Choose Xcode version run: xcode-select -p; sudo xcode-select -s /Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer; xcode-select -p - name: Run Tests diff --git a/.github/workflows/integration-tests.yml b/.github/workflows/integration-tests.yml index 823306ff3..e1c7334cc 100644 --- a/.github/workflows/integration-tests.yml +++ b/.github/workflows/integration-tests.yml @@ -34,7 +34,15 @@ jobs: distribution: temurin java-version: 17 + - name: Cache WireMock JAR + uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + id: wiremock-cache + with: + path: wiremock.jar + key: wiremock-${{ env.WIREMOCK_VERSION }} + - name: Download WireMock standalone + if: steps.wiremock-cache.outputs.cache-hit != 'true' run: | curl -L -o wiremock.jar \ "https://repo1.maven.org/maven2/org/wiremock/wiremock-standalone/${{ env.WIREMOCK_VERSION }}/wiremock-standalone-${{ env.WIREMOCK_VERSION }}.jar"