|
6 | 6 | pull_request: |
7 | 7 | branches: [ main ] |
8 | 8 |
|
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | + cancel-in-progress: true |
| 12 | + |
9 | 13 | jobs: |
10 | 14 | build: |
11 | | - name: Build and Test SDKHostApp scheme using any available iPhone simulator |
12 | | - runs-on: macos-latest |
| 15 | + name: Build & test SDKHostApp |
| 16 | + runs-on: macos-15 |
| 17 | + env: |
| 18 | + SCHEME: SDKHostApp |
| 19 | + PROJECT: IFTTT SDK.xcodeproj |
13 | 20 |
|
14 | 21 | steps: |
15 | 22 | - name: Checkout |
16 | | - uses: actions/checkout@v2 |
17 | | - - name: Build and Test |
18 | | - env: |
19 | | - scheme: ${{ 'SDKHostApp' }} |
| 23 | + uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Select Xcode |
| 26 | + uses: maxim-lobanov/setup-xcode@v1 |
| 27 | + with: |
| 28 | + xcode-version: latest-stable |
| 29 | + |
| 30 | + - name: Toolchain versions |
| 31 | + run: | |
| 32 | + xcodebuild -version |
| 33 | + swift --version |
| 34 | +
|
| 35 | + - name: Pick iPhone simulator |
| 36 | + id: sim |
| 37 | + run: | |
| 38 | + udid=$(xcrun simctl list devices available --json | python3 -c ' |
| 39 | + import json, sys |
| 40 | + data = json.load(sys.stdin) |
| 41 | + for runtime, devices in data["devices"].items(): |
| 42 | + if "iOS" not in runtime: |
| 43 | + continue |
| 44 | + for dev in devices: |
| 45 | + if dev["name"].startswith("iPhone") and dev.get("isAvailable", False): |
| 46 | + print(dev["udid"]) |
| 47 | + sys.exit(0) |
| 48 | + sys.exit("No available iPhone simulator found") |
| 49 | + ') |
| 50 | + echo "destination=platform=iOS Simulator,id=$udid" >> "$GITHUB_OUTPUT" |
| 51 | + echo "Using simulator $udid" |
| 52 | +
|
| 53 | + - name: Build & test |
20 | 54 | run: | |
21 | | - # xcrun xctrace returns via stderr, not the expected stdout (see https://developer.apple.com/forums/thread/663959) |
22 | | -
|
23 | | - if [ $scheme = default ]; then scheme=$(cat default); fi |
24 | | - |
25 | | - # Determine file to build: .xcworkspace or .xcodeproj |
26 | | - if [ "`ls -A | grep -i \\.xcworkspace\$`" ]; then filetype_parameter="workspace" && file_to_build="`ls -A | grep -i \\.xcworkspace\$`"; else filetype_parameter="project" && file_to_build="`ls -A | grep -i \\.xcodeproj\$`"; fi |
27 | | - |
28 | | - # Clean up whitespace |
29 | | - file_to_build=`echo $file_to_build | awk '{$1=$1;print}'` |
30 | | - |
31 | | - # Find first available simulator |
32 | | - device_name=$(xcrun simctl list devices available | grep "iPhone" | head -n 1 | sed -E 's/^[[:space:]]*([^()]+)[[:space:]]*\(.*$/\1/' | awk '{$1=$1; print}') |
33 | | -
|
34 | | - if [ -z "$device_name" ]; then |
35 | | - echo "❌ Failed to find a valid iOS device." |
36 | | - exit 1 |
37 | | - fi |
38 | | -
|
39 | | - echo "📱 Using device: $device_name" |
40 | | -
|
41 | | - # Build and run the tests |
| 55 | + set -o pipefail |
42 | 56 | xcodebuild test \ |
43 | | - -scheme "$scheme" \ |
44 | | - -"$filetype_parameter" "$file_to_build" \ |
45 | | - -destination "platform=iOS Simulator,name=$device_name" |
| 57 | + -project "$PROJECT" \ |
| 58 | + -scheme "$SCHEME" \ |
| 59 | + -destination "${{ steps.sim.outputs.destination }}" \ |
| 60 | + CODE_SIGNING_ALLOWED=NO \ |
| 61 | + | xcbeautify --renderer github-actions |
0 commit comments