Skip to content

Commit 813b86a

Browse files
committed
💻 ci: Fix code coverage issue
1 parent dc4454c commit 813b86a

2 files changed

Lines changed: 41 additions & 9 deletions

File tree

.github/workflows/testing.yml

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ jobs:
2121
echo "MarvelPrivateKey=$MarvelPrivateKey" >> .env
2222
- name: Install Bundler
2323
run: gem install bundler
24-
- name: Install xcpretty and slather
24+
- name: Install xcpretty and coverage tools
2525
run: |
2626
gem install xcpretty
2727
gem install slather
28+
# Install xcparse for better xcresult handling
29+
brew install chargepoint/xcparse/xcparse
2830
- name: Install Gems
2931
run: |
3032
bundle install
@@ -36,19 +38,49 @@ jobs:
3638
-project SwiftyMarvel.xcodeproj \
3739
-scheme SwiftyMarvel \
3840
-destination "platform=iOS Simulator,name=iPhone 15" \
39-
-testPlan SwiftyMarvel \
40-
-derivedDataPath DerivedData \
41+
-derivedDataPath ./DerivedData \
42+
-resultBundlePath ./TestResults.xcresult \
4143
CODE_SIGN_IDENTITY="" \
4244
CODE_SIGNING_REQUIRED=NO \
4345
ONLY_ACTIVE_ARCH=YES \
4446
-enableCodeCoverage YES | xcpretty
47+
- name: Debug - List coverage files
48+
run: |
49+
echo "Checking for coverage files..."
50+
find ./DerivedData -name "*.profdata" 2>/dev/null || echo "No .profdata files found in DerivedData"
51+
find ./TestResults.xcresult -name "*.xccovreport" 2>/dev/null || echo "No .xccovreport files found in TestResults"
52+
echo "TestResults.xcresult contents:"
53+
ls -la ./TestResults.xcresult/ || echo "TestResults.xcresult not found"
54+
echo "DerivedData contents:"
55+
find ./DerivedData -type d -name "*coverage*" 2>/dev/null || echo "No coverage directories found"
4556
- name: Prepare code coverage report
4657
run: |
47-
slather coverage \
48-
--build-directory DerivedData \
49-
--scheme SwiftyMarvel \
50-
--configuration Debug \
51-
SwiftyMarvel.xcodeproj
58+
echo "Extracting coverage using xcparse..."
59+
# Use xcparse to extract coverage from xcresult bundle
60+
xcparse codecov ./TestResults.xcresult coverage.xml --legacy
61+
62+
# If xcparse succeeds, we have our coverage file
63+
if [ -f "coverage.xml" ]; then
64+
echo "Coverage extracted successfully with xcparse"
65+
mv coverage.xml cobertura.xml
66+
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
74+
fi
75+
- name: Verify coverage file
76+
run: |
77+
if [ -f "cobertura.xml" ]; then
78+
echo "✅ cobertura.xml found"
79+
head -20 cobertura.xml
80+
else
81+
echo "❌ cobertura.xml not found"
82+
ls -la *.xml || echo "No XML files found"
83+
fi
5284
- name: Upload Code Coverage to Codecov
5385
uses: codecov/codecov-action@v3
5486
with:

.slather.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ coverage_service: cobertura_xml
22
xcodeproj: SwiftyMarvel.xcodeproj
33
scheme: SwiftyMarvel
44
output_directory: ./
5-
build_directory: DerivedData
5+
build_directory: ./DerivedData
66
ignore:
77
- "SwiftyMarvelTests/*"
88
- "SwiftyMarvelUITests/*"

0 commit comments

Comments
 (0)