Skip to content

Commit 89541c3

Browse files
authored
chore: update unit tests settings for github actions (#463)
1 parent 9d39558 commit 89541c3

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

.github/workflows/swift.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
- uses: actions/checkout@v3
3838
- uses: maxim-lobanov/setup-xcode@v1
3939
with:
40-
xcode-version: '12.4'
40+
xcode-version: 12.4
4141
- env:
4242
SRCCLR_API_TOKEN: ${{ secrets.SRCCLR_API_TOKEN }}
4343
run: |
@@ -47,7 +47,10 @@ jobs:
4747
4848
unittests:
4949
if: "${{ github.event.inputs.PREP == '' && github.event.inputs.RELEASE == '' }}"
50-
uses: optimizely/swift-sdk/.github/workflows/unit_tests.yml@master
50+
51+
#[TODO]: change to @master again
52+
#uses: optimizely/swift-sdk/.github/workflows/unit_tests.yml@master
53+
uses: optimizely/swift-sdk/.github/workflows/unit_tests.yml@jae/version-update
5154

5255
prepare_for_release:
5356
runs-on: macos-latest
@@ -56,7 +59,7 @@ jobs:
5659
- uses: actions/checkout@v3
5760
- uses: maxim-lobanov/setup-xcode@v1
5861
with:
59-
xcode-version: '12.4'
62+
xcode-version: 12.4
6063
- id: prepare_for_release
6164
name: Prepare for release
6265
env:
@@ -79,7 +82,7 @@ jobs:
7982
- uses: actions/checkout@v3
8083
- uses: maxim-lobanov/setup-xcode@v1
8184
with:
82-
xcode-version: '12.4'
85+
xcode-version: 12.4
8386
- name: Push to cocoapods.org
8487
env:
8588
GITHUB_TOKEN: ${{ secrets.CI_USER_TOKEN }}

.github/workflows/unit_tests.yml

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,35 +11,41 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14+
# github actions are very poor in supporting iOS simulators:
15+
# - multiple Xcode versions are pre installed (not all versions and they change supported xcode versions frequently)
16+
# - each xcode version has own simulator os versions.
17+
# - so to run tests with the target simulator, we have to find a proper xcode version pre-installed and support the target simulator os version.
18+
# also, the xcode version (simulator_xcode_version) and simulator os versions (os) are moving target. We have to change these time to time.
1419
include:
15-
- os: 14.4
20+
- os: 15.2
1621
device: "iPhone 11"
1722
scheme: "OptimizelySwiftSDK-iOS"
1823
test_sdk: "iphonesimulator"
1924
platform: "iOS Simulator"
2025
os_type: "iOS"
21-
simulator_xcode_version: 12.4
22-
- os: 13.3
26+
simulator_xcode_version: 13.2
27+
- os: 14.4
2328
device: "iPhone 8"
2429
scheme: "OptimizelySwiftSDK-iOS"
2530
test_sdk: "iphonesimulator"
2631
platform: "iOS Simulator"
2732
os_type: "iOS"
28-
simulator_xcode_version: 11.3.1
29-
- os: 12.4
30-
device: "iPad Air"
33+
simulator_xcode_version: 12.4
34+
- os: 13.7
35+
# good to have tests with older OS versions, but it looks like this is min OS+xcode versions supported by github actions
36+
device: "iPad Air (3rd generation)"
3137
scheme: "OptimizelySwiftSDK-iOS"
3238
test_sdk: "iphonesimulator"
3339
platform: "iOS Simulator"
3440
os_type: "iOS"
35-
simulator_xcode_version: 10.3
36-
- os: 12.4
41+
simulator_xcode_version: 11.7
42+
- os: 13.4
3743
device: "Apple TV 4K"
3844
scheme: "OptimizelySwiftSDK-tvOS"
3945
test_sdk: "appletvsimulator"
4046
platform: "tvOS Simulator"
4147
os_type: "tvOS"
42-
simulator_xcode_version: 10.3
48+
simulator_xcode_version: 11.7
4349
steps:
4450
- uses: actions/checkout@v3
4551
- uses: maxim-lobanov/setup-xcode@v1
@@ -68,6 +74,16 @@ jobs:
6874
pod repo update
6975
pod install
7076
HOMEBREW_NO_INSTALL_CLEANUP=true brew update && brew install jq
77+
78+
# github actions are very poor in supporting iOS simulators:
79+
# - to find pre-installed xcode version, run this:
80+
# > ls /Applications/
81+
# - to find supported simulator os versions, run this (and find simulator with non-error "datapath")
82+
# > xcrun simctl list --json devices
83+
84+
# switch to the target xcode version
85+
sudo xcode-select -switch /Applications/Xcode_$SIMULATOR_XCODE_VERSION.app
86+
7187
Scripts/prepare_simulator.sh
7288
Scripts/run_unit_tests.sh
7389
- name: Check on failures (Archive Test Results)

Scripts/prepare_simulator.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ set -eou pipefail
1212
# More about XCode and its compatible simulators can be found here: https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md
1313
# https://github.com/actions/virtual-environments/issues/551
1414

15-
if [ "$SIMULATOR_XCODE_VERSION" != 12.4 ]; then
15+
# Older than Xcode 12 (12.4?) has different paths
16+
MAJOR_SIMULATOR_XCODE_VERSION=$(echo $SIMULATOR_XCODE_VERSION | cut -d. -f1)
17+
if [ "$MAJOR_SIMULATOR_XCODE_VERSION" -lt 12 ]; then
1618
os_folder="iPhoneOS"
1719
os="${OS/./-}"
18-
name="${NAME// /-}"
20+
name="${NAME//[ ()]/-}"
1921

2022
sudo mkdir -p /Library/Developer/CoreSimulator/Profiles/Runtimes
2123

0 commit comments

Comments
 (0)