|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +COMMIT="${1:?Usage: just upgrade-test <commit-or-tag>}" |
| 5 | +REPO_ROOT="$(git rev-parse --show-toplevel)" |
| 6 | +WORKTREE_DIR="/tmp/gem-upgrade-test-$$" |
| 7 | +SIMULATOR_NAME="${SIMULATOR_NAME:-iPhone 17}" |
| 8 | +SIMULATOR_DEST="platform=iOS Simulator,name=$SIMULATOR_NAME" |
| 9 | +OLD_DERIVED_DATA="$WORKTREE_DIR/build/DerivedData" |
| 10 | +OLD_SPM_CACHE="$WORKTREE_DIR/build/SourcePackages" |
| 11 | +BUILD_THREADS="$(sysctl -n hw.ncpu)" |
| 12 | + |
| 13 | +cleanup() { |
| 14 | + echo "==> Cleaning up worktree" |
| 15 | + cd "$REPO_ROOT" |
| 16 | + git worktree remove --force "$WORKTREE_DIR" 2>/dev/null || true |
| 17 | +} |
| 18 | +trap cleanup EXIT |
| 19 | + |
| 20 | +echo "==> Phase 1: Build old version ($COMMIT)" |
| 21 | + |
| 22 | +git worktree add "$WORKTREE_DIR" "$COMMIT" |
| 23 | +cd "$WORKTREE_DIR" |
| 24 | +git submodule update --init |
| 25 | + |
| 26 | +echo "==> Generating stone (old)" |
| 27 | +just generate-stone |
| 28 | + |
| 29 | +echo "==> Building old version for UI testing" |
| 30 | +set -o pipefail && xcodebuild -project Gem.xcodeproj \ |
| 31 | + -scheme GemUITests \ |
| 32 | + -testPlan ui_tests \ |
| 33 | + ONLY_ACTIVE_ARCH=YES \ |
| 34 | + -destination "$SIMULATOR_DEST" \ |
| 35 | + -derivedDataPath "$OLD_DERIVED_DATA" \ |
| 36 | + -clonedSourcePackagesDirPath "$OLD_SPM_CACHE" \ |
| 37 | + -allowProvisioningUpdates \ |
| 38 | + -allowProvisioningDeviceRegistration \ |
| 39 | + -parallelizeTargets \ |
| 40 | + -jobs "$BUILD_THREADS" \ |
| 41 | + build-for-testing | xcbeautify --quieter --is-ci |
| 42 | + |
| 43 | +echo "==> Resetting simulator" |
| 44 | +cd "$REPO_ROOT" |
| 45 | +just reset-simulator |
| 46 | + |
| 47 | +echo "==> Running ImportWalletReceiveBitcoinUITests (old version)" |
| 48 | +cd "$WORKTREE_DIR" |
| 49 | +set -o pipefail && xcodebuild -project Gem.xcodeproj \ |
| 50 | + -scheme GemUITests \ |
| 51 | + -testPlan ui_tests \ |
| 52 | + ONLY_ACTIVE_ARCH=YES \ |
| 53 | + -destination "$SIMULATOR_DEST" \ |
| 54 | + -derivedDataPath "$OLD_DERIVED_DATA" \ |
| 55 | + -clonedSourcePackagesDirPath "$OLD_SPM_CACHE" \ |
| 56 | + -allowProvisioningUpdates \ |
| 57 | + -allowProvisioningDeviceRegistration \ |
| 58 | + -only-testing GemUITests/ImportWalletReceiveBitcoinUITests \ |
| 59 | + test-without-building | xcbeautify --quieter --is-ci |
| 60 | + |
| 61 | +echo "==> Phase 2: Build current version" |
| 62 | +cd "$REPO_ROOT" |
| 63 | + |
| 64 | +just build-for-testing-ui |
| 65 | + |
| 66 | +DERIVED_DATA="build/DerivedData" |
| 67 | +SPM_CACHE="build/SourcePackages" |
| 68 | + |
| 69 | +echo "==> Running UpgradeVerificationTests (current version)" |
| 70 | +set -o pipefail && xcodebuild -project Gem.xcodeproj \ |
| 71 | + -scheme GemUITests \ |
| 72 | + -testPlan ui_tests \ |
| 73 | + ONLY_ACTIVE_ARCH=YES \ |
| 74 | + -destination "$SIMULATOR_DEST" \ |
| 75 | + -derivedDataPath "$DERIVED_DATA" \ |
| 76 | + -clonedSourcePackagesDirPath "$SPM_CACHE" \ |
| 77 | + -allowProvisioningUpdates \ |
| 78 | + -allowProvisioningDeviceRegistration \ |
| 79 | + -only-testing GemUITests/UpgradeVerificationTests \ |
| 80 | + test-without-building | xcbeautify --quieter --is-ci |
| 81 | + |
| 82 | +echo "==> Upgrade test passed!" |
0 commit comments