Skip to content

Commit e258f3a

Browse files
authored
Remove prefix library override for test files (#5862)
1 parent 27656be commit e258f3a

File tree

2 files changed

+14
-23
lines changed

2 files changed

+14
-23
lines changed

tests/test_the_test/test_compute_libraries_and_scenarios.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,16 @@ def test_library_tag(self):
235235
def test_wrong_library_tag(self):
236236
inputs = build_inputs(["utils/build/docker/python/test.Dockerfile"])
237237

238-
with pytest.raises(ValueError):
239-
process(inputs)
238+
strings_out = process(inputs)
239+
240+
assert strings_out == [
241+
'library_matrix=[{"library": "java", "version": "prod"}, {"library": "python", "version": "prod"}, {"library": "java", "version": "dev"}, {"library": "python", "version": "dev"}]',
242+
'libraries_with_dev=["java", "python"]',
243+
"desired_execution_time=3600",
244+
"rebuild_lambda_proxy=false",
245+
'scenarios="DEFAULT"',
246+
'scenarios_groups="end_to_end,open_telemetry"',
247+
]
240248

241249
@set_env("GITHUB_PR_TITLE", "[java@main] Some title")
242250
def test_wrong_library_tag_with_branch(self):
@@ -260,9 +268,9 @@ def test_wrong_library_tag_with_test_file(self):
260268
strings_out = process(inputs)
261269

262270
assert strings_out == [
263-
'library_matrix=[{"library": "java", "version": "prod"}, {"library": "java", "version": "dev"}]',
264-
'libraries_with_dev=["java"]',
265-
"desired_execution_time=600",
271+
all_lib_matrix,
272+
all_lib_with_dev,
273+
"desired_execution_time=3600",
266274
"rebuild_lambda_proxy=false",
267275
'scenarios="DEFAULT,INSTALLER_NOT_SUPPORTED_AUTO_INJECTION"',
268276
'scenarios_groups=""',

utils/scripts/compute_libraries_and_scenarios.py

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -155,26 +155,9 @@ def compute_impacted(self, modified_file: str, param: Param | None) -> None:
155155
logger.warning(f"Unknown file {modified_file} was detected, activating all libraries.")
156156
self.impacted |= LIBRARIES
157157

158-
def is_manual(self, file: str) -> bool:
159-
if not self.user_choice:
160-
return False
161-
162-
if self.branch_selector or len(self.impacted) == 0:
163-
return True
164-
# user specified a library in the PR title
165-
# and there are some impacted libraries
166-
if file.startswith("tests/") or self.impacted == {self.user_choice}:
167-
# modification in tests files are complex, trust user
168-
return True
169-
# only acceptable use case : impacted library exactly matches user choice
170-
raise ValueError(
171-
f"""File {file} is modified, and it may impact {", ".join(self.impacted)}.
172-
Please remove the PR title prefix [{self.user_choice}]"""
173-
)
174-
175158
def add(self, file: str, param: Param | None) -> None:
176159
self.compute_impacted(file, param)
177-
if not self.is_manual(file):
160+
if not (self.user_choice and self.branch_selector):
178161
self.selected |= self.impacted
179162

180163
def get_outputs(self) -> dict[str, Any]:

0 commit comments

Comments
 (0)