@@ -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 :
0 commit comments