From 28be408c24984eb322094c6367ee056fc4161e64 Mon Sep 17 00:00:00 2001 From: Alexey Alter-Pesotskiy Date: Fri, 28 Jun 2024 11:30:50 +0100 Subject: [PATCH] [CI] Update iOS runtimes' download --- .github/actions/setup-ios-runtime/action.yml | 32 +++++++++++ .github/workflows/cron-checks.yml | 33 +++++------ .github/workflows/smoke-checks.yml | 3 +- .gitignore | 5 ++ Scripts/bootstrap.sh | 6 +- Scripts/install_ios_runtime.sh | 59 ++++++++++++++++++++ fastlane/.env | 7 +++ fastlane/Fastfile | 30 +++++----- 8 files changed, 139 insertions(+), 36 deletions(-) create mode 100644 .github/actions/setup-ios-runtime/action.yml create mode 100755 Scripts/install_ios_runtime.sh create mode 100644 fastlane/.env diff --git a/.github/actions/setup-ios-runtime/action.yml b/.github/actions/setup-ios-runtime/action.yml new file mode 100644 index 00000000..2aa2f045 --- /dev/null +++ b/.github/actions/setup-ios-runtime/action.yml @@ -0,0 +1,32 @@ +name: 'Setup iOS Runtime' +description: 'Download and Install requested iOS Runtime' +runs: + using: "composite" + steps: + - name: Cache iOS Simulator Runtime + uses: actions/cache@v4 + id: runtime-cache + with: + path: ./*.dmg + key: ipsw-runtime-ios-${{ inputs.version }} + restore-keys: ipsw-runtime-ios-${{ inputs.version }} + - name: Setup iOS Simulator Runtime + shell: bash + run: | + brew install blacktop/tap/ipsw + bundle exec fastlane install_runtime ios:${{ inputs.version }} + xcrun simctl list runtimes + - name: Create Custom iOS Simulator + shell: bash + run: | + ios_version_dash=$(echo "${{ inputs.version }}" | tr '.' '-') # ex: 16.4 -> 16-4 + xcrun simctl create custom-test-device "${{ inputs.device }}" "com.apple.CoreSimulator.SimRuntime.iOS-$ios_version_dash" + xcrun simctl list devices ${{ inputs.version }} + +inputs: + version: + description: "iOS Runtime Version" + required: true + device: + description: "iOS Simulator Model" + required: true diff --git a/.github/workflows/cron-checks.yml b/.github/workflows/cron-checks.yml index 343f108f..7b9453ae 100644 --- a/.github/workflows/cron-checks.yml +++ b/.github/workflows/cron-checks.yml @@ -17,7 +17,7 @@ env: jobs: build-test-app-and-frameworks: name: Build Test App and Frameworks - runs-on: macos-13 + runs-on: macos-14 steps: - uses: actions/checkout@v4.1.1 - uses: ./.github/actions/ruby-cache @@ -25,8 +25,6 @@ jobs: - name: Build run: bundle exec fastlane build_test_app_and_frameworks timeout-minutes: 60 - env: - XCODE_VERSION: "15.2" # Should match the minimum version in dependent jobs - uses: actions/upload-artifact@v4 if: success() with: @@ -42,16 +40,16 @@ jobs: strategy: matrix: include: - - ios: 17.2 - xcode: 15.2 + - ios: 17.4 + xcode: 15.4 os: macos-14 - device: "iPhone 15 Pro" + device: "iPhone 14 Pro" setup_runtime: false - ios: 16.4 - xcode: 15.2 + xcode: 15.3 os: macos-14 - device: "iPhone 14 Pro Max" - setup_runtime: false + device: "iPhone 14 Pro" + setup_runtime: true fail-fast: false runs-on: ${{ matrix.os }} env: @@ -70,16 +68,13 @@ jobs: INSTALL_ALLURE: true INSTALL_YEETD: true SKIP_MINT_BOOTSTRAP: true - - name: Cache iOS Simulator Runtime - uses: actions/cache@v4 - id: runtime-cache - with: - path: ~/Library/Caches/XcodeInstall/ - key: runtime-ios-${{ matrix.ios }} - restore-keys: runtime-ios-${{ matrix.ios }} - - name: Setup iOS ${{ matrix.ios }} Runtime + SKIP_BREW_BOOTSTRAP: true + - uses: ./.github/actions/setup-ios-runtime if: ${{ matrix.setup_runtime }} - run: bundle exec fastlane install_sim ios:"${{ matrix.ios }}" + timeout-minutes: 60 + with: + version: ${{ matrix.ios }} + device: ${{ matrix.device }} - name: Launch Allure TestOps run: bundle exec fastlane allure_launch cron:true - name: Run UI Tests (Debug) @@ -156,7 +151,7 @@ jobs: steps: - uses: actions/checkout@v3.1.0 - uses: ./.github/actions/ruby-cache - - name: List Xcode versions xcversion sees + - name: List Xcode versions run: mdfind "kMDItemCFBundleIdentifier = 'com.apple.dt.Xcode'" timeout-minutes: 25 - name: Build SwiftUI diff --git a/.github/workflows/smoke-checks.yml b/.github/workflows/smoke-checks.yml index 1640800f..47185011 100644 --- a/.github/workflows/smoke-checks.yml +++ b/.github/workflows/smoke-checks.yml @@ -127,6 +127,7 @@ jobs: INSTALL_ALLURE: true INSTALL_YEETD: true SKIP_MINT_BOOTSTRAP: true + SKIP_BREW_BOOTSTRAP: true - name: Run UI Tests (Debug) run: bundle exec fastlane test_e2e_mock device:"${{ env.IOS_SIMULATOR_DEVICE }}" batch:'${{ matrix.batch }}' test_without_building:true timeout-minutes: 100 @@ -207,7 +208,7 @@ jobs: steps: - uses: actions/checkout@v3.1.0 - uses: ./.github/actions/ruby-cache - - name: List Xcode versions xcversion sees + - name: List Xcode versions run: mdfind "kMDItemCFBundleIdentifier = 'com.apple.dt.Xcode'" timeout-minutes: 25 - name: Build SwiftUI diff --git a/.gitignore b/.gitignore index 6ba68861..43efb730 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # OS X .DS_Store +# Environment Variables +.env + # Xcode # # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore @@ -67,6 +70,7 @@ Products/ # For more information about the recommended setup visit: # https://docs.fastlane.tools/best-practices/source-control/#source-control +!fastlane/.env fastlane/report.xml fastlane/Preview.html fastlane/screenshots @@ -91,3 +95,4 @@ derived_data/ spm_cache/ .buildcache buildcache +*.dmg diff --git a/Scripts/bootstrap.sh b/Scripts/bootstrap.sh index 32f9046d..e396ef48 100755 --- a/Scripts/bootstrap.sh +++ b/Scripts/bootstrap.sh @@ -37,8 +37,10 @@ ln -sf ../../hooks/pre-commit.sh .git/hooks/pre-commit chmod +x .git/hooks/pre-commit chmod +x ./hooks/git-format-staged -puts "Install brew dependencies" -brew bundle -d +if [ "${SKIP_BREW_BOOTSTRAP:-}" != true ]; then + puts "Install brew dependencies" + brew bundle -d +fi if [ "${SKIP_MINT_BOOTSTRAP:-}" != true ]; then puts "Bootstrap Mint dependencies" diff --git a/Scripts/install_ios_runtime.sh b/Scripts/install_ios_runtime.sh new file mode 100755 index 00000000..1f7c7cd3 --- /dev/null +++ b/Scripts/install_ios_runtime.sh @@ -0,0 +1,59 @@ +#!/bin/bash -e +# Copyright 2024 Namespace Labs Inc. Licensed under the MIT License. + +log() { echo "👉 ${1}" >&2; } +die() { log "${1}"; exit 1; } +[ $# -eq 1 ] || die "usage: $0 path/to/runtime.dmg" + +dmg=$1 +mountpoint=$(mktemp -d) +staging=$(mktemp -d) + +cleanup() { + if [ -d "$staging" ]; then + set +e + log "Removing $staging..." + rm -r "$staging" + log "Unmounting $mountpoint..." + hdiutil detach "$mountpoint" >&2 + fi + + if [ -d "$mountpoint" ]; then + log "Removing $mountpoint..." + rmdir "$mountpoint" + fi +} +trap cleanup EXIT + +log "Mounting $dmg on $mountpoint..." +hdiutil attach "$dmg" -mountpoint "$mountpoint" >&2 + +if ! ls "$mountpoint"/*.pkg >/dev/null 2>&1; then + log "Detected a modern volume runtime; installing with simctl..." + xcrun simctl runtime add "$1" + exit 0 +fi + +log "Detected packaged runtime." + +bundle=$(echo "$mountpoint"/*.pkg) +basename=$(basename "$bundle") +sdkname=${basename%.*} +log "Found package $bundle (sdk $sdkname)." + +log "Expanding package $bundle to $staging/expanded..." +pkgutil --expand "$bundle" "$staging/expanded" + +dest=/Library/Developer/CoreSimulator/Profiles/Runtimes/$sdkname.simruntime +# The package would try to install itself into volume root; this is wrong. +log "Rewriting package install location to $dest..." +sed -I '' "s|