Skip to content

Commit

Permalink
Add platform compatibility check for incremental build (opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#4949)

Signed-off-by: Zelin Hao <[email protected]>
  • Loading branch information
zelinh authored Aug 19, 2024
1 parent 71f69a5 commit 91327a0
Show file tree
Hide file tree
Showing 6 changed files with 3,249 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/build_workflow/build_incremental.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

from manifests.build_manifest import BuildManifest
from manifests.input_manifest import InputManifest
from system.os import current_platform


class BuildIncremental:
def __init__(self, input_manifest: InputManifest, distribution: str):
def __init__(self, input_manifest: InputManifest, distribution: str, platform: str):
self.distribution = distribution
self.input_manifest = input_manifest
self.platform = platform or current_platform()

# Given input manifest and return a list of what components changed and added.
def commits_diff(self, input_manifest: InputManifest) -> List[str]:
Expand All @@ -31,6 +33,9 @@ def commits_diff(self, input_manifest: InputManifest) -> List[str]:
return [input_manifest.build.name.replace(" ", "-")]
components = []
for component in stable_input_manifest.components.select():
if component.platforms and self.platform not in component.platforms:
logging.info(f"Skipping {component.name} as it is not compatible with {self.platform}.")
continue
if component.name not in previous_build_manifest.components:
components.append(component.name)
logging.info(f"Adding {component.name} since it is missing from previous build manifest")
Expand Down
2 changes: 1 addition & 1 deletion src/run_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def main() -> int:
output_dir = BuildOutputDir(manifest.build.filename, args.distribution).dir

if args.incremental:
buildIncremental = BuildIncremental(manifest, args.distribution)
buildIncremental = BuildIncremental(manifest, args.distribution, args.platform)
list_of_updated_plugins = buildIncremental.commits_diff(manifest)
components = buildIncremental.rebuild_plugins(list_of_updated_plugins, manifest)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_run_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_usage(self) -> None:
os.path.join(os.path.dirname(__file__), "tests_build_workflow", "data", "opensearch-dashboards-input-2.12.0.yml"))
BUILD_MANIFEST_DASHBOARDS = BuildManifest.from_path(
os.path.join(os.path.dirname(__file__), "tests_build_workflow", "data", "opensearch-dashboards-build-tar-2.12.0.yml"))
buildIncremental = BuildIncremental(INPUT_MANIFEST, "tar")
buildIncremental = BuildIncremental(INPUT_MANIFEST, "tar", "linux")

@patch("argparse._sys.argv", ["run_build.py", OPENSEARCH_MANIFEST, "-p", "linux"])
@patch("run_build.Builders.builder_from", return_value=MagicMock())
Expand Down
Loading

0 comments on commit 91327a0

Please sign in to comment.