From e35f7f767b69e88dbedab50b609ef84361572ae8 Mon Sep 17 00:00:00 2001 From: Derek Ho Date: Fri, 12 Jul 2024 16:32:41 -0400 Subject: [PATCH 1/3] Add custom build script to support different cypress version (#2027) Signed-off-by: Derek Ho --- scripts/build.sh | 107 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 scripts/build.sh diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100644 index 000000000..06dab67b8 --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,107 @@ +#!/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 + +# vars / libs +SCRIPT_DIR=`dirname $(realpath $0)` +. $SCRIPT_DIR/../../../lib/shell/file_management.sh +PLUGIN_NAME=$(basename "$PWD") +PLUGIN_PATH=`realpath ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME` + +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, ignored." + echo -e "-a ARCHITECTURE\t[Optional] Build architecture, ignored." + echo -e "-o OUTPUT\t[Optional] Output path, default is 'artifacts'." + echo -e "-h help" +} + + +function cleanup_all() { + File_Delete $PLUGIN_PATH +} + +trap cleanup_all TERM INT EXIT + +while getopts ":h:v:q:s:o:p:a:" 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 + ;; + :) + 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 Dashboards version" + usage + exit 1 +fi + +[ -z "$OUTPUT" ] && OUTPUT=artifacts +[ ! -z "$QUALIFIER" ] && QUALIFIER_IDENTIFIER="-$QUALIFIER" + +NVM_CMD="source $NVM_DIR/nvm.sh && nvm use" +if [ "$PLATFORM" = "windows" ]; then + NVM_CMD="volta install node@`cat ../OpenSearch-Dashboards/.nvmrc` && volta install yarn@`jq -r '.engines.yarn' ../OpenSearch-Dashboards/package.json`" +fi + +HELPER_CMD=$(jq -r '.scripts.plugin_helpers' package.json) +if [ "$HELPER_CMD" != null ]; then + HELPER_STRING=plugin_helpers +else + HELPER_STRING=plugin-helpers +fi + +mkdir -p $OUTPUT/plugins +# TODO: [CLEANUP] Needed OpenSearch Dashboards git repo to build the required modules for plugins +# This makes it so there is a dependency on having Dashboards pulled already. +cp -r ../$PLUGIN_NAME/ ../OpenSearch-Dashboards/plugins +echo "BUILD MODULES FOR $PLUGIN_NAME" +CURR_DIR=`pwd` +# Bootstrap loose to allow different cypress version +cd ../OpenSearch-Dashboards; eval $NVM_CMD; yarn osd bootstrap --single-version=loose +echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" +cd plugins/$PLUGIN_NAME; yarn $HELPER_STRING build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER +cd $CURR_DIR +echo "COPY $PLUGIN_NAME.zip" +cp -r ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ \ No newline at end of file From b0d36ffbef00bccf51c2efaf697ede92657d8534 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 15 Jul 2024 18:12:08 -0400 Subject: [PATCH 2/3] Remove dependency on opensearch build repo libs from custom build.sh (#2033) Signed-off-by: Peter Zhu --- scripts/build.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 06dab67b8..55c8ef657 100644 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -10,8 +10,6 @@ set -ex # vars / libs -SCRIPT_DIR=`dirname $(realpath $0)` -. $SCRIPT_DIR/../../../lib/shell/file_management.sh PLUGIN_NAME=$(basename "$PWD") PLUGIN_PATH=`realpath ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME` @@ -30,7 +28,7 @@ function usage() { function cleanup_all() { - File_Delete $PLUGIN_PATH + rm -rf -- $PLUGIN_PATH } trap cleanup_all TERM INT EXIT @@ -104,4 +102,4 @@ echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" cd plugins/$PLUGIN_NAME; yarn $HELPER_STRING build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER cd $CURR_DIR echo "COPY $PLUGIN_NAME.zip" -cp -r ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ \ No newline at end of file +cp -r ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME/build/$PLUGIN_NAME-$VERSION$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ From 757f4cec8cb8d903ab0ef1f0a150a3220f24c9ef Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Tue, 16 Jul 2024 12:10:11 -0400 Subject: [PATCH 3/3] Increment version to 3.0.0.0 (#2035) Signed-off-by: opensearch-ci-bot Co-authored-by: opensearch-ci-bot --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 438121b4f..5aad7a155 100644 --- a/package.json +++ b/package.json @@ -53,4 +53,4 @@ "ejs": "^3.1.10", "express": "^4.19.2" } -} +} \ No newline at end of file