11name : Xcode Project
2- on : [push, workflow_dispatch]
2+ on :
3+ workflow_dispatch :
4+ push :
5+ tags-ignore :
6+ - **
7+ paths-ignore :
8+ - .gitignore
9+ - LICENSE
10+ - README.md
311
412jobs :
513 ios :
2028
2129 - name : Test
2230 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
31+ IOS_SIM="$(xcrun simctl list devices available | grep "iPhone [0-9]" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')"
32+ if [ "${#IOS_SIM}" == "0" ]; then
33+ IOS_SIM = "iPhone 12 Pro" # Fallback Simulator
34+ fi
35+
36+ xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation" -testPlan "KeyValueObservationTests" -destination "platform=iOS Simulator,name=$IOS_SIM" -configuration Debug ONLY_ACTIVE_ARCH=YES test
2437
2538 maccatalyst :
2639 name : Mac Catalyst
@@ -52,13 +65,21 @@ jobs:
5265
5366 - name : Test
5467 run : |
55- xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation macOS" -testPlan "KeyValueObservation macOS Tests" -configuration Debug -enableCodeCoverage YES test
68+ xcodebuild -project KeyValueObservation.xcodeproj -scheme "KeyValueObservation macOS" -testPlan "KeyValueObservation macOS Tests" -derivedDataPath ".xcodebuild" -configuration Debug ONLY_ACTIVE_ARCH=YES test
69+
70+ - name : Generate Code Coverage File
71+ if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
72+ run : |
73+ PROFDATA_FILE="$(find .xcodebuild -name "*.profdata")"
74+
75+ xcrun llvm-cov export --format=lcov --instr-profile="$PROFDATA_FILE" ".xcodebuild/Build/Products/Debug/KeyValueObservationTests.xctest/Contents/MacOS/KeyValueObservationTests" > "./codecov.lcov"
5676
5777 - name : Upload Code Coverage
5878 if : ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
5979 uses : codecov/codecov-action@v2
6080 with :
6181 token : ${{ secrets.CODECOV_TOKEN }}
82+ file : ./codecov.lcov
6283 verbose : true
6384
6485 tvos :
@@ -79,7 +100,12 @@ jobs:
79100
80101 - name : Test
81102 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
103+ TVOS_SIM="$(xcrun simctl list devices available | grep "Apple TV" | sort -V | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')"
104+ if [ "${#TVOS_SIM}" == "0" ]; then
105+ TVOS_SIM = "Apple TV" # Fallback Simulator
106+ fi
107+
108+ 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
83109
84110 watchos :
85111 name : watchOS
99125
100126 - name : Test
101127 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
128+ WATCHOS_SIM="$(xcrun simctl list devices available | grep "Apple Watch" | sort -rV | head -n 1 | sed -E 's/(.+)[ ]*\([^)]*\)[ ]*\([^)]*\)/\1/' | awk '{$1=$1};1')"
129+ if [ "${#WATCHOS_SIM}" == "0" ]; then
130+ WATCHOS_SIM = "Apple Watch Series 6 - 44mm" # Fallback Simulator
131+ fi
132+
133+ 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
0 commit comments