Add GitHub Actions iOS CI workflow #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: iOS CI | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| pull_request: | |
| workflow_dispatch: | |
| concurrency: | |
| group: ios-ci-${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| build-and-test: | |
| name: Build and Test (SOPA) | |
| runs-on: macos-15 | |
| timeout-minutes: 30 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Select Xcode | |
| uses: maxim-lobanov/setup-xcode@v1 | |
| with: | |
| xcode-version: latest-stable | |
| - name: Show Xcode version | |
| run: | | |
| xcodebuild -version | |
| swift --version | |
| - name: Resolve Swift packages | |
| run: | | |
| xcodebuild \ | |
| -project SOPA.xcodeproj \ | |
| -scheme SOPA \ | |
| -resolvePackageDependencies | |
| - name: Find iOS simulator destination | |
| id: sim | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| RUNTIME=$(xcrun simctl list runtimes available | grep -E 'iOS 18\\.' | head -n 1 | awk -F'[()]' '{print $2}') | |
| if [[ -z "${RUNTIME:-}" ]]; then | |
| echo "No iOS 18.x runtime found on this runner." | |
| xcrun simctl list runtimes available | |
| exit 1 | |
| fi | |
| DEVICE_UDID=$(xcrun simctl list devices available "${RUNTIME}" | grep 'iPhone 16 (' | head -n 1 | awk -F '[()]' '{print $2}') | |
| if [[ -z "${DEVICE_UDID:-}" ]]; then | |
| echo "No iPhone 16 simulator found for runtime ${RUNTIME}." | |
| xcrun simctl list devices available "${RUNTIME}" | |
| exit 1 | |
| fi | |
| echo "destination=id=${DEVICE_UDID}" >> "$GITHUB_OUTPUT" | |
| echo "Using destination id=${DEVICE_UDID} on runtime ${RUNTIME}" | |
| - name: Build | |
| run: | | |
| xcodebuild \ | |
| -project SOPA.xcodeproj \ | |
| -scheme SOPA \ | |
| -destination '${{ steps.sim.outputs.destination }}' \ | |
| build | |
| - name: Test | |
| run: | | |
| xcodebuild \ | |
| -project SOPA.xcodeproj \ | |
| -scheme SOPA \ | |
| -destination '${{ steps.sim.outputs.destination }}' \ | |
| -resultBundlePath TestResults.xcresult \ | |
| test | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: xcresult | |
| path: TestResults.xcresult | |
| if-no-files-found: ignore |