From b9b58ae2deb5bbfd62a95b2c63df0533b6f0c2b8 Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Sun, 27 Mar 2022 08:55:58 +0000 Subject: [PATCH] [BUILD][OSD] Support version qualifier Support version qualifier builds for OpenSearch Dashboards and OpenSearch Dashboards Plugins. This will create a zip for plugins with the OpenSearch Dashboards version + qualifier. But the version of the plugin will remain the same whilst opensearchDashboardsVersion in the opensearch_dashboards.json will be the OpenSearch Dashboards version, eg, 1.3.0-alpha1. This is why the version check needed to be modified a little to ensure that it can get the version + qualifier and the default version of the plugin. Updated for plugins as well. Was able to successfully build and connect OSD 1.3.0-alpha1 to the release version of OS 1.3.0. Issue resolved: https://github.com/opensearch-project/OpenSearch-Dashboards/issues/1340 Issue partially resolved: https://github.com/opensearch-project/opensearch-build/issues/1632 Signed-off-by: Kawika Avilla --- .../2.0.0/opensearch-dashboards-2.0.0.yml | 1 + .../components/OpenSearch-Dashboards/build.sh | 21 ++++++++------ .../components/ganttChartDashboards/build.sh | 11 ++++++-- .../components/notebooksDashboards/build.sh | 11 ++++++-- .../notificationsDashboards/build.sh | 11 ++++++-- .../observabilityDashboards/build.sh | 11 ++++++-- .../queryWorkbenchDashboards/build.sh | 11 ++++++-- scripts/components/reportsDashboards/build.sh | 15 ++++++---- .../default/opensearch-dashboards/build.sh | 6 ++-- scripts/default/opensearch/build.sh | 1 + src/build_workflow/build_target.py | 6 +++- .../opensearch/build_artifact_check_maven.py | 2 +- .../build_artifact_check_plugin.py | 8 +++--- ...fact_opensearch_dashboards_check_plugin.py | 2 +- .../tests_build_workflow/test_build_target.py | 28 +++++++++++++------ 15 files changed, 100 insertions(+), 45 deletions(-) diff --git a/manifests/2.0.0/opensearch-dashboards-2.0.0.yml b/manifests/2.0.0/opensearch-dashboards-2.0.0.yml index 8c0aaaeff4..b88235bbfb 100644 --- a/manifests/2.0.0/opensearch-dashboards-2.0.0.yml +++ b/manifests/2.0.0/opensearch-dashboards-2.0.0.yml @@ -3,6 +3,7 @@ schema-version: '1.0' build: name: OpenSearch Dashboards version: 2.0.0 + qualifier: alpha1 ci: image: name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build diff --git a/scripts/components/OpenSearch-Dashboards/build.sh b/scripts/components/OpenSearch-Dashboards/build.sh index 5482447cdb..6f91aff7e4 100755 --- a/scripts/components/OpenSearch-Dashboards/build.sh +++ b/scripts/components/OpenSearch-Dashboards/build.sh @@ -10,6 +10,7 @@ function usage() { echo "" echo "Arguments:" echo -e "-v VERSION\t[Required] OpenSearch Dashboards 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'." @@ -18,7 +19,7 @@ function usage() { echo -e "-h help" } -while getopts ":h:v:s:o:p:a:d:" arg; do +while getopts ":h:v:q:s:o:p:a:d:" arg; do case $arg in h) usage @@ -27,6 +28,9 @@ while getopts ":h:v:s:o:p:a:d:" arg; do v) VERSION=$OPTARG ;; + q) + QUALIFIER=$OPTARG + ;; s) SNAPSHOT=$OPTARG ;; @@ -64,6 +68,7 @@ fi [ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}') [ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m` [ -z "$DISTRIBUTION" ] && DISTRIBUTION="tar" +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" [[ "$SNAPSHOT" == "true" ]] && IDENTIFIER="-SNAPSHOT" [[ "$SNAPSHOT" != "true" ]] && RELEASE="--release" @@ -75,28 +80,28 @@ case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in EXT="tar.gz" BUILD_PARAMS="build-platform" EXTRA_PARAMS="--skip-os-packages" - QUALIFIER="$PLATFORM-x64" + SUFFIX="$PLATFORM-x64" ;; linux-tar-arm64) TARGET="--$PLATFORM-arm" EXT="tar.gz" BUILD_PARAMS="build-platform" EXTRA_PARAMS="--skip-os-packages" - QUALIFIER="$PLATFORM-arm64" + SUFFIX="$PLATFORM-arm64" ;; linux-rpm-x64) TARGET="--$DISTRIBUTION" EXT="$DISTRIBUTION" BUILD_PARAMS="build" EXTRA_PARAMS="--skip-archives" - QUALIFIER="x64" + SUFFIX="x64" ;; linux-rpm-arm64) TARGET="--$DISTRIBUTION-arm" EXT="$DISTRIBUTION" BUILD_PARAMS="build" EXTRA_PARAMS="--skip-archives" - QUALIFIER="arm64" + SUFFIX="arm64" ;; *) echo "Unsupported platform-distribution-architecture combination: $PLATFORM-$DISTRIBUTION-$ARCHITECTURE" @@ -109,10 +114,10 @@ yarn osd bootstrap echo "Building artifact" -yarn $BUILD_PARAMS $TARGET $EXTRA_PARAMS $RELEASE +yarn $BUILD_PARAMS $TARGET $EXTRA_PARAMS $RELEASE --version-qualifier=$QUALIFIER mkdir -p "${OUTPUT}/dist" # Copy artifact to dist folder in bundle build output -ARTIFACT_BUILD_NAME=opensearch-dashboards-$VERSION$IDENTIFIER-$QUALIFIER.$EXT -ARTIFACT_TARGET_NAME=opensearch-dashboards-min-$VERSION$IDENTIFIER-$QUALIFIER.$EXT +ARTIFACT_BUILD_NAME=opensearch-dashboards-$VERSION$QUALIFIER_IDENTIFIER$IDENTIFIER-$SUFFIX.$EXT +ARTIFACT_TARGET_NAME=opensearch-dashboards-min-$VERSION$QUALIFIER_IDENTIFIER$IDENTIFIER-$SUFFIX.$EXT cp target/$ARTIFACT_BUILD_NAME $OUTPUT/dist/$ARTIFACT_TARGET_NAME diff --git a/scripts/components/ganttChartDashboards/build.sh b/scripts/components/ganttChartDashboards/build.sh index 0782be8e87..80e49f4734 100755 --- a/scripts/components/ganttChartDashboards/build.sh +++ b/scripts/components/ganttChartDashboards/build.sh @@ -13,6 +13,7 @@ function usage() { 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, ignored." echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." @@ -20,7 +21,7 @@ function usage() { echo -e "-h help" } -while getopts ":h:v:s:o:p:a:" arg; do +while getopts ":h:v:q:s:o:p:a:" arg; do case $arg in h) usage @@ -29,6 +30,9 @@ while getopts ":h:v:s:o:p:a:" arg; do v) VERSION=$OPTARG ;; + q) + QUALIFIER=$OPTARG + ;; s) SNAPSHOT=$OPTARG ;; @@ -60,6 +64,7 @@ if [ -z "$VERSION" ]; then fi [ -z "$OUTPUT" ] && OUTPUT=artifacts +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" mkdir -p $OUTPUT/plugins # For hybrid plugin it actually resides in 'ganttChartDashboards/gantt-chart' @@ -71,7 +76,7 @@ cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin-helpers build) +(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) echo "COPY $PLUGIN_NAME.zip" -cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION.zip $OUTPUT/plugins/ +cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER \ No newline at end of file diff --git a/scripts/components/notebooksDashboards/build.sh b/scripts/components/notebooksDashboards/build.sh index 19e51827f2..771c6837cc 100755 --- a/scripts/components/notebooksDashboards/build.sh +++ b/scripts/components/notebooksDashboards/build.sh @@ -13,6 +13,7 @@ function usage() { 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, ignored." echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." @@ -20,7 +21,7 @@ function usage() { echo -e "-h help" } -while getopts ":h:v:s:o:p:a:" arg; do +while getopts ":h:v:q:s:o:p:a:" arg; do case $arg in h) usage @@ -29,6 +30,9 @@ while getopts ":h:v:s:o:p:a:" arg; do v) VERSION=$OPTARG ;; + q) + QUALIFIER=$OPTARG + ;; s) SNAPSHOT=$OPTARG ;; @@ -60,6 +64,7 @@ if [ -z "$VERSION" ]; then fi [ -z "$OUTPUT" ] && OUTPUT=artifacts +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" mkdir -p $OUTPUT/plugins # For hybrid plugin it actually resides in 'notebooksDashboards/dashboards-notebooks' @@ -71,7 +76,7 @@ cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin-helpers build) +(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) echo "COPY $PLUGIN_NAME.zip" -cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION.zip $OUTPUT/plugins/ +cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER \ No newline at end of file diff --git a/scripts/components/notificationsDashboards/build.sh b/scripts/components/notificationsDashboards/build.sh index 93c3c5ed62..c6c9fff43e 100755 --- a/scripts/components/notificationsDashboards/build.sh +++ b/scripts/components/notificationsDashboards/build.sh @@ -13,6 +13,7 @@ function usage() { 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, ignored." echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." @@ -20,7 +21,7 @@ function usage() { echo -e "-h help" } -while getopts ":h:v:s:o:p:a:" arg; do +while getopts ":h:v:q:s:o:p:a:" arg; do case $arg in h) usage @@ -29,6 +30,9 @@ while getopts ":h:v:s:o:p:a:" arg; do v) VERSION=$OPTARG ;; + q) + QUALIFIER=$OPTARG + ;; s) SNAPSHOT=$OPTARG ;; @@ -60,6 +64,7 @@ if [ -z "$VERSION" ]; then fi [ -z "$OUTPUT" ] && OUTPUT=artifacts +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" mkdir -p $OUTPUT/plugins # For hybrid plugin it actually resides in 'notificationsDashboards/dashboards-notifications' @@ -71,7 +76,7 @@ cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build) +(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) echo "COPY $PLUGIN_NAME.zip" -cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION.zip $OUTPUT/plugins/ +cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER \ No newline at end of file diff --git a/scripts/components/observabilityDashboards/build.sh b/scripts/components/observabilityDashboards/build.sh index a8fd366beb..9c2e0a7d42 100755 --- a/scripts/components/observabilityDashboards/build.sh +++ b/scripts/components/observabilityDashboards/build.sh @@ -13,6 +13,7 @@ function usage() { 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, ignored." echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." @@ -20,7 +21,7 @@ function usage() { echo -e "-h help" } -while getopts ":h:v:s:o:p:a:" arg; do +while getopts ":h:v:q:s:o:p:a:" arg; do case $arg in h) usage @@ -29,6 +30,9 @@ while getopts ":h:v:s:o:p:a:" arg; do v) VERSION=$OPTARG ;; + q) + QUALIFIER=$OPTARG + ;; s) SNAPSHOT=$OPTARG ;; @@ -60,6 +64,7 @@ if [ -z "$VERSION" ]; then fi [ -z "$OUTPUT" ] && OUTPUT=artifacts +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" mkdir -p $OUTPUT/plugins # For hybrid plugin it actually resides in 'observability/dashboards-observability' @@ -71,7 +76,7 @@ cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build) +(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) echo "COPY $PLUGIN_NAME.zip" -cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION.zip $OUTPUT/plugins/ +cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER diff --git a/scripts/components/queryWorkbenchDashboards/build.sh b/scripts/components/queryWorkbenchDashboards/build.sh index 73ca784456..437c118d58 100755 --- a/scripts/components/queryWorkbenchDashboards/build.sh +++ b/scripts/components/queryWorkbenchDashboards/build.sh @@ -13,6 +13,7 @@ function usage() { 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, ignored." echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." @@ -20,7 +21,7 @@ function usage() { echo -e "-h help" } -while getopts ":h:v:s:o:p:a:" arg; do +while getopts ":h:v:q:s:o:p:a:" arg; do case $arg in h) usage @@ -29,6 +30,9 @@ while getopts ":h:v:s:o:p:a:" arg; do v) VERSION=$OPTARG ;; + q) + QUALIFIER=$OPTARG + ;; s) SNAPSHOT=$OPTARG ;; @@ -60,6 +64,7 @@ if [ -z "$VERSION" ]; then fi [ -z "$OUTPUT" ] && OUTPUT=artifacts +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" mkdir -p $OUTPUT/plugins # For hybrid plugin it actually resides in 'queryWorkbenchDashboards/workbench' @@ -71,7 +76,7 @@ cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build) +(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) echo "COPY $PLUGIN_NAME.zip" -cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION.zip $OUTPUT/plugins/ +cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER \ No newline at end of file diff --git a/scripts/components/reportsDashboards/build.sh b/scripts/components/reportsDashboards/build.sh index 047d6fefb4..da9058ef76 100755 --- a/scripts/components/reportsDashboards/build.sh +++ b/scripts/components/reportsDashboards/build.sh @@ -13,6 +13,7 @@ function usage() { 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'." @@ -20,7 +21,7 @@ function usage() { echo -e "-h help" } -while getopts ":h:v:s:o:p:a:" arg; do +while getopts ":h:v:q:s:o:p:a:" arg; do case $arg in h) usage @@ -29,6 +30,9 @@ while getopts ":h:v:s:o:p:a:" arg; do v) VERSION=$OPTARG ;; + q) + QUALIFIER=$OPTARG + ;; s) SNAPSHOT=$OPTARG ;; @@ -62,6 +66,7 @@ fi [ -z "$OUTPUT" ] && OUTPUT=artifacts [ -z "$PLATFORM" ] && PLATFORM=$(uname -s | awk '{print tolower($0)}') [ -z "$ARCHITECTURE" ] && ARCHITECTURE=`uname -m` +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" case $PLATFORM in linux*) @@ -99,17 +104,17 @@ cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build) +(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) ZIP_NAME=`ls ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build | grep .zip` unzip ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$ZIP_NAME -d ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/ # Reporting uses headless chromium to generate reports, which needs to be included in its artifact echo "DOWNLOADING CHROMIUM FOR $PLUGIN_NAME" mkdir -p ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/opensearch-dashboards/$PLUGIN_NAME curl -SL "$CHROMIUM_URL" -o $CHROMIUM_TARGET -echo "PUTTING CHROMIUM INSIDE $PLUGIN_NAME-$VERSION.zip" +echo "PUTTING CHROMIUM INSIDE $PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip" unzip "$CHROMIUM_TARGET" -d ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/opensearch-dashboards/$PLUGIN_NAME -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build && zip -ur $PLUGIN_NAME-$VERSION.zip opensearch-dashboards) +(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build && zip -ur $PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip opensearch-dashboards) echo "COPY $PLUGIN_NAME.zip" -cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION.zip $OUTPUT/plugins/ +cp -r ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ rm -rf ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER diff --git a/scripts/default/opensearch-dashboards/build.sh b/scripts/default/opensearch-dashboards/build.sh index 31c4ae0996..7ebd472f09 100755 --- a/scripts/default/opensearch-dashboards/build.sh +++ b/scripts/default/opensearch-dashboards/build.sh @@ -13,6 +13,7 @@ function usage() { 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, ignored." echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." @@ -63,6 +64,7 @@ if [ -z "$VERSION" ]; then fi [ -z "$OUTPUT" ] && OUTPUT=artifacts +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" mkdir -p $OUTPUT/plugins PLUGIN_NAME=$(basename "$PWD") @@ -72,7 +74,7 @@ cp -r ../$PLUGIN_NAME/ ../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../OpenSearch-Dashboards && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME && yarn plugin-helpers build) +(cd ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) echo "COPY $PLUGIN_NAME.zip" -cp -r ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME/build/$PLUGIN_NAME-$VERSION.zip $OUTPUT/plugins/ +cp -r ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ rm -rf ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME \ No newline at end of file diff --git a/scripts/default/opensearch/build.sh b/scripts/default/opensearch/build.sh index 11007f1361..7c33ece42f 100755 --- a/scripts/default/opensearch/build.sh +++ b/scripts/default/opensearch/build.sh @@ -13,6 +13,7 @@ function usage() { 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, ignored." echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." diff --git a/src/build_workflow/build_target.py b/src/build_workflow/build_target.py index 9687e44c5e..b76570968c 100644 --- a/src/build_workflow/build_target.py +++ b/src/build_workflow/build_target.py @@ -55,7 +55,7 @@ def opensearch_version(self) -> str: ) @property - def compatible_opensearch_versions(self) -> List[str]: + def compatible_core_versions(self) -> List[str]: return ( [BuildTarget.__qualify_version(self.version, self.qualifier, self.snapshot)] + self.patches @@ -79,6 +79,10 @@ def compatible_component_versions(self) -> List[str]: + list(map(lambda version: BuildTarget.__qualify_version(version + ".0", self.qualifier, True), self.patches)) ) + @property + def compatible_opensearch_dashboards_component_versions(self) -> List[str]: + return list(set([self.version + ".0"] + self.compatible_component_versions)) + @property def compatible_versions(self) -> List[str]: versions = [self.version] diff --git a/src/build_workflow/opensearch/build_artifact_check_maven.py b/src/build_workflow/opensearch/build_artifact_check_maven.py index 75e1c4161f..1197067a4b 100644 --- a/src/build_workflow/opensearch/build_artifact_check_maven.py +++ b/src/build_workflow/opensearch/build_artifact_check_maven.py @@ -37,7 +37,7 @@ def check(self, path: str) -> None: try: versions: List[Any] = [None] versions.extend(self.target.compatible_component_versions) - versions.extend(self.target.compatible_opensearch_versions) + versions.extend(self.target.compatible_core_versions) properties.check_value_in("Implementation-Version", versions) except PropertiesFile.CheckError as e: raise BuildArtifactCheck.BuildArtifactInvalidError(path, str(e)) diff --git a/src/build_workflow/opensearch_dashboards/build_artifact_check_plugin.py b/src/build_workflow/opensearch_dashboards/build_artifact_check_plugin.py index cd40031d0c..002bf85f81 100644 --- a/src/build_workflow/opensearch_dashboards/build_artifact_check_plugin.py +++ b/src/build_workflow/opensearch_dashboards/build_artifact_check_plugin.py @@ -19,7 +19,7 @@ def check(self, path: str) -> None: if os.path.splitext(path)[1] != ".zip": raise BuildArtifactCheck.BuildArtifactInvalidError(path, "Not a zip file.") - match = re.search(r"^(\w+)-[\d\.]*.*.zip$", os.path.basename(path)) + match = re.search(r"^(\w+)-[\d\.]*.*(-*)?.zip$", os.path.basename(path)) if not match: raise BuildArtifactCheck.BuildArtifactInvalidError(path, "Expected filename to be in the format of pluginName-1.1.0.zip.") @@ -32,11 +32,11 @@ def check(self, path: str) -> None: data = zip.read(f"opensearch-dashboards/{plugin_name}/opensearch_dashboards.json").decode("UTF-8") config = ConfigFile(data) try: - config.check_value_in("version", self.target.compatible_component_versions) - config.check_value_in("opensearchDashboardsVersion", self.target.compatible_versions) + config.check_value_in("version", self.target.compatible_opensearch_dashboards_component_versions) + config.check_value_in("opensearchDashboardsVersion", self.target.compatible_core_versions) except ConfigFile.CheckError as e: raise BuildArtifactCheck.BuildArtifactInvalidError(path, e.__str__()) logging.info(f'Checked {path} ({config.get_value("version", "N/A")})') def __valid_paths(self, pluginName: str) -> List[str]: - return list(map(lambda version: f"{pluginName}-{version}.zip", self.target.compatible_versions)) + return list(map(lambda version: f"{pluginName}-{version}.zip", self.target.compatible_core_versions)) diff --git a/tests/tests_build_workflow/opensearch_dashboards/test_build_artifact_opensearch_dashboards_check_plugin.py b/tests/tests_build_workflow/opensearch_dashboards/test_build_artifact_opensearch_dashboards_check_plugin.py index 06c010cbed..30b40d2dd6 100644 --- a/tests/tests_build_workflow/opensearch_dashboards/test_build_artifact_opensearch_dashboards_check_plugin.py +++ b/tests/tests_build_workflow/opensearch_dashboards/test_build_artifact_opensearch_dashboards_check_plugin.py @@ -63,7 +63,7 @@ def test_check_plugin_invalid_version_in_filename(self) -> None: with self.__mock(snapshot=False) as mock: mock.check("pluginName-1.2.3.zip") self.assertEqual( - "Artifact pluginName-1.2.3.zip is invalid. Expected filename to to be one of ['pluginName-1.1.0.zip', 'pluginName-1.0.0.zip'].", + "Artifact pluginName-1.2.3.zip is invalid. Expected filename to to be one of ['pluginName-1.1.0.zip', 'pluginName-1.0.0.zip', 'pluginName-1.0.0-SNAPSHOT.zip'].", str(context.exception), ) diff --git a/tests/tests_build_workflow/test_build_target.py b/tests/tests_build_workflow/test_build_target.py index 0d166a5c41..557f5cd197 100644 --- a/tests/tests_build_workflow/test_build_target.py +++ b/tests/tests_build_workflow/test_build_target.py @@ -52,27 +52,27 @@ def test_opensearch_version_snapshot_qualifier(self) -> None: "1.1.0-alpha1-SNAPSHOT", ) - def test_compatible_opensearch_versions(self) -> None: + def test_compatible_core_versions(self) -> None: self.assertEqual( - BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=False).compatible_opensearch_versions, + BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=False).compatible_core_versions, ['1.1.2', '1.1.0', '1.1.1', '1.1.0-SNAPSHOT', '1.1.1-SNAPSHOT'], ) - def test_compatible_opensearch_versions_qualifier(self) -> None: + def test_compatible_core_versions_qualifier(self) -> None: self.assertEqual( - BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=False, qualifier="alpha1").compatible_opensearch_versions, + BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=False, qualifier="alpha1").compatible_core_versions, ['1.1.2-alpha1', '1.1.0', '1.1.1', '1.1.0-alpha1-SNAPSHOT', '1.1.1-alpha1-SNAPSHOT'], ) - def test_compatible_opensearch_versions_snapshot(self) -> None: + def test_compatible_core_versions_snapshot(self) -> None: self.assertEqual( - BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=True).compatible_opensearch_versions, + BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=True).compatible_core_versions, ['1.1.2-SNAPSHOT', '1.1.0', '1.1.1', '1.1.0-SNAPSHOT', '1.1.1-SNAPSHOT'], ) - def test_compatible_opensearch_versions_snapshot_qualifier(self) -> None: + def test_compatible_core_versions_snapshot_qualifier(self) -> None: self.assertEqual( - BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=True, qualifier="alpha1").compatible_opensearch_versions, + BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=True, qualifier="alpha1").compatible_core_versions, ['1.1.2-alpha1-SNAPSHOT', '1.1.0', '1.1.1', '1.1.0-alpha1-SNAPSHOT', '1.1.1-alpha1-SNAPSHOT'], ) @@ -94,12 +94,24 @@ def test_compatible_component_versions(self) -> None: ['1.1.2.0', '1.1.0.0', '1.1.1.0', '1.1.0.0-SNAPSHOT', '1.1.1.0-SNAPSHOT'], ) + def test_compatible_opensearch_dashboards_component_versions(self) -> None: + self.assertCountEqual( + BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=False).compatible_opensearch_dashboards_component_versions, + ['1.1.2.0', '1.1.0.0', '1.1.1.0', '1.1.0.0-SNAPSHOT', '1.1.1.0-SNAPSHOT'], + ) + def test_compatible_component_versions_qualifier(self) -> None: self.assertEqual( BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=False, qualifier="alpha1").compatible_component_versions, ['1.1.2.0-alpha1', '1.1.0.0-alpha1', '1.1.1.0-alpha1', '1.1.0.0-alpha1-SNAPSHOT', '1.1.1.0-alpha1-SNAPSHOT'], ) + def test_compatible_opensearch_dashboards_component_versions_qualifier(self) -> None: + self.assertCountEqual( + BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=False, qualifier="alpha1").compatible_opensearch_dashboards_component_versions, + ['1.1.2.0', '1.1.2.0-alpha1', '1.1.0.0-alpha1', '1.1.1.0-alpha1', '1.1.0.0-alpha1-SNAPSHOT', '1.1.1.0-alpha1-SNAPSHOT'], + ) + def test_compatible_component_versions_snapshot(self) -> None: self.assertEqual( BuildTarget(version="1.1.2", architecture="x86", patches=["1.1.0", "1.1.1"], snapshot=True).compatible_component_versions,