From 1116d3b3698accaec39cd498975dec0035e1963c Mon Sep 17 00:00:00 2001 From: Kawika Avilla Date: Thu, 7 Apr 2022 18:35:14 -0700 Subject: [PATCH] [OSD][Build] nvm use (#1905) * [OSD][Build] nvm use Within OSD we have a .nvmrc file that is used when `nvm use` is executing. So we can use the right node version for the build. Issue: n/a Signed-off-by: Kawika Avilla * source it Signed-off-by: Kawika Avilla * update dev doc Signed-off-by: Kawika Avilla * source in shell Signed-off-by: Kawika Avilla * plugin builder Signed-off-by: Kawika Avilla --- DEVELOPER_GUIDE.md | 6 ++++++ manifests/1.3.1/opensearch-dashboards-1.3.1.yml | 1 - manifests/2.0.0/opensearch-dashboards-2.0.0.yml | 1 - scripts/components/OpenSearch-Dashboards/build.sh | 4 ++++ scripts/components/ganttChartDashboards/build.sh | 4 ++-- scripts/components/notebooksDashboards/build.sh | 4 ++-- scripts/components/notificationsDashboards/build.sh | 4 ++-- scripts/components/observabilityDashboards/build.sh | 4 ++-- scripts/components/queryWorkbenchDashboards/build.sh | 4 ++-- scripts/components/reportsDashboards/build.sh | 4 ++-- scripts/default/opensearch-dashboards/build.sh | 4 ++-- 11 files changed, 24 insertions(+), 16 deletions(-) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index db6d930a40..0185e1320c 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -79,6 +79,12 @@ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash nvm install v14.18.2 ``` +Add the lines below to the correct profile file (`~/.zshrc`, `~/.bashrc`, etc.). +``` +export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" +``` + #### Yarn [Yarn](https://classic.yarnpkg.com/en/docs/install) is required for building and running the OpenSearch Dashboards and plugins diff --git a/manifests/1.3.1/opensearch-dashboards-1.3.1.yml b/manifests/1.3.1/opensearch-dashboards-1.3.1.yml index 7cf4590989..b44c2eb2cf 100644 --- a/manifests/1.3.1/opensearch-dashboards-1.3.1.yml +++ b/manifests/1.3.1/opensearch-dashboards-1.3.1.yml @@ -6,7 +6,6 @@ build: ci: image: name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v1 - args: -e NODE_VERSION=10.24.1 components: - name: OpenSearch-Dashboards repository: https://github.com/opensearch-project/OpenSearch-Dashboards.git 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 c78bd70046..9888104230 100644 --- a/manifests/2.0.0/opensearch-dashboards-2.0.0.yml +++ b/manifests/2.0.0/opensearch-dashboards-2.0.0.yml @@ -7,7 +7,6 @@ build: ci: image: name: opensearchstaging/ci-runner:ci-runner-centos7-opensearch-dashboards-build-v1 - args: -e NODE_VERSION=14.18.2 components: - name: OpenSearch-Dashboards ref: main diff --git a/scripts/components/OpenSearch-Dashboards/build.sh b/scripts/components/OpenSearch-Dashboards/build.sh index 6f91aff7e4..cda727c8b1 100755 --- a/scripts/components/OpenSearch-Dashboards/build.sh +++ b/scripts/components/OpenSearch-Dashboards/build.sh @@ -109,6 +109,10 @@ case $PLATFORM-$DISTRIBUTION-$ARCHITECTURE in ;; esac +echo "Setting node version" +source $NVM_DIR/nvm.sh +nvm use + echo "Building node modules for core with $PLATFORM-$DISTRIBUTION-$ARCHITECTURE" yarn osd bootstrap diff --git a/scripts/components/ganttChartDashboards/build.sh b/scripts/components/ganttChartDashboards/build.sh index 80e49f4734..fbe491e8da 100755 --- a/scripts/components/ganttChartDashboards/build.sh +++ b/scripts/components/ganttChartDashboards/build.sh @@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD")) # This makes it so there is a dependency on having Dashboards pulled already. cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards && yarn osd bootstrap) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd 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$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 771c6837cc..596edc4167 100755 --- a/scripts/components/notebooksDashboards/build.sh +++ b/scripts/components/notebooksDashboards/build.sh @@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD")) # This makes it so there is a dependency on having Dashboards pulled already. cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards && yarn osd bootstrap) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd 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$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 c6c9fff43e..fe2046e603 100755 --- a/scripts/components/notificationsDashboards/build.sh +++ b/scripts/components/notificationsDashboards/build.sh @@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD")) # This makes it so there is a dependency on having Dashboards pulled already. cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards && yarn osd bootstrap) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd 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$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 9c2e0a7d42..bee298b5ff 100755 --- a/scripts/components/observabilityDashboards/build.sh +++ b/scripts/components/observabilityDashboards/build.sh @@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD")) # This makes it so there is a dependency on having Dashboards pulled already. cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards && yarn osd bootstrap) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd 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$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 437c118d58..8da4fd92c5 100755 --- a/scripts/components/queryWorkbenchDashboards/build.sh +++ b/scripts/components/queryWorkbenchDashboards/build.sh @@ -74,9 +74,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD")) # This makes it so there is a dependency on having Dashboards pulled already. cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards && yarn osd bootstrap) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd 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$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 da9058ef76..ea5dc3c5e7 100755 --- a/scripts/components/reportsDashboards/build.sh +++ b/scripts/components/reportsDashboards/build.sh @@ -102,9 +102,9 @@ PLUGIN_NAME=$(basename $(dirname "$PWD")) # This makes it so there is a dependency on having Dashboards pulled already. cp -r ../$PLUGIN_FOLDER/ ../../OpenSearch-Dashboards/plugins echo "BUILD MODULES FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards && yarn osd bootstrap) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../../OpenSearch-Dashboards/plugins/$PLUGIN_FOLDER && yarn plugin_helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd 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 diff --git a/scripts/default/opensearch-dashboards/build.sh b/scripts/default/opensearch-dashboards/build.sh index 7ebd472f09..035119f663 100755 --- a/scripts/default/opensearch-dashboards/build.sh +++ b/scripts/default/opensearch-dashboards/build.sh @@ -72,9 +72,9 @@ PLUGIN_NAME=$(basename "$PWD") # 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" -(cd ../OpenSearch-Dashboards && yarn osd bootstrap) +(cd ../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && yarn osd bootstrap) echo "BUILD RELEASE ZIP FOR $PLUGIN_NAME" -(cd ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME && yarn plugin-helpers build --opensearch-dashboards-version=$VERSION$QUALIFIER_IDENTIFIER) +(cd ../../OpenSearch-Dashboards && source $NVM_DIR/nvm.sh && nvm use && cd 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$QUALIFIER_IDENTIFIER.zip $OUTPUT/plugins/ rm -rf ../OpenSearch-Dashboards/plugins/$PLUGIN_NAME \ No newline at end of file