Skip to content

Commit

Permalink
[CI] Update iOS runtimes' download (#3265)
Browse files Browse the repository at this point in the history
  • Loading branch information
testableapple authored Jun 27, 2024
1 parent e7a60a6 commit 59f4177
Show file tree
Hide file tree
Showing 9 changed files with 171 additions and 69 deletions.
32 changes: 32 additions & 0 deletions .github/actions/setup-ios-runtime/action.yml
Original file line number Diff line number Diff line change
@@ -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
69 changes: 22 additions & 47 deletions .github/workflows/cron-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,17 @@ jobs:
- 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.3
os: macos-14
device: "iPhone 14 Pro Max"
device: "iPhone 14 Pro"
setup_runtime: true
- ios: 15.5
xcode: 15.3
os: macos-14
device: "iPhone 13"
setup_runtime: true
- ios: 14.5
xcode: 15.3
os: macos-14
device: "iPhone SE (2nd generation)"
setup_runtime: true
- ios: 13.7
xcode: 15.3
os: macos-14
device: "iPad Air (3rd generation)"
device: "iPhone 13 Pro"
setup_runtime: true
fail-fast: false
runs-on: ${{ matrix.os }}
Expand All @@ -85,20 +75,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: ~/Downloads/*.dmg
key: xcodes-runtime-ios-${{ matrix.ios }}
restore-keys: xcodes-runtime-ios-${{ matrix.ios }}
- name: Setup iOS ${{ matrix.ios }} Runtime
SKIP_BREW_BOOTSTRAP: true
- uses: ./.github/actions/setup-ios-runtime
if: ${{ matrix.setup_runtime }}
timeout-minutes: 60
run: |
brew install xcodesorg/made/xcodes
xcodes runtimes
sudo xcodes runtimes install 'iOS ${{ matrix.ios }}' --keep-archive
with:
version: ${{ matrix.ios }}
device: ${{ matrix.device }}
- name: Launch Allure TestOps
run: bundle exec fastlane allure_launch cron:true
- name: Run UI Tests (Debug)
Expand Down Expand Up @@ -143,27 +126,27 @@ jobs:
- ios: 17.4
xcode: 15.4
os: macos-14
device: "iPhone 14 Pro Max"
device: "iPhone 14 Pro"
setup_runtime: false
- ios: 16.4
xcode: 15.3
os: macos-14
device: "iPhone 14 Pro Max"
device: "iPhone 14 Pro"
setup_runtime: true
- ios: 15.5
xcode: 15.3
os: macos-14
device: "iPhone 13"
device: "iPhone 13 Pro"
setup_runtime: true
- ios: 14.5
xcode: 15.3
os: macos-14
device: "iPhone SE (2nd generation)"
xcode: 14.2
os: macos-12
device: "iPhone 12 Pro"
setup_runtime: true
- ios: 13.7
xcode: 15.3
os: macos-14
device: "iPad Air (3rd generation)"
xcode: 14.2
os: macos-12
device: "iPhone 11 Pro"
setup_runtime: true
fail-fast: false
runs-on: ${{ matrix.os }}
Expand All @@ -175,20 +158,12 @@ jobs:
- uses: ./.github/actions/bootstrap
env:
INSTALL_YEETD: true
- name: Cache iOS Simulator Runtime
uses: actions/cache@v4
id: runtime-cache
with:
path: ~/Downloads/*.dmg
key: xcodes-runtime-ios-${{ matrix.ios }}
restore-keys: xcodes-runtime-ios-${{ matrix.ios }}
- name: Setup iOS ${{ matrix.ios }} Runtime
- uses: ./.github/actions/setup-ios-runtime
if: ${{ matrix.setup_runtime }}
timeout-minutes: 60
run: |
brew install xcodesorg/made/xcodes
xcodes runtimes
sudo xcodes runtimes install 'iOS ${{ matrix.ios }}' --keep-archive
with:
version: ${{ matrix.ios }}
device: ${{ matrix.device }}
- name: Run LLC Tests (Debug)
run: bundle exec fastlane test device:"${{ matrix.device }} (${{ matrix.ios }})" cron:true
timeout-minutes: 100
Expand Down Expand Up @@ -224,7 +199,7 @@ jobs:
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/ruby-cache
- name: List Xcode versions xcversion sees
- name: List Xcode versions
run: mdfind "kMDItemCFBundleIdentifier = 'com.apple.dt.Xcode'"
- name: Build LLC
run: bundle exec fastlane test device:"iPhone 8" build_for_testing:true
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/smoke-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ jobs:
env:
INSTALL_YEETD: true
SKIP_MINT_BOOTSTRAP: true
SKIP_BREW_BOOTSTRAP: true
- name: Run UI Tests (Debug)
run: bundle exec fastlane test_ui device:"${{ env.IOS_SIMULATOR_DEVICE }}" skip_build:true record:${{ github.event.inputs.snapshots }}
timeout-minutes: 60
Expand Down Expand Up @@ -158,6 +159,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
Expand Down Expand Up @@ -224,7 +226,7 @@ jobs:
steps:
- uses: actions/[email protected]
- uses: ./.github/actions/ruby-cache
- name: List Xcode versions xcversion sees
- name: List Xcode versions
run: mdfind "kMDItemCFBundleIdentifier = 'com.apple.dt.Xcode'"
- name: Build LLC
run: bundle exec fastlane test device:"iPhone 13" build_for_testing:true
Expand Down
8 changes: 5 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -64,6 +67,7 @@ Carthage/
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

!fastlane/.env
fastlane/fastlane.log
fastlane/report.xml
fastlane/Preview.html
Expand Down Expand Up @@ -92,6 +96,7 @@ spm_cache/
buildcache
App Thinning Size Report.txt
app-thinning.plist
*.dmg

# gcloud
google-cloud-sdk
Expand All @@ -104,8 +109,5 @@ Products/
# Ignore Dependencies folder
Dependencies/

# Environment Variables
.env

# Ignore internal scheme
StreamChat.xcodeproj/xcshareddata/xcschemes/DemoApp-StreamDevelopers.xcscheme
7 changes: 5 additions & 2 deletions Scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ 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"
Expand Down
59 changes: 59 additions & 0 deletions Scripts/install_ios_runtime.sh
Original file line number Diff line number Diff line change
@@ -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|<pkg-info|<pkg-info install-location=\"$dest\"|" "$staging/expanded/PackageInfo"

log "Re-assembling the package $staging/$basename..."
pkgutil --flatten "$staging/expanded" "$staging/$basename"

log "Installing $staging/$basename..."
sudo installer -pkg "$staging/$basename" -target /

version=$(plutil -extract CFBundleName raw "$dest/Contents/Info.plist")
log "Installed $version."
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,11 @@ final class ChannelController_Tests: XCTestCase {
/// This test simulates a bug where the `channel` and `messages` fields were not updated if
/// they weren't touched before calling synchronize.
func test_synchronize_newDMChannelController_fieldsAreFetched_evenAfterCallingSynchronize() throws {
try XCTSkipIf(
ProcessInfo().operatingSystemVersion.majorVersion == 14,
"https://stream-io.atlassian.net/browse/PBE-4812"
)

setupControllerForNewDirectMessageChannel(
currentUserId: .unique,
otherUserId: .unique
Expand Down Expand Up @@ -4208,6 +4213,11 @@ final class ChannelController_Tests: XCTestCase {
}

func test_markUnread_whenIsNotMarkingAsRead_andCurrentUserIdIsPresent_whenThereAreOtherMessages_whenUpdaterSucceeds() throws {
try XCTSkipIf(
ProcessInfo().operatingSystemVersion.majorVersion == 13,
"https://stream-io.atlassian.net/browse/PBE-4812"
)

let messageId = MessageId.unique
let previousMessageId = MessageId.unique
let markedAsUnreadMessage = MessagePayload.dummy(messageId: messageId, createdAt: Date())
Expand Down
7 changes: 7 additions & 0 deletions fastlane/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT=180
FASTLANE_XCODEBUILD_SETTINGS_RETRIES=10
FASTLANE_SKIP_ACTION_SUMMARY=true
FASTLANE_HIDE_PLUGINS_TABLE=true
FASTLANE_SKIP_UPDATE_CHECK=true
FASTLANE_HIDE_CHANGELOG=true
Loading

0 comments on commit 59f4177

Please sign in to comment.