From e6288a3ee7a75e74d6cdba0e836dc98bbcd5dc8c Mon Sep 17 00:00:00 2001 From: Ralph Ursprung Date: Tue, 1 Nov 2022 09:25:34 +0100 Subject: [PATCH] remove OpenSearch `build.sh`: moved to OpenSearch repo `build.sh` has been copied over to all active branches(*) of the OpenSearch repo and can now consequently be deleted here. this means, that from now on, the scripts from the respository will be picked up. for more information on the order of evaluation of the custom build scripts, see the [documentation][]. this gives the advantage to have branch-specific new logic in place there. this has already been used to add the no-jdk targets to the builds on main and 2.x. two tests were based on the assumption that there would be a `build.sh` for OpenSearch in this repository, however these are generic tests and just used OpenSearch as an example. they have been switched to be based on OpenSearch-Dashboards instead which - for the time being - still has its own `build.sh` here. (*): the following branches have been considered as active: - main - 2.x - 2.3 - 1.x - 1.3 this is part of opensearch-project/opensearch-build#99 [documentation]: https://github.com/opensearch-project/opensearch-build/tree/main/src/build_workflow#custom-build-scripts Signed-off-by: Ralph Ursprung --- scripts/components/OpenSearch/build.sh | 161 ------------------ .../test_builder_from_source.py | 6 +- tests/tests_paths/test_script_finder.py | 8 +- 3 files changed, 7 insertions(+), 168 deletions(-) delete mode 100755 scripts/components/OpenSearch/build.sh diff --git a/scripts/components/OpenSearch/build.sh b/scripts/components/OpenSearch/build.sh deleted file mode 100755 index a091777650..0000000000 --- a/scripts/components/OpenSearch/build.sh +++ /dev/null @@ -1,161 +0,0 @@ -#!/bin/bash - -# Copyright OpenSearch Contributors -# SPDX-License-Identifier: Apache-2.0 -# -# The OpenSearch Contributors require contributions made to -# this file be licensed under the Apache-2.0 license or a -# compatible open source license. - -set -ex - -function usage() { - echo "Usage: $0 [args]" - echo "" - echo "Arguments:" - echo -e "-v VERSION\t[Required] OpenSearch version." - echo -e "-q QUALIFIER\t[Optional] Version qualifier." - echo -e "-s SNAPSHOT\t[Optional] Build a snapshot, default is 'false'." - echo -e "-p PLATFORM\t[Optional] Platform, default is 'uname -s'." - echo -e "-a ARCHITECTURE\t[Optional] Build architecture, default is 'uname -m'." - echo -e "-d DISTRIBUTION\t[Optional] Distribution, default is 'tar'." - echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'." - echo -e "-h help" -} - -while getopts ":h:v:q:s:o:p:a:d:" arg; do - case $arg in - h) - usage - exit 1 - ;; - v) - VERSION=$OPTARG - ;; - q) - QUALIFIER=$OPTARG - ;; - s) - SNAPSHOT=$OPTARG - ;; - o) - OUTPUT=$OPTARG - ;; - p) - PLATFORM=$OPTARG - ;; - a) - ARCHITECTURE=$OPTARG - ;; - d) - DISTRIBUTION=$OPTARG - ;; - :) - echo "Error: -${OPTARG} requires an argument" - usage - exit 1 - ;; - ?) - echo "Invalid option: -${arg}" - exit 1 - ;; - esac -done - -if [ -z "$VERSION" ]; then - echo "Error: You must specify the OpenSearch version" - usage - exit 1 -fi - -[ -z "$OUTPUT" ] && OUTPUT=artifacts - -mkdir -p $OUTPUT/maven/org/opensearch - -# Build project and publish to maven local. -./gradlew publishToMavenLocal -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER - -# Publish to existing test repo, using this to stage release versions of the artifacts that can be released from the same build. -./gradlew publishNebulaPublicationToTestRepository -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER - -# Copy maven publications to be promoted -cp -r ./build/local-test-repo/org/opensearch "${OUTPUT}"/maven/org - -# Assemble distribution artifact -# see https://github.com/opensearch-project/OpenSearch/blob/main/settings.gradle#L34 for other distribution targets - -[ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}') -[ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m` -[ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar" - -case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in - linux-tar-x64|darwin-tar-x64) - PACKAGE="tar" - EXT="tar.gz" - TYPE="archives" - TARGET="$PLATFORM-$PACKAGE" - SUFFIX="$PLATFORM-x64" - ;; - linux-tar-arm64|darwin-tar-arm64) - PACKAGE="tar" - EXT="tar.gz" - TYPE="archives" - TARGET="$PLATFORM-arm64-$PACKAGE" - SUFFIX="$PLATFORM-arm64" - ;; - linux-rpm-x64) - PACKAGE="rpm" - EXT="rpm" - TYPE="packages" - TARGET="rpm" - SUFFIX="x86_64" - ;; - linux-rpm-arm64) - PACKAGE="rpm" - EXT="rpm" - TYPE="packages" - TARGET="arm64-rpm" - SUFFIX="aarch64" - ;; - windows-zip-x64) - PACKAGE="zip" - EXT="zip" - TYPE="archives" - TARGET="$PLATFORM-$PACKAGE" - SUFFIX="$PLATFORM-x64" - ;; - windows-zip-arm64) - PACKAGE="zip" - EXT="zip" - TYPE="archives" - TARGET="$PLATFORM-arm64-$PACKAGE" - SUFFIX="$PLATFORM-arm64" - ;; - *) - echo "Unsupported platform-distribution-architecture combination: $PLATFORM-$DISTRIBUTION-$ARCHITECTURE" - exit 1 - ;; -esac - -echo "Building OpenSearch for $PLATFORM-$DISTRIBUTION-$ARCHITECTURE" - -./gradlew :distribution:$TYPE:$TARGET:assemble -Dbuild.snapshot=$SNAPSHOT -Dbuild.version_qualifier=$QUALIFIER - -# Copy artifact to dist folder in bundle build output -[[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT" -ARTIFACT_BUILD_NAME=`ls distribution/$TYPE/$TARGET/build/distributions/ | grep "opensearch-min.*$SUFFIX.$EXT"` -mkdir -p "${OUTPUT}/dist" -cp distribution/$TYPE/$TARGET/build/distributions/$ARTIFACT_BUILD_NAME "${OUTPUT}"/dist/$ARTIFACT_BUILD_NAME - -echo "Building core plugins..." -mkdir -p "${OUTPUT}/core-plugins" -cd plugins -../gradlew assemble -Dbuild.snapshot="$SNAPSHOT" -Dbuild.version_qualifier=$QUALIFIER -cd .. -for plugin in plugins/*; do - PLUGIN_NAME=$(basename "$plugin") - if [ -d "$plugin" ] && [ "examples" != "$PLUGIN_NAME" ]; then - PLUGIN_ARTIFACT_BUILD_NAME=`ls "$plugin"/build/distributions/ | grep "$PLUGIN_NAME.*$IDENTIFIER.zip"` - cp "$plugin"/build/distributions/"$PLUGIN_ARTIFACT_BUILD_NAME" "${OUTPUT}"/core-plugins/"$PLUGIN_ARTIFACT_BUILD_NAME" - fi -done diff --git a/tests/tests_build_workflow/test_builder_from_source.py b/tests/tests_build_workflow/test_builder_from_source.py index 1d05229553..2a4a297913 100644 --- a/tests/tests_build_workflow/test_builder_from_source.py +++ b/tests/tests_build_workflow/test_builder_from_source.py @@ -30,7 +30,7 @@ def setUp(self) -> None: ) self.builder_distribution = BuilderFromSource( - InputComponentFromSource({"name": "OpenSearch", "repository": "url", "ref": "ref"}), + InputComponentFromSource({"name": "OpenSearch-Dashboards", "repository": "url", "ref": "ref"}), BuildTarget( name="OpenSearch", version="1.3.0", @@ -99,7 +99,7 @@ def test_build_distribution(self, mock_git_repo: Mock) -> None: " ".join( [ "bash", - os.path.realpath(os.path.join(ScriptFinder.component_scripts_path, "OpenSearch", "build.sh")), + os.path.realpath(os.path.join(ScriptFinder.component_scripts_path, "OpenSearch-Dashboards", "build.sh")), "-v 1.3.0", "-p linux", "-a x64", @@ -109,7 +109,7 @@ def test_build_distribution(self, mock_git_repo: Mock) -> None: ] ) ) - build_recorder.record_component.assert_called_with("OpenSearch", mock_git_repo.return_value) + build_recorder.record_component.assert_called_with("OpenSearch-Dashboards", mock_git_repo.return_value) @patch("build_workflow.builder_from_source.GitRepository") def test_build_distribution_support(self, mock_git_repo: Mock) -> None: diff --git a/tests/tests_paths/test_script_finder.py b/tests/tests_paths/test_script_finder.py index 18e59d4c3b..d52828b232 100644 --- a/tests/tests_paths/test_script_finder.py +++ b/tests/tests_paths/test_script_finder.py @@ -39,8 +39,8 @@ def test_find_build_script_opensearch_dashboards_default(self) -> None: def test_find_build_script_component_override(self) -> None: self.assertEqual( - os.path.join(ScriptFinder.component_scripts_path, "OpenSearch", "build.sh"), - ScriptFinder.find_build_script("OpenSearch", "OpenSearch", self.component_without_scripts), + os.path.join(ScriptFinder.component_scripts_path, "OpenSearch-Dashboards", "build.sh"), + ScriptFinder.find_build_script("OpenSearch-Dashboards", "OpenSearch-Dashboards", self.component_without_scripts), msg="A component without scripts resolves to a component override.", ) @@ -60,8 +60,8 @@ def test_find_build_script_component_script_in_folder(self) -> None: def test_find_build_script_component_script_in_folder_with_default(self) -> None: self.assertEqual( - os.path.join(ScriptFinder.component_scripts_path, "OpenSearch", "build.sh"), - ScriptFinder.find_build_script("OpenSearch", "OpenSearch", self.component_with_scripts_folder), + os.path.join(ScriptFinder.component_scripts_path, "OpenSearch-Dashboards", "build.sh"), + ScriptFinder.find_build_script("OpenSearch-Dashboards", "OpenSearch-Dashboards", self.component_with_scripts_folder), msg="A component with a scripts folder resolves to the override.", )