Skip to content

Commit d8726b9

Browse files
[MOB-10136] Collect Coverage Reports from iOS (#805)
* Collect coverage reports from iOS * Convert iOS XCode coverage report into JSON * Convert xcresult into lcov report and upload to Codecov * Update Codecov coverage target * Format `xcodebuild` command in CI config Co-authored-by: Youssef Raafat <[email protected]> * Fix typo in `xcodebuild` test command Co-authored-by: Youssef Raafat <[email protected]>
1 parent 04f2838 commit d8726b9

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

.circleci/config.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,34 @@ jobs:
128128
command: yarn
129129
- run:
130130
name: Install Pods
131-
command: cd ios && pod install
131+
working_directory: ios
132+
command: pod install
132133
- run:
133134
name: Build and run tests
134-
command: cd ios && xcodebuild -allowProvisioningUpdates -workspace InstabugSample.xcworkspace -scheme InstabugSample -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' test | xcpretty
135+
working_directory: ios
136+
command: |
137+
xcodebuild -allowProvisioningUpdates \
138+
-workspace InstabugSample.xcworkspace \
139+
-scheme InstabugSample \
140+
-resultBundlePath coverage/result.xcresult \
141+
-sdk iphonesimulator \
142+
-destination 'platform=iOS Simulator,name=iPhone 13 Pro Max,OS=15.5' \
143+
test | xcpretty
135144
no_output_timeout: 30m
145+
- run:
146+
name: Convert xcresult into JSON report
147+
working_directory: ios/coverage
148+
command: xcrun xccov view --report --json result.xcresult > report.json
149+
- run:
150+
name: Clone xccov2lcov
151+
command: git clone [email protected]:trax-retail/xccov2lcov.git
152+
- run:
153+
name: Convert xccov into lcov report
154+
working_directory: xccov2lcov
155+
command: swift run xccov2lcov ../ios/coverage/report.json > ../ios/coverage/coverage.txt
156+
- codecov/upload:
157+
flags: ios
158+
file: ios/coverage/coverage.txt
136159

137160
e2e_ios:
138161
macos:

codecov.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ coverage:
1010
status:
1111
project:
1212
default:
13-
target: 50%
13+
target: 55%
1414
patch:
1515
javascript:
1616
target: 90%
@@ -20,6 +20,10 @@ coverage:
2020
target: 35%
2121
flags:
2222
- android
23+
ios:
24+
target: 50%
25+
flags:
26+
- ios
2327

2428
flags:
2529
javascript:
@@ -30,3 +34,7 @@ flags:
3034
carryforward: true
3135
paths:
3236
- android
37+
ios:
38+
carryforward: true
39+
paths:
40+
- ios

example/ios/InstabugSample.xcodeproj/xcshareddata/xcschemes/InstabugSample.xcscheme

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,18 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29-
shouldUseLaunchSchemeArgsEnv = "YES">
29+
shouldUseLaunchSchemeArgsEnv = "YES"
30+
codeCoverageEnabled = "YES"
31+
onlyGenerateCoverageForSpecifiedTargets = "YES">
32+
<CodeCoverageTargets>
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "50FE5EF73DC8C0767F7FABB1748BACBE"
36+
BuildableName = "libRNInstabug.a"
37+
BlueprintName = "RNInstabug"
38+
ReferencedContainer = "container:Pods/Pods.xcodeproj">
39+
</BuildableReference>
40+
</CodeCoverageTargets>
3041
<Testables>
3142
<TestableReference
3243
skipped = "NO">

0 commit comments

Comments
 (0)