@@ -27,16 +27,23 @@ class StatusResult(TypedDict):
27
27
28
28
CUSTOM_TARGET_TEXT_PATCH_KEY = "custom_target_helper_text_patch"
29
29
CUSTOM_TARGET_TEXT_PROJECT_KEY = "custom_target_helper_text_project"
30
+ CUSTOM_RCB_INDIRECT_CHANGES_KEY = "custom_rcb_indirect_changes_helper_text"
30
31
CUSTOM_TARGET_TEXT_VALUE = (
31
32
"Your {context} {notification_type} has failed because the {point_of_comparison} coverage ({coverage}%) is below the target coverage ({target}%). "
32
33
"You can increase the {point_of_comparison} coverage or adjust the "
33
34
"[target](https://docs.codecov.com/docs/commit-status#target) coverage."
34
35
)
36
+ CUSTOM_RCB_INDIRECT_CHANGES_VALUE = (
37
+ "Your {context} {notification_type} has failed because you have indirect coverage changes. "
38
+ "Learn more about [Unexpected Coverage Changes](https://docs.codecov.com/docs/unexpected-coverage-changes) "
39
+ "and [reasons for indirect coverage changes](https://docs.codecov.com/docs/unexpected-coverage-changes#reasons-for-indirect-changes)."
40
+ )
35
41
36
42
37
43
HELPER_TEXT_MAP = {
38
44
CUSTOM_TARGET_TEXT_PATCH_KEY : CUSTOM_TARGET_TEXT_VALUE ,
39
45
CUSTOM_TARGET_TEXT_PROJECT_KEY : CUSTOM_TARGET_TEXT_VALUE ,
46
+ CUSTOM_RCB_INDIRECT_CHANGES_KEY : CUSTOM_RCB_INDIRECT_CHANGES_VALUE ,
40
47
}
41
48
42
49
@@ -311,12 +318,15 @@ def _apply_adjust_base_behavior(
311
318
return None
312
319
313
320
def _apply_fully_covered_patch_behavior (
314
- self , comparison : ComparisonProxy | FilteredComparison
315
- ) -> tuple [str , str ] | None :
321
+ self ,
322
+ comparison : ComparisonProxy | FilteredComparison ,
323
+ notification_type : str ,
324
+ ) -> tuple [tuple [str , str ] | None , dict ]:
316
325
"""
317
326
Rule for passing project status on fully_covered_patch behavior:
318
- Pass if patch coverage is 100% and there are no unexpected changes
327
+ Pass if patch coverage is 100% and there are no indirect changes
319
328
"""
329
+ helper_text = {}
320
330
log .info (
321
331
"Applying fully_covered_patch behavior to project status" ,
322
332
extra = dict (commit = comparison .head .commit .commitid ),
@@ -332,23 +342,37 @@ def _apply_fully_covered_patch_behavior(
332
342
"Unexpected changes when applying patch_100 behavior" ,
333
343
extra = dict (commit = comparison .head .commit .commitid ),
334
344
)
335
- return None
345
+
346
+ # their comparison failed because of unexpected/indirect changes, give them helper text about it
347
+ helper_text [CUSTOM_RCB_INDIRECT_CHANGES_KEY ] = HELPER_TEXT_MAP [
348
+ CUSTOM_RCB_INDIRECT_CHANGES_KEY
349
+ ].format (
350
+ context = self .context ,
351
+ notification_type = notification_type ,
352
+ )
353
+ return None , helper_text
336
354
337
355
diff = comparison .get_diff (use_original_base = True )
338
356
patch_totals = comparison .head .report .apply_diff (diff )
339
357
if patch_totals is None or patch_totals .lines == 0 :
340
358
# Coverage was not changed by patch
341
359
return (
342
- StatusState .success .value ,
343
- ", passed because coverage was not affected by patch" ,
360
+ (
361
+ StatusState .success .value ,
362
+ ", passed because coverage was not affected by patch" ,
363
+ ),
364
+ helper_text ,
344
365
)
345
366
coverage = Decimal (patch_totals .coverage )
346
367
if coverage == 100.0 :
347
368
return (
348
- StatusState .success .value ,
349
- ", passed because patch was fully covered by tests, and no indirect coverage changes" ,
369
+ (
370
+ StatusState .success .value ,
371
+ ", passed because patch was fully covered by tests, and no indirect coverage changes" ,
372
+ ),
373
+ helper_text ,
350
374
)
351
- return None
375
+ return None , helper_text
352
376
353
377
def get_project_status (
354
378
self , comparison : ComparisonProxy | FilteredComparison , notification_type : str
@@ -373,9 +397,14 @@ def get_project_status(
373
397
elif removed_code_behavior == "adjust_base" :
374
398
removed_code_result = self ._apply_adjust_base_behavior (comparison )
375
399
elif removed_code_behavior == "fully_covered_patch" :
376
- removed_code_result = self ._apply_fully_covered_patch_behavior (
377
- comparison
400
+ removed_code_result , helper_text = (
401
+ self ._apply_fully_covered_patch_behavior (
402
+ comparison ,
403
+ notification_type = notification_type ,
404
+ )
378
405
)
406
+ # if user set this in their yaml, give them helper text related to it
407
+ result ["included_helper_text" ].update (helper_text )
379
408
else :
380
409
if removed_code_behavior not in [False , "off" ]:
381
410
log .warning (
0 commit comments