@@ -42,6 +42,7 @@ def __init__(self, repository, revision, task_name_filter, cache_root):
42
42
43
43
temp_dir = tempfile .mkdtemp ()
44
44
self .artifacts_dir = os .path .join (temp_dir , "ccov-artifacts" )
45
+ self .reports_dir = os .path .join (temp_dir , "ccov-reports" )
45
46
46
47
self .index_service = taskcluster_config .get_service ("index" )
47
48
@@ -118,27 +119,56 @@ def retrieve_source_and_artifacts(self):
118
119
# Thread 2 - Clone repository.
119
120
executor .submit (self .clone_repository , self .repository , self .revision )
120
121
121
- def generate_covdir (self ):
122
+ def build_reports (self , only = None ):
122
123
"""
123
- Build the covdir report using current artifacts
124
+ Build all the possible covdir reports using current artifacts
124
125
"""
125
- output = grcov .report (
126
- self .artifactsHandler .get (), source_dir = self .repo_dir , out_format = "covdir"
127
- )
128
- logger .info ("Covdir report generated successfully" )
129
- return json .loads (output )
126
+ os .makedirs (self .reports_dir , exist_ok = True )
130
127
131
- # This function is executed when the bot is triggered at the end of a mozilla-central build.
132
- def go_from_trigger_mozilla_central (self ):
133
- # Check the covdir report does not already exists
134
- if uploader .gcp_covdir_exists (self .branch , self .revision ):
135
- logger .warn ("Covdir report already on GCP" )
136
- return
128
+ reports = {}
129
+ for (
130
+ (platform , suite ),
131
+ artifacts ,
132
+ ) in self .artifactsHandler .get_combinations ().items ():
137
133
138
- self .retrieve_source_and_artifacts ()
134
+ if only is not None and (platform , suite ) not in only :
135
+ continue
136
+
137
+ # Generate covdir report for that suite & platform
138
+ logger .info (
139
+ "Building covdir suite report" ,
140
+ suite = suite ,
141
+ platform = platform ,
142
+ artifacts = len (artifacts ),
143
+ )
144
+ output = grcov .report (
145
+ artifacts , source_dir = self .repo_dir , out_format = "covdir"
146
+ )
147
+
148
+ # Write output on FS
149
+ path = os .path .join (self .reports_dir , f"{ platform } .{ suite } .json" )
150
+ with open (path , "wb" ) as f :
151
+ f .write (output )
139
152
140
- # Check that all JavaScript files present in the coverage artifacts actually exist.
141
- # If they don't, there might be a bug in the LCOV rewriter.
153
+ reports [(platform , suite )] = path
154
+
155
+ return reports
156
+
157
+ def upload_reports (self , reports ):
158
+ """
159
+ Upload all provided covdir reports on GCP
160
+ """
161
+ for (platform , suite ), path in reports .items ():
162
+ report = open (path , "rb" ).read ()
163
+ uploader .gcp (
164
+ self .branch , self .revision , report , suite = suite , platform = platform
165
+ )
166
+
167
+ def check_javascript_files (self ):
168
+ """
169
+ Check that all JavaScript files present in the coverage artifacts actually exist.
170
+ If they don't, there might be a bug in the LCOV rewriter.
171
+ """
142
172
for artifact in self .artifactsHandler .get ():
143
173
if "jsvm" not in artifact :
144
174
continue
@@ -161,7 +191,24 @@ def go_from_trigger_mozilla_central(self):
161
191
f"{ missing_files } are present in coverage reports, but missing from the repository"
162
192
)
163
193
164
- report = self .generate_covdir ()
194
+ # This function is executed when the bot is triggered at the end of a mozilla-central build.
195
+ def go_from_trigger_mozilla_central (self ):
196
+ # Check the covdir report does not already exists
197
+ if uploader .gcp_covdir_exists (self .branch , self .revision , "all" , "all" ):
198
+ logger .warn ("Full covdir report already on GCP" )
199
+ return
200
+
201
+ self .retrieve_source_and_artifacts ()
202
+
203
+ self .check_javascript_files ()
204
+
205
+ reports = self .build_reports ()
206
+ logger .info ("Built all covdir reports" , nb = len (reports ))
207
+
208
+ # Retrieve the full report
209
+ full_path = reports .get (("all" , "all" ))
210
+ assert full_path is not None , "Missing full report (all:all)"
211
+ report = json .load (open (full_path ))
165
212
166
213
paths = uploader .covdir_paths (report )
167
214
expected_extensions = [".js" , ".cpp" ]
@@ -170,6 +217,9 @@ def go_from_trigger_mozilla_central(self):
170
217
path .endswith (extension ) for path in paths
171
218
), "No {} file in the generated report" .format (extension )
172
219
220
+ self .upload_reports (reports )
221
+ logger .info ("Uploaded all covdir reports" , nb = len (reports ))
222
+
173
223
# Get pushlog and ask the backend to generate the coverage by changeset
174
224
# data, which will be cached.
175
225
with hgmo .HGMO (self .repo_dir ) as hgmo_server :
@@ -179,9 +229,6 @@ def go_from_trigger_mozilla_central(self):
179
229
phabricatorUploader = PhabricatorUploader (self .repo_dir , self .revision )
180
230
changesets_coverage = phabricatorUploader .upload (report , changesets )
181
231
182
- uploader .gcp (self .branch , self .revision , report )
183
-
184
- logger .info ("Build uploaded on GCP" )
185
232
notify_email (self .revision , changesets , changesets_coverage )
186
233
187
234
# This function is executed when the bot is triggered at the end of a try build.
@@ -201,7 +248,10 @@ def go_from_trigger_try(self):
201
248
202
249
self .retrieve_source_and_artifacts ()
203
250
204
- report = self .generate_covdir ()
251
+ reports = self .build_reports (only = [("all" , "all" )])
252
+ full_path = reports .get (("all" , "all" ))
253
+ assert full_path is not None , "Missing full report (all:all)"
254
+ report = json .load (open (full_path ))
205
255
206
256
logger .info ("Upload changeset coverage data to Phabricator" )
207
257
phabricatorUploader .upload (report , changesets )
0 commit comments