2626import argparse
2727from datetime import timedelta
2828import os
29+ import glob
2930import time
3031import json
3132from typing import Dict , Iterable , Set
5253
5354sdk_string = "/sdk/"
5455
56+ # Normally, this wouldn't be necessary but because sdk/core/ci.v2.yml exists it's necessary
57+ def proj_path_has_yml (proj_path ):
58+ file_pattern = "ci*.yml"
59+ matching_paths = glob .glob (file_pattern , root_dir = proj_path )
60+ if matching_paths :
61+ return True
62+ else :
63+ return False
64+
5565# Function that creates the aggregate POM.
5666def create_from_source_pom (artifacts_list : str , additional_modules_list : str , set_skip_linting_projects : str , match_any_version : bool ):
5767 artifacts_list_identifiers = artifacts_list .split (',' )
@@ -113,14 +123,18 @@ def create_from_source_pom(artifacts_list: str, additional_modules_list: str, se
113123 # the directory path needs to be added to the sparse checkout, otherwise it's one
114124 # directory up.
115125 proj_path = os .path .normpath (root_path + p .directory_path )
116- # proj_path_with_yml = os.path.normpath(proj_path + "/ci.yml")
117- # if os.path.exists(proj_path_with_yml):
118- # sparse_checkout_directory = p.directory_path
119- # else:
120- # Temporarily commenting out if / else above to resolve sparse checkout issue when running Communication
121- # library From Source live tests (plus possibly more). Will be reverted once all library checkouts are resolved.
126+ if proj_path_has_yml (proj_path ):
127+ yml_directory = p .directory_path
128+ else :
129+ yml_directory = '/' .join (p .directory_path .split ('/' )[0 :- 1 ])
130+
131+ # This is temporary, the sparse checkout directories should be the same directory where the yml
132+ # file lives but needs to be the sdk/<serviceDirectory>. The reason being that there are directories
133+ # whose ci.yml is in the library directory but there are dependencies on other directories in the
134+ # service directory, outside of their library directory. ex. several communication libraries
135+ # use sdk/communication/test-resources or sdk/clientcore/annotation-processor's ci.yml file
136+ # needs sdk/clientcore/annotation-processor-test
122137 sparse_checkout_directory = '/' .join (p .directory_path .split ('/' )[0 :- 1 ])
123-
124138 sparse_checkout_directories .add (sparse_checkout_directory )
125139
126140 # The ServiceDirectories list should only ever contain the list of service
@@ -129,8 +143,8 @@ def create_from_source_pom(artifacts_list: str, additional_modules_list: str, se
129143 # Sparse checkout directories can contain directories that aren't service directories.
130144 # (aka. /common). Any service directory will start with "/sdk/", everything else is
131145 # would be attributed to supporting libraries (ex. perf-test-core).
132- if sdk_string in sparse_checkout_directory :
133- service_directory = sparse_checkout_directory .replace (sdk_string , "" )
146+ if sdk_string in yml_directory :
147+ service_directory = yml_directory .replace (sdk_string , "" )
134148 service_directories .add (service_directory )
135149
136150 # output the SparseCheckoutDirectories environment variable
0 commit comments