-
Notifications
You must be signed in to change notification settings - Fork 10
/
sections.py
715 lines (646 loc) · 29.5 KB
/
sections.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
import logging
import random
from base64 import b64encode
from decimal import Decimal
from itertools import starmap
from typing import List
from urllib.parse import urlencode
from shared.helpers.yaml import walk
from shared.reports.resources import Report
from helpers.reports import get_totals_from_file_in_reports
from services.comparison import ComparisonProxy
from services.comparison.overlays import OverlayType
from services.notification.notifiers.mixins.message.helpers import (
diff_to_string,
ellipsis,
escape_markdown,
get_table_header,
get_table_layout,
make_metrics,
make_patch_only_metrics,
)
from services.urls import get_commit_url_from_commit_sha, get_pull_graph_url
from services.yaml.reader import get_components_from_yaml, round_number
log = logging.getLogger(__name__)
def get_section_class_from_layout_name(layout_name):
if layout_name.startswith("flag"):
return FlagSectionWriter
if layout_name == "diff":
return DiffSectionWriter
if layout_name.startswith(("files", "tree")):
return FileSectionWriter
if layout_name == "reach":
return ReachSectionWriter
if layout_name == "footer":
return FooterSectionWriter
if layout_name == "betaprofiling":
return ImpactedEntrypointsSectionWriter
if layout_name == "announcements":
return AnnouncementSectionWriter
if layout_name in ["header", "newheader", "condensed_header"]:
return NewHeaderSectionWriter
if layout_name == "newfooter" or layout_name == "condensed_footer":
return NewFooterSectionWriter
if layout_name.startswith("component"):
return ComponentsSectionWriter
if layout_name == "newfiles" or layout_name == "condensed_files":
return NewFilesSectionWriter
class BaseSectionWriter(object):
def __init__(self, repository, layout, show_complexity, settings, current_yaml):
self.repository = repository
self.layout = layout
self.show_complexity = show_complexity
self.settings = settings
self.current_yaml = current_yaml
@property
def name(self):
return self.__class__.__name__
async def write_section(self, *args, **kwargs):
return [i async for i in self.do_write_section(*args, **kwargs)]
class NullSectionWriter(BaseSectionWriter):
async def write_section(*args, **kwargs):
return []
class NewFooterSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
hide_project_coverage = self.settings.get("hide_project_coverage", False)
if hide_project_coverage:
yield ("")
yield (
":loudspeaker: Thoughts on this report? [Let us know!]({0})".format(
"https://about.codecov.io/pull-request-comment-report/"
)
)
else:
repo_service = comparison.repository_service.service
yield ("")
yield (
"[:umbrella: View full report in Codecov by Sentry]({0}?dropdown=coverage&src=pr&el=continue). ".format(
links["pull"]
)
)
yield (
":loudspeaker: Have feedback on the report? [Share it here]({0}).".format(
"https://about.codecov.io/codecov-pr-comment-feedback/"
if repo_service == "github"
else "https://gitlab.com/codecov-open-source/codecov-user-feedback/-/issues/4"
)
)
class NewHeaderSectionWriter(BaseSectionWriter):
def _possibly_include_test_result_setup_confirmation(self, comparison):
if comparison.all_tests_passed():
yield ("")
yield (":white_check_mark: All tests successful. No failed tests found.")
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
yaml = self.current_yaml
base_report = comparison.project_coverage_base.report
head_report = comparison.head.report
pull_dict = comparison.enriched_pull.provider_pull
repo_service = comparison.repository_service.service
diff_totals = head_report.apply_diff(diff)
if diff_totals:
misses_and_partials = diff_totals.misses + diff_totals.partials
patch_coverage = diff_totals.coverage
else:
misses_and_partials = None
patch_coverage = None
if misses_and_partials:
yield (
f"Attention: Patch coverage is `{patch_coverage}%` with `{misses_and_partials} lines` in your changes are missing coverage. Please review."
)
else:
yield "All modified and coverable lines are covered by tests :white_check_mark:"
hide_project_coverage = self.settings.get("hide_project_coverage", False)
if hide_project_coverage:
for msg in self._possibly_include_test_result_setup_confirmation(
comparison
):
yield msg
return
if base_report and head_report:
yield (
"> Project coverage is {head_cov}%. Comparing base [(`{commitid_base}`)]({links[base]}?dropdown=coverage&el=desc) to head [(`{commitid_head}`)]({links[pull]}?dropdown=coverage&src=pr&el=desc).".format(
commitid_head=comparison.head.commit.commitid[:7],
commitid_base=comparison.project_coverage_base.commit.commitid[:7],
links=links,
head_cov=round_number(yaml, Decimal(head_report.totals.coverage)),
)
)
else:
yield (
"> :exclamation: No coverage uploaded for {request_type} {what} (`{branch}@{commit}`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-{what}-commit).".format(
what="base" if not base_report else "head",
branch=pull_dict["base" if not base_report else "head"]["branch"],
commit=pull_dict["base" if not base_report else "head"]["commitid"][
:7
],
request_type=(
"merge request" if repo_service == "gitlab" else "pull request"
),
)
)
if behind_by:
yield (
f"> Report is {behind_by} commits behind head on {pull_dict['base']['branch']}."
)
if (
comparison.enriched_pull.provider_pull is not None
and comparison.head.commit.commitid
!= comparison.enriched_pull.provider_pull["head"]["commitid"]
):
# Temporary log so we understand when this happens
log.info(
"Notifying user that current head and pull head differ",
extra=dict(
repoid=comparison.head.commit.repoid,
commit=comparison.head.commit.commitid,
pull_head=comparison.enriched_pull.provider_pull["head"][
"commitid"
],
),
)
yield ("")
yield (
"> :exclamation: Current head {current_head} differs from pull request most recent head {pull_head}. Consider uploading reports for the commit {pull_head} to get more accurate results".format(
pull_head=comparison.enriched_pull.provider_pull["head"][
"commitid"
][:7],
current_head=comparison.head.commit.commitid[:7],
)
)
if self.settings.get("show_critical_paths"):
all_potentially_affected_critical_files = set(
(diff["files"] if diff else {}).keys()
) | set(c.path for c in changes or [])
overlay = comparison.get_overlay(OverlayType.line_execution_count)
files_in_critical = set(
await overlay.search_files_for_critical_changes(
all_potentially_affected_critical_files
)
)
if files_in_critical:
yield ("")
yield (
"Changes have been made to critical files, which contain lines commonly executed in production. [Learn more](https://docs.codecov.com/docs/impact-analysis)"
)
for msg in self._possibly_include_test_result_setup_confirmation(comparison):
yield msg
class AnnouncementSectionWriter(BaseSectionWriter):
ats_message = (
"We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/)",
)
current_active_messages = [
"Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in [Chrome](https://chrome.google.com/webstore/detail/codecov/gedikamndpbemklijjkncpnolildpbgo) or [Firefox](https://addons.mozilla.org/en-US/firefox/addon/codecov/) today!"
# "Codecov can now indicate which changes are the most critical in Pull Requests. [Learn more](https://about.codecov.io/product/feature/runtime-insights/)" # This is disabled as of CODE-1885. But we might bring it back later.
]
async def do_write_section(self, comparison: ComparisonProxy, *args, **kwargs):
if self._potential_ats_user(comparison):
message_to_display = AnnouncementSectionWriter.ats_message
else:
# This allows us to shift through active messages while respecting the annoucement limit.
message_to_display = random.choice(
AnnouncementSectionWriter.current_active_messages
)
yield f":mega: {message_to_display}"
def _has_ats_configured(self):
if not self.current_yaml:
return False
flags = self.current_yaml.read_yaml_field(
"flag_management", "individual_flags", _else=[]
)
for flag_info in flags:
if flag_info.get("carryforward_mode") == "labels":
return True
return False
def _potential_ats_user(self, comparison: ComparisonProxy) -> bool:
if self.repository and self.repository.language == "python":
if not self._has_ats_configured() and comparison.has_head_report():
report = comparison.head.report
# we're using the total chunks size as a proxy for potential CI
# runtime - assuming that if you have more files + uploads then
# perhaps your CI is running longer
#
# this value was just chosen empirically by looking at some of our
# own repos and relating chunks size to CI time - ideally we'd like
# to target repos w/ CI time > 20 min but we don't really have that
# info available
if report.size > 80_000_000:
return True
return False
class ImpactedEntrypointsSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
overlay = comparison.get_overlay(OverlayType.line_execution_count)
impacted_endpoints = await overlay.find_impacted_endpoints()
if impacted_endpoints:
yield "| Related Entrypoints |"
yield "|---|"
for endpoint in impacted_endpoints:
yield (f"|{endpoint['group_name']}|")
elif impacted_endpoints is not None:
yield "This change has been scanned for critical changes. [Learn more](https://docs.codecov.com/docs/impact-analysis)"
class FooterSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
pull_dict = comparison.enriched_pull.provider_pull
yield ("------")
yield ("")
yield (
"[Continue to review full report in Codecov by Sentry]({0}?dropdown=coverage&src=pr&el=continue).".format(
links["pull"]
)
)
yield (
"> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)"
)
yield (
"> `\u0394 = absolute <relative> (impact)`, `\xF8 = not affected`, `? = missing data`"
)
yield (
"> Powered by [Codecov]({pull}?dropdown=coverage&src=pr&el=footer). Last update [{base}...{head}]({pull}?dropdown=coverage&src=pr&el=lastupdated). Read the [comment docs]({comment}).".format(
pull=links["pull"],
base=pull_dict["base"]["commitid"][:7],
head=pull_dict["head"]["commitid"][:7],
comment="https://docs.codecov.io/docs/pull-request-comments",
)
)
class ReachSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
pull = comparison.enriched_pull.database_pull
yield (
"[![Impacted file tree graph]({})]({}?src=pr&el=tree)".format(
get_pull_graph_url(
pull,
"tree.svg",
width=650,
height=150,
src="pr",
token=pull.repository.image_token,
),
links["pull"],
)
)
class DiffSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
base_report = comparison.project_coverage_base.report
head_report = comparison.head.report
if base_report is None:
base_report = Report()
pull_dict = comparison.enriched_pull.provider_pull
pull = comparison.enriched_pull.database_pull
yield ("```diff")
lines = diff_to_string(
self.current_yaml,
pull_dict["base"]["branch"], # important because base may be null
base_report.totals if base_report else None,
"#%s" % pull.pullid,
head_report.totals,
)
for li in lines:
yield (li)
yield ("```")
def _get_tree_cell(typ, path, metrics, compare, is_critical):
return "| {rm}[{path}]({compare}?src=pr&el=tree&{path_as_query_param}#diff-{hash}){rm}{file_tags} {metrics}".format(
rm="~~" if typ == "deleted" else "",
path=escape_markdown(ellipsis(path, 50, False)),
path_as_query_param=urlencode({"filepath": path}),
compare=compare,
hash=b64encode(path.encode()).decode(),
metrics=metrics,
file_tags=" **Critical**" if is_critical else "",
)
class NewFilesSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
# create list of files changed in diff
base_report = comparison.project_coverage_base.report
head_report = comparison.head.report
if base_report is None:
base_report = Report()
files_in_diff = [
(
_diff["type"],
path,
make_patch_only_metrics(
get_totals_from_file_in_reports(base_report, path) or False,
get_totals_from_file_in_reports(head_report, path) or False,
_diff["totals"],
self.show_complexity,
self.current_yaml,
links["pull"],
),
int(_diff["totals"].misses + _diff["totals"].partials),
)
for path, _diff in (diff["files"] if diff else {}).items()
if _diff.get("totals")
]
all_files = set(f[1] for f in files_in_diff or []) | set(
c.path for c in changes or []
)
if files_in_diff:
table_header = "| Patch % | Lines |"
table_layout = "|---|---|---|"
# get limit of results to show
limit = int(self.layout.split(":")[1] if ":" in self.layout else 10)
mentioned = []
files_in_critical = set()
if self.settings.get("show_critical_paths", False):
overlay = comparison.get_overlay(OverlayType.line_execution_count)
files_in_critical = set(
await overlay.search_files_for_critical_changes(all_files)
)
def tree_cell(typ, path, metrics, _=None):
if path not in mentioned:
# mentioned: for files that are in diff and changes
mentioned.append(path)
return _get_tree_cell(
typ=typ,
path=path,
metrics=metrics,
compare=links["pull"],
is_critical=path in files_in_critical,
)
remaining_files = 0
printed_files = 0
changed_files = sorted(
files_in_diff, key=lambda a: a[3] or Decimal("0"), reverse=True
)
changed_files_with_missing_lines = [f for f in changed_files if f[3] > 0]
if changed_files_with_missing_lines:
yield (
"| [Files]({0}?dropdown=coverage&src=pr&el=tree) {1}".format(
links["pull"], table_header
)
)
yield (table_layout)
for file in changed_files_with_missing_lines:
if printed_files == limit:
remaining_files += 1
else:
printed_files += 1
yield (tree_cell(file[0], file[1], file[2]))
if remaining_files:
yield (
"| ... and [{n} more]({href}?src=pr&el=tree-more) | |".format(
n=remaining_files, href=links["pull"]
)
)
class FileSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
# create list of files changed in diff
base_report = comparison.project_coverage_base.report
head_report = comparison.head.report
if base_report is None:
base_report = Report()
files_in_diff = [
(
_diff["type"],
path,
make_metrics(
get_totals_from_file_in_reports(base_report, path) or False,
get_totals_from_file_in_reports(head_report, path) or False,
_diff["totals"],
self.show_complexity,
self.current_yaml,
links["pull"],
),
int(_diff["totals"].misses + _diff["totals"].partials),
)
for path, _diff in (diff["files"] if diff else {}).items()
if _diff.get("totals")
]
all_files = set(f[1] for f in files_in_diff or []) | set(
c.path for c in changes or []
)
if files_in_diff:
table_header = get_table_header(self.show_complexity)
table_layout = get_table_layout(self.show_complexity)
# get limit of results to show
limit = int(self.layout.split(":")[1] if ":" in self.layout else 10)
mentioned = []
files_in_critical = set()
if self.settings.get("show_critical_paths", False):
overlay = comparison.get_overlay(OverlayType.line_execution_count)
files_in_critical = set(
await overlay.search_files_for_critical_changes(all_files)
)
def tree_cell(typ, path, metrics, _=None):
if path not in mentioned:
# mentioned: for files that are in diff and changes
mentioned.append(path)
return _get_tree_cell(
typ=typ,
path=path,
metrics=metrics,
compare=links["pull"],
is_critical=path in files_in_critical,
)
yield (
"| [Files]({0}?dropdown=coverage&src=pr&el=tree) {1}".format(
links["pull"], table_header
)
)
yield (table_layout)
for line in starmap(
tree_cell,
sorted(files_in_diff, key=lambda a: a[3] or Decimal("0"))[:limit],
):
yield (line)
remaining = len(files_in_diff) - limit
if remaining > 0:
yield (
"| ... and [{n} more]({href}?src=pr&el=tree-more) | |".format(
n=remaining, href=links["pull"]
)
)
if changes:
len_changes_not_in_diff = len(all_files or []) - len(files_in_diff or [])
if files_in_diff and len_changes_not_in_diff > 0:
yield ("")
yield (
"... and [{n} file{s} with indirect coverage changes]({href}/indirect-changes?src=pr&el=tree-more)".format(
n=len_changes_not_in_diff,
href=links["pull"],
s="s" if len_changes_not_in_diff > 1 else "",
)
)
elif len_changes_not_in_diff > 0:
yield (
"[see {n} file{s} with indirect coverage changes]({href}/indirect-changes?src=pr&el=tree-more)".format(
n=len_changes_not_in_diff,
href=links["pull"],
s="s" if len_changes_not_in_diff > 1 else "",
)
)
class FlagSectionWriter(BaseSectionWriter):
async def do_write_section(self, comparison, diff, changes, links, behind_by=None):
# flags
base_report = comparison.project_coverage_base.report
head_report = comparison.head.report
if base_report is None:
base_report = Report()
base_flags = base_report.flags if base_report else {}
head_flags = head_report.flags if head_report else {}
missing_flags = set(base_flags.keys()) - set(head_flags.keys())
flags = []
show_carriedforward_flags = self.settings.get("show_carryforward_flags", False)
for name, flag in head_flags.items():
if (show_carriedforward_flags is True) or ( # Include all flags
show_carriedforward_flags is False
and flag.carriedforward
is False # Only include flags without carriedforward coverage
):
flags.append(
{
"name": name,
"before": get_totals_from_file_in_reports(base_flags, name),
"after": flag.totals,
"diff": (
flag.apply_diff(diff) if walk(diff, ("files",)) else None
),
"carriedforward": flag.carriedforward,
"carriedforward_from": flag.carriedforward_from,
}
)
for flag in missing_flags:
flags.append(
{
"name": flag,
"before": base_flags[flag],
"after": None,
"diff": None,
"carriedforward": False,
"carriedforward_from": None,
}
)
# TODO: get icons working
# flag_icon_url = ""
# carriedforward_flag_icon_url = ""
if flags:
# Even if "show_carryforward_flags" is true, we don't want to show that column if there isn't actually carriedforward coverage,
# so figure out if we actually have any carriedforward coverage to show
has_carriedforward_flags = any(
flag["carriedforward"] is True
for flag in flags # If "show_carryforward_flags" yaml setting is set to false there won't be any flags in this list with carriedforward coverage.
)
table_header = (
"| Coverage \u0394 |"
+ (" Complexity \u0394 |" if self.show_complexity else "")
+ " |"
+ (" *Carryforward flag |" if has_carriedforward_flags else "")
)
table_layout = (
"|---|---|---|"
+ ("---|" if self.show_complexity else "")
+ ("---|" if has_carriedforward_flags else "")
)
yield (
"| [Flag]({href}/flags?src=pr&el=flags) ".format(href=links["pull"])
+ table_header
)
yield (table_layout)
for flag in sorted(flags, key=lambda f: f["name"]):
carriedforward, carriedforward_from = (
flag["carriedforward"],
flag["carriedforward_from"],
)
# Format the message for the "carriedforward" column, if the flag was carried forward
if carriedforward is True:
# The "from <link to parent commit>" text will only appear if we actually know which commit we carried forward from
carriedforward_from_url = (
get_commit_url_from_commit_sha(
self.repository, carriedforward_from
)
if carriedforward_from
else ""
)
carriedforward_message = (
" Carriedforward"
+ (
f" from [{carriedforward_from[:7]}]({carriedforward_from_url})"
if carriedforward_from and carriedforward_from_url
else ""
)
+ " |"
)
else:
carriedforward_message = " |" if has_carriedforward_flags else ""
yield (
"| {name} {metrics}{cf}".format(
name="[{flag_name}]({href}/flags?src=pr&el=flag)".format(
flag_name=flag["name"],
href=links["pull"],
),
metrics=make_metrics(
flag["before"],
flag["after"],
flag["diff"],
self.show_complexity,
self.current_yaml,
),
cf=carriedforward_message,
)
)
if has_carriedforward_flags and show_carriedforward_flags:
yield ("")
yield (
"*This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags) to find out more."
)
elif not show_carriedforward_flags:
yield ("")
yield (
"Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags#carryforward-flags-in-the-pull-request-comment) to find out more."
)
class ComponentsSectionWriter(BaseSectionWriter):
async def _get_table_data_for_components(
self, all_components, comparison: ComparisonProxy
) -> List[dict]:
component_data = []
for component in all_components:
flags = component.get_matching_flags(comparison.head.report.flags.keys())
filtered_comparison = comparison.get_filtered_comparison(
flags, component.paths
)
diff = await filtered_comparison.get_diff()
component_data.append(
{
"name": component.get_display_name(),
"before": (
filtered_comparison.project_coverage_base.report.totals
if filtered_comparison.project_coverage_base.report is not None
else None
),
"after": filtered_comparison.head.report.totals,
"diff": filtered_comparison.head.report.apply_diff(
diff, _save=False
),
}
)
return component_data
async def do_write_section(
self, comparison: ComparisonProxy, diff, changes, links, behind_by=None
):
all_components = get_components_from_yaml(self.current_yaml)
if all_components == []:
return # fast return if there's noting to process
component_data_to_show = await self._get_table_data_for_components(
all_components, comparison
)
# Table header and layout
yield "| [Components]({href}/components?src=pr&el=components) | Coverage \u0394 | |".format(
href=links["pull"],
)
yield "|---|---|---|"
# The interesting part
for component_data in component_data_to_show:
yield (
"| {name} {metrics}".format(
name="[{component_name}]({href}/components?src=pr&el=component)".format(
component_name=component_data["name"],
href=links["pull"],
),
metrics=make_metrics(
component_data["before"],
component_data["after"],
component_data["diff"],
show_complexity=False,
yaml=self.current_yaml,
),
)
)