|
1 | 1 | name: Xcode Project
|
2 |
| -on: [push, workflow_dispatch] |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '**' |
| 7 | + tags-ignore: |
| 8 | + - '**' |
| 9 | + paths-ignore: |
| 10 | + - .gitignore |
| 11 | + - LICENSE |
| 12 | + - README.md |
3 | 13 |
|
4 | 14 | jobs:
|
5 | 15 | ios:
|
6 | 16 | name: iOS
|
7 | 17 | runs-on: macOS-latest
|
| 18 | + env: |
| 19 | + LOGSDIR: /tmp/.keyvalueobservation.xcodebuild/iOS/Logs |
8 | 20 |
|
9 | 21 | steps:
|
10 | 22 | - name: Checkout Code
|
11 | 23 | uses: actions/checkout@v2
|
12 | 24 |
|
| 25 | + - name: Setup Environment |
| 26 | + run: | |
| 27 | + mkdir -p "$LOGSDIR" |
| 28 | +
|
13 | 29 | - name: Build iOS
|
14 | 30 | run: |
|
15 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -destination "generic/platform=iOS" -configuration Debug |
| 31 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -destination "generic/platform=iOS" -configuration Debug 2>&1 | tee "$LOGSDIR/build-ios.log" |
16 | 32 |
|
17 | 33 | - name: Build iOS Simulator
|
18 | 34 | run: |
|
19 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -destination "generic/platform=iOS Simulator" -configuration Debug |
| 35 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -destination "generic/platform=iOS Simulator" -configuration Debug 2>&1 | tee "$LOGSDIR/build-iossimulator.log" |
20 | 36 |
|
21 | 37 | - name: Test
|
22 | 38 | run: |
|
23 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -testPlan "KeyValueObservationTests" -destination "platform=iOS Simulator,name=iPhone 12 Pro Max" -configuration Debug ONLY_ACTIVE_ARCH=YES test |
| 39 | + IOS_SIM="$(xcrun simctl list devices available | grep "iPhone [0-9]" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" |
| 40 | + if [ "${#IOS_SIM}" == "0" ]; then |
| 41 | + IOS_SIM = "iPhone 12 Pro" # Fallback Simulator |
| 42 | + fi |
| 43 | +
|
| 44 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -testPlan "KeyValueObservationTests" -destination "platform=iOS Simulator,name=$IOS_SIM" -configuration Debug ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-ios.log" |
| 45 | +
|
| 46 | + - name: Upload Logs |
| 47 | + uses: actions/upload-artifact@v2 |
| 48 | + if: always() |
| 49 | + with: |
| 50 | + name: iOSBuildLogs |
| 51 | + path: ${{ env.LOGSDIR }}/*.log |
24 | 52 |
|
25 | 53 | maccatalyst:
|
26 | 54 | name: Mac Catalyst
|
27 | 55 | runs-on: macOS-latest
|
| 56 | + env: |
| 57 | + LOGSDIR: /tmp/.keyvalueobservation.xcodebuild/macCatalyst/Logs |
28 | 58 |
|
29 | 59 | steps:
|
30 | 60 | - name: Checkout Code
|
31 | 61 | uses: actions/checkout@v2
|
32 | 62 |
|
| 63 | + - name: Setup Environment |
| 64 | + run: | |
| 65 | + mkdir -p "$LOGSDIR" |
| 66 | +
|
33 | 67 | - name: Build
|
34 | 68 | run: |
|
35 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -destination "generic/platform=macOS,variant=Mac Catalyst" -configuration Debug |
| 69 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -destination "generic/platform=macOS,variant=Mac Catalyst" -configuration Debug 2>&1 | tee "$LOGSDIR/build-maccatalyst.log" |
36 | 70 |
|
37 | 71 | - name: Test
|
38 | 72 | run: |
|
39 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -testPlan "KeyValueObservationTests" -destination "platform=macOS,variant=Mac Catalyst" -configuration Debug ONLY_ACTIVE_ARCH=YES test |
| 73 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -testPlan "KeyValueObservationTests" -destination "platform=macOS,variant=Mac Catalyst" -configuration Debug ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-maccatalyst.log" |
| 74 | +
|
| 75 | + - name: Upload Logs |
| 76 | + uses: actions/upload-artifact@v2 |
| 77 | + if: always() |
| 78 | + with: |
| 79 | + name: MacCatalystBuildLogs |
| 80 | + path: ${{ env.LOGSDIR }}/*.log |
40 | 81 |
|
41 | 82 | macos:
|
42 | 83 | name: macOS
|
43 | 84 | runs-on: macOS-latest
|
| 85 | + env: |
| 86 | + LOGSDIR: /tmp/.keyvalueobservation.xcodebuild/macOS/Logs |
44 | 87 |
|
45 | 88 | steps:
|
46 | 89 | - name: Checkout Code
|
47 | 90 | uses: actions/checkout@v2
|
48 | 91 |
|
| 92 | + - name: Setup Environment |
| 93 | + run: | |
| 94 | + mkdir -p "$LOGSDIR" |
| 95 | +
|
49 | 96 | - name: Build
|
50 | 97 | run: |
|
51 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation macOS" -destination "generic/platform=macOS" -configuration Debug |
| 98 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation macOS" -destination "generic/platform=macOS" -configuration Debug 2>&1 | tee "$LOGSDIR/build-macos.log" |
52 | 99 |
|
53 | 100 | - name: Test
|
54 | 101 | run: |
|
55 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation macOS" -testPlan "KeyValueObservation macOS Tests" -configuration Debug -enableCodeCoverage YES test |
| 102 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation macOS" -testPlan "KeyValueObservation macOS Tests" -derivedDataPath ".xcodebuild" -configuration Debug ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-macos.log" |
| 103 | +
|
| 104 | + - name: Generate Code Coverage File |
| 105 | + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 106 | + run: | |
| 107 | + PROFDATA_FILE="$(find .xcodebuild -name "*.profdata")" |
| 108 | +
|
| 109 | + xcrun llvm-cov export --format=lcov --instr-profile="$PROFDATA_FILE" ".xcodebuild/Build/Products/Debug/KeyValueObservationTests.xctest/Contents/MacOS/KeyValueObservationTests" > "./codecov.lcov" |
56 | 110 |
|
57 | 111 | - name: Upload Code Coverage
|
58 | 112 | if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
59 | 113 | uses: codecov/codecov-action@v2
|
60 | 114 | with:
|
61 | 115 | token: ${{ secrets.CODECOV_TOKEN }}
|
| 116 | + file: ./codecov.lcov |
62 | 117 | verbose: true
|
63 | 118 |
|
| 119 | + - name: Upload Logs |
| 120 | + uses: actions/upload-artifact@v2 |
| 121 | + if: always() |
| 122 | + with: |
| 123 | + name: macOSBuildLogs |
| 124 | + path: ${{ env.LOGSDIR }}/*.log |
| 125 | + |
64 | 126 | tvos:
|
65 | 127 | name: tvOS
|
66 | 128 | runs-on: macOS-latest
|
| 129 | + env: |
| 130 | + LOGSDIR: /tmp/.keyvalueobservation.xcodebuild/tvOS/Logs |
67 | 131 |
|
68 | 132 | steps:
|
69 | 133 | - name: Checkout Code
|
70 | 134 | uses: actions/checkout@v2
|
71 | 135 |
|
| 136 | + - name: Setup Environment |
| 137 | + run: | |
| 138 | + mkdir -p "$LOGSDIR" |
| 139 | +
|
72 | 140 | - name: Build tvOS
|
73 | 141 | run: |
|
74 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation tvOS" -destination "generic/platform=tvOS" -configuration Debug |
| 142 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation tvOS" -destination "generic/platform=tvOS" -configuration Debug 2>&1 | tee "$LOGSDIR/build-tvos.log" |
75 | 143 |
|
76 | 144 | - name: Build tvOS Simulator
|
77 | 145 | run: |
|
78 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation tvOS" -destination "generic/platform=tvOS Simulator" -configuration Debug |
| 146 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation tvOS" -destination "generic/platform=tvOS Simulator" -configuration Debug 2>&1 | tee "$LOGSDIR/build-tvossimulator.log" |
79 | 147 |
|
80 | 148 | - name: Test
|
81 | 149 | run: |
|
82 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation tvOS" -testPlan "KeyValueObservation tvOS Tests" -destination "platform=tvOS Simulator,name=Apple TV 4K" -configuration Debug ONLY_ACTIVE_ARCH=YES test |
| 150 | + TVOS_SIM="$(xcrun simctl list devices available | grep "Apple TV" | sort -V | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" |
| 151 | + if [ "${#TVOS_SIM}" == "0" ]; then |
| 152 | + TVOS_SIM = "Apple TV" # Fallback Simulator |
| 153 | + fi |
| 154 | +
|
| 155 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation tvOS" -testPlan "KeyValueObservation tvOS Tests" -destination "platform=tvOS Simulator,name=$TVOS_SIM" -configuration Debug ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-tvos.log" |
| 156 | +
|
| 157 | + - name: Upload Logs |
| 158 | + uses: actions/upload-artifact@v2 |
| 159 | + if: always() |
| 160 | + with: |
| 161 | + name: tvOSBuildLogs |
| 162 | + path: ${{ env.LOGSDIR }}/*.log |
83 | 163 |
|
84 | 164 | watchos:
|
85 | 165 | name: watchOS
|
86 | 166 | runs-on: macOS-11
|
| 167 | + env: |
| 168 | + LOGSDIR: /tmp/.keyvalueobservation.xcodebuild/watchOS/Logs |
87 | 169 |
|
88 | 170 | steps:
|
89 | 171 | - name: Checkout Code
|
90 | 172 | uses: actions/checkout@v2
|
91 | 173 |
|
| 174 | + - name: Setup Environment |
| 175 | + run: | |
| 176 | + mkdir -p "$LOGSDIR" |
| 177 | +
|
92 | 178 | - name: Build watchOS
|
93 | 179 | run: |
|
94 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation watchOS" -destination "generic/platform=watchOS" -configuration Debug |
| 180 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation watchOS" -destination "generic/platform=watchOS" -configuration Debug 2>&1 | tee "$LOGSDIR/build-watchos.log" |
95 | 181 |
|
96 | 182 | - name: Build watchOS Simulator
|
97 | 183 | run: |
|
98 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation watchOS" -destination "generic/platform=watchOS Simulator" -configuration Debug |
| 184 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation watchOS" -destination "generic/platform=watchOS Simulator" -configuration Debug 2>&1 | tee "$LOGSDIR/build-watchossimulator.log" |
99 | 185 |
|
100 | 186 | - name: Test
|
101 | 187 | run: |
|
102 |
| - xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation watchOS" -testPlan "KeyValueObservation watchOS Tests" -destination "platform=watchOS Simulator,name=Apple Watch Series 6 - 44mm" -configuration Debug ONLY_ACTIVE_ARCH=YES test |
| 188 | + WATCHOS_SIM="$(xcrun simctl list devices available | grep "Apple Watch" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')" |
| 189 | + if [ "${#WATCHOS_SIM}" == "0" ]; then |
| 190 | + WATCHOS_SIM = "Apple Watch Series 6 - 44mm" # Fallback Simulator |
| 191 | + fi |
| 192 | +
|
| 193 | + xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation watchOS" -testPlan "KeyValueObservation watchOS Tests" -destination "platform=watchOS Simulator,name=$WATCHOS_SIM" -configuration Debug ONLY_ACTIVE_ARCH=YES test 2>&1 | tee "$LOGSDIR/test-watchos.log" |
| 194 | +
|
| 195 | + - name: Upload Logs |
| 196 | + uses: actions/upload-artifact@v2 |
| 197 | + if: always() |
| 198 | + with: |
| 199 | + name: watchOSBuildLogs |
| 200 | + path: ${{ env.LOGSDIR }}/*.log |
0 commit comments