|
| 1 | +name: (i|tv)(Pad)OS |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + |
| 6 | +jobs: |
| 7 | + ios-SPM: |
| 8 | + name: SPM ${{ matrix.destination }} Xcode ${{ matrix.config.xcode }} [${{ matrix.build_config }}] |
| 9 | + runs-on: ${{ matrix.config.os }} |
| 10 | + strategy: |
| 11 | + fail-fast: false |
| 12 | + matrix: |
| 13 | + config: # newer versions at top |
| 14 | + - { os: "macos-15", xcode: "16.0" } |
| 15 | + - { os: "macos-14", xcode: "15.4" } |
| 16 | + destination: |
| 17 | + - iOS |
| 18 | + - tvOS |
| 19 | + build_config: |
| 20 | + - Debug |
| 21 | + - Release |
| 22 | + steps: |
| 23 | + - uses: actions/checkout@v4 |
| 24 | + |
| 25 | + - name: Cache SPM dependencies |
| 26 | + uses: actions/cache@v4 |
| 27 | + with: |
| 28 | + path: | |
| 29 | + ~/Library/Caches/org.swift.swiftpm |
| 30 | + ~/Library/Developer/Xcode/DerivedData/**/SourcePackages |
| 31 | + key: ${{ runner.os }}-spm-xcode-${{ hashFiles('Package.resolved', '**/*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }} |
| 32 | + restore-keys: | |
| 33 | + ${{ runner.os }}-spm-xcode- |
| 34 | +
|
| 35 | + - name: Select Xcode ${{ matrix.config.xcode }} |
| 36 | + run: sudo xcode-select -s /Applications/Xcode_${{ matrix.config.xcode }}.app |
| 37 | + |
| 38 | + - name: Find Simulator |
| 39 | + run: | |
| 40 | + SIMULATOR_NAME=$(xcodebuild -showdestinations -scheme "shared-actions-Package" | perl -nle 'if (m/${{ matrix.destination }}\sSimulator.*name\:([^\}]+)\s\}\.*/g && $1 !~ /^Any/ && $1 !~ /SE/) { print $1; }' | sort -r | head -n 1) |
| 41 | + echo "Found simulator: $SIMULATOR_NAME" |
| 42 | + echo "SIMULATOR_NAME=$SIMULATOR_NAME" >> $GITHUB_ENV |
| 43 | +
|
| 44 | + - name: Build ${{ matrix.build_config }} for Any ${{ matrix.destination }} Device |
| 45 | + run: | |
| 46 | + xcodebuild build -scheme "shared-actions-Package" -configuration ${{ matrix.build_config }} -destination "generic/platform=${{ matrix.destination }},name=Any ${{ matrix.destination }} Device" |
| 47 | +
|
| 48 | + - name: Build ${{ matrix.build_config }} for testing on ${{ matrix.destination }} Simulator |
| 49 | + run: | # https://developer.apple.com/documentation/xcode/build-settings-reference#Enable-Testability |
| 50 | + xcodebuild build-for-testing -scheme "shared-actions-Package" -configuration ${{ matrix.build_config }} -destination "platform=${{ matrix.destination }} Simulator,OS=latest,name=$SIMULATOR_NAME" ENABLE_TESTABILITY=YES |
| 51 | +
|
| 52 | + - name: Test ${{ matrix.build_config }} on ${{ matrix.destination }} Simulator |
| 53 | + run: | |
| 54 | + set -o pipefail && env NSUnbufferedIO=YES xcodebuild test-without-building -scheme "shared-actions-Package" -configuration ${{ matrix.build_config }} -destination "platform=${{ matrix.destination }} Simulator,OS=latest,name=$SIMULATOR_NAME" |
| 55 | +
|
| 56 | + - name: Upload failure artifacts |
| 57 | + if: failure() |
| 58 | + uses: actions/upload-artifact@v4 |
| 59 | + with: |
| 60 | + name: ${{ runner.os }}-${{ github.job }}-swift_${{ matrix.config.xcode }}-${{ matrix.destination }}-${{ matrix.build_config }}-${{ github.run_id }} |
| 61 | + path: | |
| 62 | + ~/Library/Developer/Xcode/DerivedData/ |
| 63 | + if-no-files-found: warn |
| 64 | + include-hidden-files: true |
0 commit comments