Skip to content

Commit 274aff4

Browse files
committed
💻 ci: Fix code coverage issue
1 parent 780b4e5 commit 274aff4

1 file changed

Lines changed: 40 additions & 13 deletions

File tree

.github/workflows/testing.yml

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ jobs:
2727
gem install slather
2828
# Install xcparse for better xcresult handling
2929
brew install chargepoint/xcparse/xcparse
30+
# Install xccov-to-cobertura-xml for direct conversion
31+
npm install -g xccov-to-cobertura-xml
3032
- name: Install Gems
3133
run: |
3234
bundle install
@@ -55,22 +57,47 @@ jobs:
5557
find ./DerivedData -type d -name "*coverage*" 2>/dev/null || echo "No coverage directories found"
5658
- name: Prepare code coverage report
5759
run: |
58-
echo "Extracting coverage using xcparse..."
59-
# Use xcparse to extract coverage from xcresult bundle
60-
xcparse codecov ./TestResults.xcresult coverage.xml --legacy
60+
echo "Trying multiple approaches to extract coverage..."
6161
62-
# If xcparse succeeds, we have our coverage file
63-
if [ -f "coverage.xml" ]; then
64-
echo "Coverage extracted successfully with xcparse"
62+
# Method 1: Try xcparse
63+
echo "1. Trying xcparse..."
64+
if xcparse codecov ./TestResults.xcresult coverage.xml; then
65+
echo "✅ xcparse succeeded"
6566
mv coverage.xml cobertura.xml
6667
else
67-
echo "xcparse failed, trying slather..."
68-
# Fallback to slather
69-
slather coverage \
70-
--scheme SwiftyMarvel \
71-
--configuration Debug \
72-
--build-directory ./DerivedData \
73-
SwiftyMarvel.xcodeproj
68+
echo "❌ xcparse failed"
69+
70+
# Method 2: Try xccov-to-cobertura-xml
71+
echo "2. Trying xccov-to-cobertura-xml..."
72+
if xcrun xccov view --report --json ./TestResults.xcresult > coverage-report.json && \
73+
xccov-to-cobertura-xml coverage-report.json > cobertura.xml; then
74+
echo "✅ xccov-to-cobertura-xml succeeded"
75+
else
76+
echo "❌ xccov-to-cobertura-xml failed"
77+
78+
# Method 3: Extract profdata and use slather
79+
echo "3. Trying to extract profdata for slather..."
80+
find ./TestResults.xcresult -name "*.profdata" -exec cp {} ./coverage.profdata \;
81+
82+
if [ -f "./coverage.profdata" ]; then
83+
echo "Found profdata file, copying to DerivedData..."
84+
mkdir -p ./DerivedData/Build/ProfileData
85+
cp ./coverage.profdata ./DerivedData/Build/ProfileData/
86+
87+
echo "Running slather with profdata..."
88+
slather coverage \
89+
--scheme SwiftyMarvel \
90+
--configuration Debug \
91+
--build-directory ./DerivedData \
92+
SwiftyMarvel.xcodeproj
93+
else
94+
echo "❌ No profdata found, trying basic slather..."
95+
slather coverage \
96+
--scheme SwiftyMarvel \
97+
--configuration Debug \
98+
SwiftyMarvel.xcodeproj
99+
fi
100+
fi
74101
fi
75102
- name: Verify coverage file
76103
run: |

0 commit comments

Comments
 (0)