|
27 | 27 | gem install slather |
28 | 28 | # Install xcparse for better xcresult handling |
29 | 29 | brew install chargepoint/xcparse/xcparse |
| 30 | + # Install xccov-to-cobertura-xml for direct conversion |
| 31 | + npm install -g xccov-to-cobertura-xml |
30 | 32 | - name: Install Gems |
31 | 33 | run: | |
32 | 34 | bundle install |
@@ -55,22 +57,47 @@ jobs: |
55 | 57 | find ./DerivedData -type d -name "*coverage*" 2>/dev/null || echo "No coverage directories found" |
56 | 58 | - name: Prepare code coverage report |
57 | 59 | 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..." |
61 | 61 | |
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" |
65 | 66 | mv coverage.xml cobertura.xml |
66 | 67 | 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 |
74 | 101 | fi |
75 | 102 | - name: Verify coverage file |
76 | 103 | run: | |
|
0 commit comments