Skip to content

Commit b127c70

Browse files
authored
Merge pull request #6 from tokijh/update-ci
Update CI script to dynamically select the latest available simulator
2 parents c54e3d3 + 7884c54 commit b127c70

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,48 @@ on:
99
jobs:
1010
test:
1111
runs-on: macOS-latest
12+
13+
env:
14+
SCHEME: WeakMapTable
15+
CODECOV_PACKAGE_NAME: WeakMapTable
16+
1217
strategy:
18+
fail-fast: false
1319
matrix:
1420
env:
1521
- sdk: iphonesimulator
16-
destination: platform=iOS Simulator,name=iPhone 12 Pro,OS=latest
17-
1822
- sdk: macosx
19-
destination: arch=x86_64
20-
2123
- sdk: appletvsimulator
22-
destination: platform=tvOS Simulator,name=Apple TV,OS=latest
2324

2425
steps:
25-
- uses: actions/checkout@v2
26+
- uses: actions/checkout@v4
27+
28+
- name: List SDKs and Devices
29+
run: xcodebuild -showsdks; xcrun xctrace list devices
30+
31+
- uses: maxim-lobanov/setup-xcode@v1
32+
with:
33+
xcode-version: latest-stable
34+
35+
- name: Select iOS Simulator dynamically
36+
if: matrix.env.sdk == 'iphonesimulator'
37+
run: |
38+
OS_VERSION=$(xcrun simctl list runtimes | grep 'iOS' | grep -oE '[0-9]+\.[0-9]+' | sort -Vr | head -n1)
39+
DEVICE_NAME=$(xcrun simctl list devices | grep -A 20 "^-- iOS $OS_VERSION --" | grep -E '^ *iPhone [0-9]+ \(' | grep -v 'Pro\|Plus\|SE\|unavailable' | sed -E 's/^[[:space:]]*([^()]+) \(.*/\1/' | sort -t' ' -k2 -n -r | head -n1)
40+
echo "Using simulator: $DEVICE_NAME (iOS $OS_VERSION)"
41+
echo "DESTINATION=platform=iOS Simulator,name=$DEVICE_NAME,OS=$OS_VERSION" >> $GITHUB_ENV
2642
27-
- name: Select Xcode 12.4
28-
run: sudo xcode-select -s /Applications/Xcode_12.4.app
43+
- name: Set macOS destination
44+
if: matrix.env.sdk == 'macosx'
45+
run: echo "DESTINATION=arch=x86_64" >> $GITHUB_ENV
2946

30-
- name: Generate Xcode Project
31-
run: swift package generate-xcodeproj --enable-code-coverage
47+
- name: Set tvOS destination
48+
if: matrix.env.sdk == 'appletvsimulator'
49+
run: echo "DESTINATION=platform=tvOS Simulator,name=Apple TV,OS=latest" >> $GITHUB_ENV
3250

3351
- name: Build and Test
3452
run: |
35-
set -o pipefail && xcodebuild clean build test \
36-
-project "$PROJECT" \
53+
set -o pipefail && xcodebuild build test \
3754
-scheme "$SCHEME" \
3855
-sdk "$SDK" \
3956
-destination "$DESTINATION" \
@@ -42,10 +59,8 @@ jobs:
4259
-resultBundlePath "./${{ matrix.env.sdk }}.xcresult" \
4360
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO | xcpretty -c;
4461
env:
45-
PROJECT: WeakMapTable.xcodeproj
46-
SCHEME: WeakMapTable-Package
4762
SDK: ${{ matrix.env.sdk }}
48-
DESTINATION: ${{ matrix.env.destination }}
63+
DESTINATION: ${{ env.DESTINATION }}
4964

5065
- name: Upload coverage to Codecov
5166
uses: codecov/[email protected]

0 commit comments

Comments
 (0)