From 1bf1ed92a6cee94662de5ea378c1f46eb17b5b48 Mon Sep 17 00:00:00 2001 From: Tengda He Date: Wed, 27 Oct 2021 00:01:45 +0000 Subject: [PATCH] Copy the OpenSearch-Dashboards git package to ~/.cache folder when building the OpenSearch-Dashboards component. Also create the load_dashboard_from_cache function for plugin build to reuse OpenSearch-Dashboards source code. This way allows individual plugin to build independently, https://github.com/opensearch-project/opensearch-build/issues/606 Signed-off-by: Tengda He --- ONBOARDING.md | 2 +- scripts/components/OpenSearch-Dashboards/build.sh | 5 +++++ scripts/components/ganttChartDashboards/build.sh | 15 +++++++++++++++ scripts/components/notebooksDashboards/build.sh | 15 +++++++++++++++ .../components/notificationsDashboards/build.sh | 15 +++++++++++++++ .../components/queryWorkbenchDashboards/build.sh | 15 +++++++++++++++ scripts/components/reportsDashboards/build.sh | 14 ++++++++++++++ scripts/default/opensearch-dashboards/build.sh | 15 +++++++++++++++ 8 files changed, 95 insertions(+), 1 deletion(-) diff --git a/ONBOARDING.md b/ONBOARDING.md index 2bb5555e98..cb8a3958fb 100644 --- a/ONBOARDING.md +++ b/ONBOARDING.md @@ -8,7 +8,7 @@ This document describes steps to onboard a new plugin to release workflow for co 2. Create a `scripts/build.sh` if you have specific requirements that are not covered by the [default build.sh script](/scripts/default/build.sh) and commit it to your repository. -3. Ensure your `build.sh` reads and passes along both `-Dbuild.snapshot=` and `-Dopensearch.version=` flags. Snapshot builds should produce a -SNAPSHOT tagged artifact for example `opensearch-plugin-1.1.0.0-SNAPSHOT.zip` where a release build of the same component would produce `opensearch-plugin-1.1.0.0.zip`. +3. Ensure your `build.sh` reads and passes along both `-Dbuild.snapshot=` and `-Dopensearch.version=` flags. Snapshot builds should produce a -SNAPSHOT tagged artifact for example `opensearch-plugin-1.1.0.0-SNAPSHOT.zip` where a release build of the same component would produce `opensearch-plugin-1.1.0.0.zip`. If building a opensearch-dashboards plugin be sure to have the opensearch-dashboards core already in cache. 4. Execute `./build.sh` to ensure your component builds and all artifacts are correctly placed into ./artifacts/ with correct output names. diff --git a/scripts/components/OpenSearch-Dashboards/build.sh b/scripts/components/OpenSearch-Dashboards/build.sh index 0a98e5cb49..fd2c66c8ec 100755 --- a/scripts/components/OpenSearch-Dashboards/build.sh +++ b/scripts/components/OpenSearch-Dashboards/build.sh @@ -77,6 +77,11 @@ case $ARCHITECTURE in ;; esac +echo "Copying dashboard to .cache for reuse" +rm -rf ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ +mkdir -p ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ +cp -r . ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ + echo "Building node modules for core" yarn osd bootstrap diff --git a/scripts/components/ganttChartDashboards/build.sh b/scripts/components/ganttChartDashboards/build.sh index 0782be8e87..ded10d0908 100755 --- a/scripts/components/ganttChartDashboards/build.sh +++ b/scripts/components/ganttChartDashboards/build.sh @@ -20,6 +20,20 @@ function usage() { echo -e "-h help" } +function load_opensearch_dashboards_from_cache() { + if [ ! -d ../OpenSearch-Dashboards ]; then + echo "No OpenSearch-Dashboards folder found, trying to load from cache" + if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then + echo "Copy OpenSearch-Dashboards from cache" + cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../ + else + echo "No correct version OpenSearch-Dashboards found from cache, + please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards" + exit 1 + fi + fi +} + while getopts ":h:v:s:o:p:a:" arg; do case $arg in h) @@ -67,6 +81,7 @@ PLUGIN_FOLDER=$(basename "$PWD") PLUGIN_NAME=$(basename $(dirname "$PWD")) # 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. +load_opensearch_dashboards_from_cache cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) diff --git a/scripts/components/notebooksDashboards/build.sh b/scripts/components/notebooksDashboards/build.sh index 19e51827f2..2fd9b0bd8a 100755 --- a/scripts/components/notebooksDashboards/build.sh +++ b/scripts/components/notebooksDashboards/build.sh @@ -20,6 +20,20 @@ function usage() { echo -e "-h help" } +function load_opensearch_dashboards_from_cache() { + if [ ! -d ../OpenSearch-Dashboards ]; then + echo "No OpenSearch-Dashboards folder found, trying to load from cache" + if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then + echo "Copy OpenSearch-Dashboards from cache" + cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../ + else + echo "No correct version OpenSearch-Dashboards found from cache, + please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards" + exit 1 + fi + fi +} + while getopts ":h:v:s:o:p:a:" arg; do case $arg in h) @@ -67,6 +81,7 @@ PLUGIN_FOLDER=$(basename "$PWD") PLUGIN_NAME=$(basename $(dirname "$PWD")) # 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. +load_opensearch_dashboards_from_cache cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) diff --git a/scripts/components/notificationsDashboards/build.sh b/scripts/components/notificationsDashboards/build.sh index 93c3c5ed62..afc7135a41 100755 --- a/scripts/components/notificationsDashboards/build.sh +++ b/scripts/components/notificationsDashboards/build.sh @@ -20,6 +20,20 @@ function usage() { echo -e "-h help" } +function load_opensearch_dashboards_from_cache() { + if [ ! -d ../OpenSearch-Dashboards ]; then + echo "No OpenSearch-Dashboards folder found, trying to load from cache" + if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then + echo "Copy OpenSearch-Dashboards from cache" + cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../ + else + echo "No correct version OpenSearch-Dashboards found from cache, + please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards" + exit 1 + fi + fi +} + while getopts ":h:v:s:o:p:a:" arg; do case $arg in h) @@ -67,6 +81,7 @@ PLUGIN_FOLDER=$(basename "$PWD") PLUGIN_NAME=$(basename $(dirname "$PWD")) # 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. +load_opensearch_dashboards_from_cache cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) diff --git a/scripts/components/queryWorkbenchDashboards/build.sh b/scripts/components/queryWorkbenchDashboards/build.sh index 73ca784456..63ba9925db 100755 --- a/scripts/components/queryWorkbenchDashboards/build.sh +++ b/scripts/components/queryWorkbenchDashboards/build.sh @@ -20,6 +20,20 @@ function usage() { echo -e "-h help" } +function load_opensearch_dashboards_from_cache() { + if [ ! -d ../OpenSearch-Dashboards ]; then + echo "No OpenSearch-Dashboards folder found, try to load from cache" + if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then + echo "Copy OpenSearch-Dashboards from cache" + cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../ + else + echo "No correct version OpenSearch-Dashboards found from cache, + please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards" + exit 1 + fi + fi +} + while getopts ":h:v:s:o:p:a:" arg; do case $arg in h) @@ -67,6 +81,7 @@ PLUGIN_FOLDER=$(basename "$PWD") PLUGIN_NAME=$(basename $(dirname "$PWD")) # 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. +load_opensearch_dashboards_from_cache cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) diff --git a/scripts/components/reportsDashboards/build.sh b/scripts/components/reportsDashboards/build.sh index 51d06a1b71..d169e91233 100755 --- a/scripts/components/reportsDashboards/build.sh +++ b/scripts/components/reportsDashboards/build.sh @@ -20,6 +20,19 @@ function usage() { echo -e "-h help" } +function load_opensearch_dashboards_from_cache() { + if [ ! -d ../OpenSearch-Dashboards ]; then + echo "No OpenSearch-Dashboards folder found, try to load from cache" + if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then + echo "Copy OpenSearch-Dashboards from cache" + cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../../ + else + echo "No correct version OpenSearch-Dashboards found from cache, please build OpenSearch-Dashboards first" + exit 1 + fi + fi +} + while getopts ":h:v:s:o:p:a:" arg; do case $arg in h) @@ -67,6 +80,7 @@ PLUGIN_FOLDER=$(basename "$PWD") PLUGIN_NAME=$(basename $(dirname "$PWD")) # 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. +load_opensearch_dashboards_from_cache cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../../OpenSearch-Dashboards && yarn osd bootstrap) diff --git a/scripts/default/opensearch-dashboards/build.sh b/scripts/default/opensearch-dashboards/build.sh index 18bf7187d9..4bae06fa18 100755 --- a/scripts/default/opensearch-dashboards/build.sh +++ b/scripts/default/opensearch-dashboards/build.sh @@ -20,6 +20,20 @@ function usage() { echo -e "-h help" } +function load_opensearch_dashboards_from_cache() { + if [ ! -d ../OpenSearch-Dashboards ]; then + echo "No OpenSearch-Dashboards folder found, try to load from cache" + if [ -d ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ]; then + echo "Copy OpenSearch-Dashboards from cache" + cp -r ~/.cache/opensearch-project/$VERSION/OpenSearch-Dashboards/ ../ + else + echo "No correct version OpenSearch-Dashboards found from cache, + please run: ./build.sh manifests/1.1.0/opensearch-dashboards-1.1.0.yml --component=OpenSearch-Dashboards" + exit 1 + fi + fi +} + while getopts ":h:v:s:o:p:a:" arg; do case $arg in h) @@ -65,6 +79,7 @@ mkdir -p $OUTPUT/plugins PLUGIN_NAME=$(basename "$PWD") # 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. +load_opensearch_dashboards_from_cache cp -r ../$PLUGIN_NAME/ ../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" (cd ../OpenSearch-Dashboards && yarn osd bootstrap)