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

[RPM M1] Add distribution supported components list so only specific scripts can take -d parameter #1652

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
7 changes: 6 additions & 1 deletion src/build_workflow/builder_from_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ def checkout(self, work_dir: str) -> None:
)

def build(self, build_recorder: BuildRecorder) -> None:

# List of components whose build scripts support `-d` parameter
# Bundled plugins do not need `-d` as they are java based zips
DISTRIBUTION_SUPPORTED_COMPONENTS = ["OpenSearch", "OpenSearch-Dashboards"]

build_script = ScriptFinder.find_build_script(self.target.name, self.component.name, self.git_repo.working_directory)

build_command = " ".join(
Expand All @@ -39,7 +44,7 @@ def build(self, build_recorder: BuildRecorder) -> None:
f"-v {self.target.version}",
f"-p {self.target.platform}",
f"-a {self.target.architecture}",
f"-d {self.target.distribution}" if self.target.distribution else None,
f"-d {self.target.distribution}" if self.target.distribution and (self.component.name in DISTRIBUTION_SUPPORTED_COMPONENTS) else None,
peterzhuamazon marked this conversation as resolved.
Show resolved Hide resolved
f"-s {str(self.target.snapshot).lower()}",
f"-o {self.output_path}",
]
Expand Down
33 changes: 33 additions & 0 deletions tests/tests_build_workflow/test_builder_from_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ def setUp(self) -> None:
),
)

self.builder_distribution_support = BuilderFromSource(
InputComponentFromSource({"name": "common-utils", "repository": "url", "ref": "ref"}),
BuildTarget(
name="OpenSearch",
version="1.3.0",
platform="linux",
architecture="x64",
distribution="rpm",
snapshot=False,
),
)

def test_builder(self) -> None:
self.assertEqual(self.builder.component.name, "common-utils")

Expand Down Expand Up @@ -86,6 +98,27 @@ def test_build_distribution(self, mock_git_repo: Mock) -> None:
)
build_recorder.record_component.assert_called_with("OpenSearch", mock_git_repo.return_value)

@patch("build_workflow.builder_from_source.GitRepository")
def test_build_distribution_support(self, mock_git_repo: Mock) -> None:
mock_git_repo.return_value = MagicMock(working_directory="dir")
build_recorder = MagicMock()
self.builder_distribution_support.checkout("dir")
self.builder_distribution_support.build(build_recorder)
mock_git_repo.return_value.execute.assert_called_with(
" ".join(
[
"bash",
os.path.realpath(os.path.join(ScriptFinder.component_scripts_path, "common-utils", "build.sh")),
"-v 1.3.0",
"-p linux",
"-a x64",
"-s false",
"-o builds",
]
)
)
build_recorder.record_component.assert_called_with("common-utils", mock_git_repo.return_value)

@patch("build_workflow.builder_from_source.GitRepository")
def test_build_snapshot(self, mock_git_repo: Mock) -> None:
self.builder.target.snapshot = True
Expand Down