16
16
17
17
import Foundation
18
18
19
- /// A mapping of SDKs to an ID that will represent that SDK in the database .
20
- let TARGET_TO_SDK_INDEX = [
21
- " Auth_Example_iOS.app " : 0.0 ,
22
- " Core_Example_iOS.app " : 1.0 ,
23
- " Database_Example_iOS.app " : 2.0 ,
24
- " DynamicLinks_Example_iOS.app " : 3.0 ,
25
- " InstanceID_Example_iOS.app " : 4.0 ,
26
- " Messaging_Example_iOS.app " : 5.0 ,
27
- " Storage_Example_iOS.app " : 6.0 ,
19
+ /// A set of SDK targets for which to collect code coverage .
20
+ let TARGETS_TO_COLLECT : Set = [
21
+ " Auth_Example_iOS.app " ,
22
+ " Core_Example_iOS.app " ,
23
+ " Database_Example_iOS.app " ,
24
+ " DynamicLinks_Example_iOS.app " ,
25
+ " InstanceID_Example_iOS.app " ,
26
+ " Messaging_Example_iOS.app " ,
27
+ " Storage_Example_iOS.app " ,
28
28
// TODO(Corrob): Add support for Firestore, Functions, and InAppMessaging.
29
29
]
30
30
@@ -47,30 +47,30 @@ public struct UploadMetrics: Encodable {
47
47
public struct TableUpdate : Encodable {
48
48
public var table_name : String
49
49
public var column_names : [ String ]
50
- public var replace_measurements : [ [ Double ] ]
50
+ public var replace_measurements : [ [ String ] ]
51
51
52
- public init ( table_name: String , column_names: [ String ] , replace_measurements: [ [ Double ] ] ) {
52
+ public init ( table_name: String , column_names: [ String ] , replace_measurements: [ [ String ] ] ) {
53
53
self . table_name = table_name
54
54
self . column_names = column_names
55
55
self . replace_measurements = replace_measurements
56
56
}
57
57
58
58
/// Creates a table update for code coverage by parsing a coverage report from XCov.
59
- public static func createFrom( coverage: CoverageReport , pullRequest: Int ) -> TableUpdate {
60
- var metrics = [ [ Double ] ] ( )
59
+ public static func createFrom( coverage: CoverageReport , pullRequest: Int , currentTime : String ) -> TableUpdate {
60
+ var metrics = [ [ String ] ] ( )
61
61
for target in coverage. targets {
62
- let sdkKey = TARGET_TO_SDK_INDEX [ target. name]
63
- if sdkKey == nil {
64
- print ( " WARNING - target \( target. name) has no mapping to an SDK id. Skipping... " )
65
- } else {
66
- var row = [ Double] ( )
67
- row. append ( Double ( pullRequest) )
68
- row. append ( sdkKey!)
69
- row. append ( target. coverage)
62
+ if TARGETS_TO_COLLECT . contains ( target. name) {
63
+ var row = [ String] ( )
64
+ row. append ( target. name. components ( separatedBy: " _ " ) [ 0 ] )
65
+ row. append ( String ( pullRequest) )
66
+ row. append ( String ( target. coverage) )
67
+ row. append ( currentTime)
70
68
metrics. append ( row)
69
+ } else {
70
+ print ( " WARNING - target \( target. name) is being filtered out from coverage collection. Skipping... " )
71
71
}
72
72
}
73
- let columnNames = [ " pull_request_id " , " sdk_id " , " coverage_percent " ]
74
- return TableUpdate ( table_name: " Coverage1 " , column_names: columnNames, replace_measurements: metrics)
73
+ let columnNames = [ " product_name " , " pull_request_id " , " coverage_total " , " collection_time " ]
74
+ return TableUpdate ( table_name: " IosCodeCoverage " , column_names: columnNames, replace_measurements: metrics)
75
75
}
76
76
}
0 commit comments