From ca9ee0013063c74daa05968bf81fea6442ef3d3e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 1 Oct 2024 22:40:50 +0000 Subject: [PATCH] Add compile step before Cypress runs in CI (#2187) * Add compile step before run step Signed-off-by: Simeon Widdis * Remove wait-for-startup step Signed-off-by: Simeon Widdis * Fix detection of server startup Signed-off-by: Simeon Widdis * Fix cache finding no lock files Signed-off-by: Simeon Widdis * Add caches for different package targets Signed-off-by: Simeon Widdis * Fix caches Signed-off-by: Simeon Widdis * Add yarn cache to regular unit tests Signed-off-by: Simeon Widdis * Remove target cache in ftr Signed-off-by: Simeon Widdis --------- Signed-off-by: Simeon Widdis Signed-off-by: Simeon Widdis (cherry picked from commit fb9027af0e35ed50d8ed574cccc535f112f486aa) Signed-off-by: github-actions[bot] --- ...-observability-test-and-build-workflow.yml | 31 +++++++++++++++++++ .../ftr-e2e-dashboards-observability-test.yml | 27 ++++++++++++---- .../workflows/integration-tests-workflow.yml | 27 ++++++++++++---- 3 files changed, 73 insertions(+), 12 deletions(-) diff --git a/.github/workflows/dashboards-observability-test-and-build-workflow.yml b/.github/workflows/dashboards-observability-test-and-build-workflow.yml index 7d998c011f..8c0c89fabc 100644 --- a/.github/workflows/dashboards-observability-test-and-build-workflow.yml +++ b/.github/workflows/dashboards-observability-test-and-build-workflow.yml @@ -36,6 +36,23 @@ jobs: with: path: OpenSearch-Dashboards/plugins/dashboards-observability + - name: Get yarn cache dir + id: setup-yarn + shell: bash + run: | + cd ./OpenSearch-Dashboards + source $NVM_DIR/nvm.sh + nvm use + echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Yarn Cache + uses: actions/cache@v4 + with: + path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }} + key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-yarn- + - name: Plugin Bootstrap uses: nick-fields/retry@v2 with: @@ -112,6 +129,20 @@ jobs: - run: node -v - run: yarn -v + - name: Get yarn cache dir + id: setup-yarn + shell: bash + run: | + echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT + + - name: Yarn Cache + uses: actions/cache@v4 + with: + path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }} + key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-yarn- + - name: Checkout Dashboards Observability uses: actions/checkout@v2 with: diff --git a/.github/workflows/ftr-e2e-dashboards-observability-test.yml b/.github/workflows/ftr-e2e-dashboards-observability-test.yml index 3c30a95bad..28b2938be7 100644 --- a/.github/workflows/ftr-e2e-dashboards-observability-test.yml +++ b/.github/workflows/ftr-e2e-dashboards-observability-test.yml @@ -122,16 +122,31 @@ jobs: registry-url: "https://registry.npmjs.org" - name: Install correct yarn version for OpenSearch Dashboards + id: setup-yarn run: | npm uninstall -g yarn echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}" npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }} + echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - name: Bootstrap the plugin + - name: Yarn Cache + uses: actions/cache@v4 + with: + path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }} + key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-yarn- + + - name: Bootstrap OpenSearch Dashboards run: | - cd OpenSearch-Dashboards/plugins/dashboards-observability + cd OpenSearch-Dashboards yarn osd bootstrap --single-version=loose + - name: Compile OpenSearch Dashboards + run: | + cd OpenSearch-Dashboards + node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers=10 --verbose + - name: Run OpenSearch Dashboards server run: | cd OpenSearch-Dashboards @@ -141,12 +156,12 @@ jobs: if: ${{ runner.os == 'Linux' }} run: | cd ./OpenSearch-Dashboards - if timeout 600 grep -q "bundles compiled successfully after" <(tail -n0 -f dashboard.log); then - echo "OpenSearch Dashboards compiled successfully." + if timeout 60 grep -q "http server running" <(tail -n +1 -f dashboard.log); then + echo "OpenSearch Dashboards started successfully." else - echo "Timeout for 600 seconds reached. OpenSearch Dashboards did not finish compiling." + echo "Timeout of 60 seconds reached. OpenSearch Dashboards did not start successfully." exit 1 - fi + fi& - name: Checkout Dashboards Functioanl Test Repo uses: actions/checkout@v2 diff --git a/.github/workflows/integration-tests-workflow.yml b/.github/workflows/integration-tests-workflow.yml index d975d81edb..2311690d42 100644 --- a/.github/workflows/integration-tests-workflow.yml +++ b/.github/workflows/integration-tests-workflow.yml @@ -140,16 +140,31 @@ jobs: working-directory: OpenSearch-Dashboards - name: Install correct yarn version for OpenSearch Dashboards + id: setup-yarn run: | npm uninstall -g yarn echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}" npm i -g yarn@${{ steps.versions_step.outputs.yarn_version }} + echo "yarn-cache-dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - - name: Bootstrap the plugin + - name: Yarn Cache + uses: actions/cache@v4 + with: + path: ${{ steps.setup-yarn.outputs.yarn-cache-dir }} + key: ${{ runner.OS }}-yarn-${{ hashFiles('OpenSearch-Dashboards/**/yarn.lock') }} + restore-keys: | + ${{ runner.OS }}-yarn- + + - name: Bootstrap OpenSearch Dashboards run: | - cd OpenSearch-Dashboards/plugins/dashboards-observability + cd OpenSearch-Dashboards yarn osd bootstrap --single-version=loose + - name: Compile OpenSearch Dashboards + run: | + cd OpenSearch-Dashboards + node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers=10 --verbose + - name: Run OpenSearch Dashboards server run: | cd OpenSearch-Dashboards @@ -159,12 +174,12 @@ jobs: if: ${{ runner.os == 'Linux' }} run: | cd ./OpenSearch-Dashboards - if timeout 600 grep -q "bundles compiled successfully after" <(tail -n0 -f dashboard.log); then - echo "OpenSearch Dashboards compiled successfully." + if timeout 60 grep -q "http server running" <(tail -n +1 -f dashboard.log); then + echo "OpenSearch Dashboards started successfully." else - echo "Timeout for 600 seconds reached. OpenSearch Dashboards did not finish compiling." + echo "Timeout of 60 seconds reached. OpenSearch Dashboards did not start successfully." exit 1 - fi + fi& - name: Install Cypress run: |