Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return all library names if repo-level parameter changes #3379

Merged
merged 4 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions hermetic_build/common/cli/get_changed_libraries.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ def create(
baseline_config=from_yaml(baseline_generation_config_path),
current_config=from_yaml(current_generation_config_path),
)
changed_libraries = config_change.get_changed_libraries()
if changed_libraries is None:
print("No changed library.")
return
click.echo(",".join(config_change.get_changed_libraries()))


Expand Down
9 changes: 4 additions & 5 deletions hermetic_build/common/model/config_change.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def __init__(self, commit: Commit, libraries: set[str]):


class ConfigChange:
ALL_LIBRARIES_CHANGED = None

def __init__(
self,
Expand All @@ -74,16 +73,16 @@ def __init__(
self.baseline_config = baseline_config
self.current_config = current_config

def get_changed_libraries(self) -> Optional[list[str]]:
def get_changed_libraries(self) -> list[str]:
"""
Returns a unique, sorted list of library name of changed libraries.
None if there is a repository level change, which means all libraries
in the current_config will be generated.

:return: library names of change libraries.
"""
if ChangeType.REPO_LEVEL_CHANGE in self.change_to_libraries:
return ConfigChange.ALL_LIBRARIES_CHANGED
return [
library.get_library_name() for library in self.current_config.libraries
]
library_names = set()
for change_type, library_changes in self.change_to_libraries.items():
if change_type == ChangeType.GOOGLEAPIS_COMMIT:
Expand Down
20 changes: 18 additions & 2 deletions hermetic_build/common/tests/model/config_change_unit_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,26 @@ def test_get_changed_libraries_with_repo_level_change_returns_all_libraries_chan
],
},
baseline_config=ConfigChangeTest.__get_a_gen_config(),
current_config=ConfigChangeTest.__get_a_gen_config(),
current_config=ConfigChangeTest.__get_a_gen_config(
googleapis_commitish="",
libraries=[
ConfigChangeTest.__get_a_library_config(
library_name="gke-backup",
gapic_configs=[
GapicConfig(proto_path="google/cloud/gkebackup/v1")
],
),
ConfigChangeTest.__get_a_library_config(
library_name="test-library",
gapic_configs=[
GapicConfig(proto_path="google/cloud/gkebackup/v1")
],
),
],
),
)
self.assertEqual(
ConfigChange.ALL_LIBRARIES_CHANGED,
["gke-backup", "test-library"],
config_change.get_changed_libraries(),
)

Expand Down
Loading