|
| 1 | +name: iOS CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + pull_request: |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: ios-ci-${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + build-and-test: |
| 16 | + name: Build and Test (SOPA) |
| 17 | + runs-on: macos-15 |
| 18 | + timeout-minutes: 30 |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Select Xcode |
| 25 | + uses: maxim-lobanov/setup-xcode@v1 |
| 26 | + with: |
| 27 | + xcode-version: latest-stable |
| 28 | + |
| 29 | + - name: Show Xcode version |
| 30 | + run: | |
| 31 | + xcodebuild -version |
| 32 | + swift --version |
| 33 | +
|
| 34 | + - name: Resolve Swift packages |
| 35 | + run: | |
| 36 | + xcodebuild \ |
| 37 | + -project SOPA.xcodeproj \ |
| 38 | + -scheme SOPA \ |
| 39 | + -resolvePackageDependencies |
| 40 | +
|
| 41 | + - name: Find iOS simulator destination |
| 42 | + id: sim |
| 43 | + shell: bash |
| 44 | + run: | |
| 45 | + set -euo pipefail |
| 46 | + RUNTIME=$(xcrun simctl list runtimes available | grep -E 'iOS 18\\.' | head -n 1 | awk -F'[()]' '{print $2}') |
| 47 | +
|
| 48 | + if [[ -z "${RUNTIME:-}" ]]; then |
| 49 | + echo "No iOS 18.x runtime found on this runner." |
| 50 | + xcrun simctl list runtimes available |
| 51 | + exit 1 |
| 52 | + fi |
| 53 | +
|
| 54 | + DEVICE_UDID=$(xcrun simctl list devices available "${RUNTIME}" | grep 'iPhone 16 (' | head -n 1 | awk -F '[()]' '{print $2}') |
| 55 | +
|
| 56 | + if [[ -z "${DEVICE_UDID:-}" ]]; then |
| 57 | + echo "No iPhone 16 simulator found for runtime ${RUNTIME}." |
| 58 | + xcrun simctl list devices available "${RUNTIME}" |
| 59 | + exit 1 |
| 60 | + fi |
| 61 | +
|
| 62 | + echo "destination=id=${DEVICE_UDID}" >> "$GITHUB_OUTPUT" |
| 63 | + echo "Using destination id=${DEVICE_UDID} on runtime ${RUNTIME}" |
| 64 | +
|
| 65 | + - name: Build |
| 66 | + run: | |
| 67 | + xcodebuild \ |
| 68 | + -project SOPA.xcodeproj \ |
| 69 | + -scheme SOPA \ |
| 70 | + -destination '${{ steps.sim.outputs.destination }}' \ |
| 71 | + build |
| 72 | +
|
| 73 | + - name: Test |
| 74 | + run: | |
| 75 | + xcodebuild \ |
| 76 | + -project SOPA.xcodeproj \ |
| 77 | + -scheme SOPA \ |
| 78 | + -destination '${{ steps.sim.outputs.destination }}' \ |
| 79 | + -resultBundlePath TestResults.xcresult \ |
| 80 | + test |
| 81 | +
|
| 82 | + - name: Upload test results |
| 83 | + if: always() |
| 84 | + uses: actions/upload-artifact@v4 |
| 85 | + with: |
| 86 | + name: xcresult |
| 87 | + path: TestResults.xcresult |
| 88 | + if-no-files-found: ignore |
0 commit comments