1313from dataclasses import dataclass
1414from datetime import datetime , timedelta , timezone
1515from pathlib import Path
16- from typing import Any
16+ from typing import Any , Callable
1717
1818
1919GRADLE_VERSIONS_URL = "https://services.gradle.org/versions/all"
@@ -428,25 +428,49 @@ def validate_lockfiles(args: argparse.Namespace) -> int:
428428 print (f"::warning file={ relative_path } ::{ gav } : { 'Cannot verify age' if kind == 'unverified' else 'Too new' } . Reverted lockfile to baseline." )
429429
430430 reverted_files = len (violations_by_file )
431- summary = build_validation_summary (violations_by_file = violations_by_file , replacements_by_file = replacements_by_file , baseline_lockfiles = baseline_lockfiles , min_age_hours = args .min_age_hours )
432- emit_outputs ({"cutoff_at" : format_datetime (cutoff ), "reverted_files" : reverted_files , "summary" : summary }, args .github_output )
431+ summary_instrumentation = build_validation_summary (violations_by_file = violations_by_file , replacements_by_file = replacements_by_file , baseline_lockfiles = baseline_lockfiles , min_age_hours = args .min_age_hours , path_filter = is_instrumentation_path )
432+ summary_core = build_validation_summary (violations_by_file = violations_by_file , replacements_by_file = replacements_by_file , baseline_lockfiles = baseline_lockfiles , min_age_hours = args .min_age_hours , path_filter = lambda path : not is_instrumentation_path (path ))
433+ emit_outputs (
434+ {
435+ "cutoff_at" : format_datetime (cutoff ),
436+ "reverted_files" : reverted_files ,
437+ "summary_core" : summary_core ,
438+ "summary_instrumentation" : summary_instrumentation ,
439+ },
440+ args .github_output ,
441+ )
433442 print (f"Validated { len (changed )} changed coordinate(s) across { len (changed_by_file )} lockfile(s). { reverted_files } lockfile(s) reverted." )
434443 return 0
435444
436445
446+ # instrumentation lockfiles live under these prefixes and ship in a separate PR from core modules.
447+ # Keep in sync with the file split in .github/workflows/update-gradle-dependencies.yaml
448+ INSTRUMENTATION_PATH_PREFIXES = ("dd-smoke-tests/" , "dd-java-agent/instrumentation/" )
449+
450+
451+ # classify a lockfile path as belonging to the instrumentation PR (vs the core modules PR)
452+ def is_instrumentation_path (relative_path : str ) -> bool :
453+ normalized = relative_path .replace (os .sep , "/" )
454+ return normalized .startswith (INSTRUMENTATION_PATH_PREFIXES )
455+
456+
437457# build summary of reverted/downgraded dependencies for PR descriptions
458+ # path_filter restricts the summary to lockfiles whose relative path matches,
459+ # so each PR (core vs instrumentation) only lists the dependencies it actually changes
438460def build_validation_summary (
439461 * ,
440462 violations_by_file : dict [str , list [tuple [str , str , int ]]],
441463 replacements_by_file : dict [str , dict [str , tuple [str , int ]]],
442464 baseline_lockfiles : dict [str , set [str ]],
443465 min_age_hours : int ,
466+ path_filter : Callable [[str ], bool ],
444467) -> str :
445- if not violations_by_file and not replacements_by_file :
446- return ""
447- lines = [f"## Dependency age policy" , "" ]
468+ header = ["## Dependency age policy" , "" ]
469+ lines = list (header )
448470 seen : set [str ] = set ()
449471 for relative_path , replacements in replacements_by_file .items ():
472+ if not path_filter (relative_path ):
473+ continue
450474 baseline_coords = baseline_lockfiles .get (relative_path , set ())
451475 for old_gav , (new_gav , hours_remaining ) in replacements .items ():
452476 if old_gav not in seen :
@@ -456,14 +480,18 @@ def build_validation_summary(
456480 else :
457481 new_version = new_gav .rsplit (":" , 1 )[1 ]
458482 lines .append (f"- `{ old_gav } ` is { hours_remaining } h away from meeting { min_age_hours } h cooldown, updated to `{ new_version } `" )
459- for entries in violations_by_file .values ():
483+ for relative_path , entries in violations_by_file .items ():
484+ if not path_filter (relative_path ):
485+ continue
460486 for gav , kind , hours_remaining in entries :
461487 if gav not in seen :
462488 seen .add (gav )
463489 if kind == "unverified" :
464490 lines .append (f"- `{ gav } ` — cannot verify age, reverted" )
465491 else :
466492 lines .append (f"- `{ gav } ` is { hours_remaining } h away from meeting { min_age_hours } h cooldown, reverted" )
493+ if len (lines ) == len (header ): # nothing matched the filter
494+ return ""
467495 return "\n " .join (lines )
468496
469497
0 commit comments