From 66419d1d27dd9d39efdeb6e209d545a49709581f Mon Sep 17 00:00:00 2001 From: "opensearch-trigger-bot[bot]" <98922864+opensearch-trigger-bot[bot]@users.noreply.github.com> Date: Wed, 20 Mar 2024 03:09:37 +0530 Subject: [PATCH] Add workflow to build and install security analytics dashboards plugin (#899) (#958) * Initial commit to try using workflow from other fork * setup with backend or job scheduler * Use generalized workflows * Extra dash * Correct directory * Revert "Add missing modules common and types (#875)" This reverts commit ba9c4f66264eadb25e2f25b595e861454ad6b241. * Revert "Revert "Add missing modules common and types (#875)"" This reverts commit 17cff1440a188e9675241c30f7e4a429391ae5ae. * Single version loose to fix bootstrapping issues * Add v1 tag * Remove security specific settings * Remove references to security * Add loose for windows --------- (cherry picked from commit 6bb078b9671280416d6f6244ce38b581cbc11618) Signed-off-by: Derek Ho Signed-off-by: github-actions[bot] Co-authored-by: github-actions[bot] --- .github/workflows/cypress-workflow.yml | 2 +- .github/workflows/unit-tests-workflow.yml | 4 +- .../workflows/verify-binary-installation.yml | 55 +++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/verify-binary-installation.yml diff --git a/.github/workflows/cypress-workflow.yml b/.github/workflows/cypress-workflow.yml index 391e4a224..a81220a55 100644 --- a/.github/workflows/cypress-workflow.yml +++ b/.github/workflows/cypress-workflow.yml @@ -82,7 +82,7 @@ jobs: - name: Bootstrap plugin/OpenSearch-Dashboards run: | cd OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin - yarn osd bootstrap + yarn osd bootstrap --single-version=loose - name: Run OpenSearch-Dashboards server run: | diff --git a/.github/workflows/unit-tests-workflow.yml b/.github/workflows/unit-tests-workflow.yml index 3b3c10cb9..ce58c0f3a 100644 --- a/.github/workflows/unit-tests-workflow.yml +++ b/.github/workflows/unit-tests-workflow.yml @@ -45,7 +45,7 @@ jobs: cd ./OpenSearch-Dashboards/ su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v && cd ./plugins/security-analytics-dashboards-plugin && - whoami && yarn osd bootstrap && yarn run test:jest --coverage" + whoami && yarn osd bootstrap --single-version=loose && yarn run test:jest --coverage" - name: Uploads coverage if: ${{ matrix.os == 'ubuntu-latest' }} @@ -89,7 +89,7 @@ jobs: - name: Bootstrap plugin/OpenSearch-Dashboards run: | cd OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin - yarn osd bootstrap + yarn osd bootstrap --single-version=loose - name: Run tests run: | cd OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin diff --git a/.github/workflows/verify-binary-installation.yml b/.github/workflows/verify-binary-installation.yml new file mode 100644 index 000000000..d237d4a6c --- /dev/null +++ b/.github/workflows/verify-binary-installation.yml @@ -0,0 +1,55 @@ +name: 'Install Dashboards with Plugin via Binary' + +on: [push, pull_request] +env: + OPENSEARCH_VERSION: '3.0.0' + CI: 1 + # avoid warnings like "tput: No value for $TERM and no -T specified" + TERM: xterm + +jobs: + verify-binary-installation: + name: Run binary installation + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest] + # TODO: add windows support when OSD core is stable on windows + runs-on: ${{ matrix.os }} + steps: + - name: Checkout Branch + uses: actions/checkout@v3 + + - name: Set env + run: | + opensearch_version=$(node -p "require('./opensearch_dashboards.json').opensearchDashboardsVersion") + plugin_version=$(node -p "require('./opensearch_dashboards.json').version") + echo "OPENSEARCH_VERSION=$opensearch_version" >> $GITHUB_ENV + echo "PLUGIN_VERSION=$plugin_version" >> $GITHUB_ENV + shell: bash + + - name: Run Opensearch + uses: derek-ho/start-opensearch@v2 + with: + opensearch-version: ${{ env.OPENSEARCH_VERSION }} + security-enabled: false + + - name: Run Dashboard + id: setup-dashboards + uses: derek-ho/setup-opensearch-dashboards@v1 + with: + plugin_name: security-analytics-dashboards-plugin + built_plugin_name: security-analytics-dashboards + install_zip: true + + - name: Start the binary + run: | + nohup ./bin/opensearch-dashboards & + working-directory: ${{ steps.setup-dashboards.outputs.dashboards-binary-directory }} + shell: bash + + - name: Health check + run: | + timeout 300 bash -c 'while [[ "$(curl http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done' + shell: bash +