From 4022047c8c65dd41ea332cd84fe9248a682c9714 Mon Sep 17 00:00:00 2001
From: Manasvini B Suryanarayana <manasvis@amazon.com>
Date: Fri, 23 Feb 2024 21:43:43 +0000
Subject: [PATCH] Add cigroup matrix for parallel runs

Signed-off-by: Manasvini B Suryanarayana <manasvis@amazon.com>
---
 .../workflows/dashboards_cypress_workflow.yml  | 18 +++++++++++-------
 package.json                                   |  6 ++----
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/.github/workflows/dashboards_cypress_workflow.yml b/.github/workflows/dashboards_cypress_workflow.yml
index 7f0a6bb9c3d7..4d474689a70e 100644
--- a/.github/workflows/dashboards_cypress_workflow.yml
+++ b/.github/workflows/dashboards_cypress_workflow.yml
@@ -2,6 +2,8 @@ name: Orchestrator cypress workflow
 run-name: dashboards_cypress_workflow ${{ inputs.UNIQUE_ID != '' && inputs.UNIQUE_ID || '' }} # Unique id number appended to the workflow run-name to reference the run within the orchestrator.
 # Trigger on dispatch event sent from FT repo orchestrator
 on:
+  push:
+    branches: [ '**' ]
   workflow_dispatch:
     inputs:
       test_repo:
@@ -43,20 +45,19 @@ env:
   OSD_PATH: 'osd'
   CYPRESS_BROWSER: 'chromium'
   JOB_ID: ${{ inputs.UNIQUE_ID}}
-  OPENSEARCH:  ${{ inputs.OS_URL != '' && inputs.OS_URL  || 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/$VERSION/latest/linux/x64/tar/dist/opensearch/opensearch-$VERSION-linux-x64.tar.gz' }}
-  DASHBOARDS: ${{ inputs.OSD_URL != '' && inputs.OSD_URL  || 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/$VERSION/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-$VERSION-linux-x64.tar.gz' }}
+  OPENSEARCH:  ${{ inputs.OS_URL != '' && inputs.OS_URL  || 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch/2.12.0/latest/linux/x64/tar/dist/opensearch/opensearch-2.12.0-linux-x64.tar.gz' }}
+  DASHBOARDS: ${{ inputs.OSD_URL != '' && inputs.OSD_URL  || 'https://ci.opensearch.org/ci/dbc/distribution-build-opensearch-dashboards/2.12.0/latest/linux/x64/tar/dist/opensearch-dashboards/opensearch-dashboards-2.12.0-linux-x64.tar.gz' }}
   OPENSEARCH_DIR: 'cypress/opensearch'
   DASHBOARDS_DIR: 'cypress/opensearch-dashboards'
   SECURITY_ENABLED: ${{ inputs.SECURITY_ENABLED != '' && inputs.SECURITY_ENABLED || 'false' }}
-  SPEC: 'cypress/integration/core_opensearch_dashboards/*'
 
 jobs:
   cypress-tests:
     runs-on: ubuntu-latest
     strategy:
+      fail-fast: false
       matrix:
-        spec_group:
-          [1, 2, 3, 4] # Add more spec files as needed
+        spec_group: [1, 2] # Add more spec files as needed
     container:
       image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2
       options: --user 1001
@@ -94,10 +95,13 @@ jobs:
           IFS="," read -a SPEC_ARRAY <<< $(yarn --silent osd:ciGroup${{ matrix.spec_group }})
           FORMATTED_SPEC=''
           for i in "${SPEC_ARRAY[@]}"; do
+            echo "i is : ${i}"
             FORMATTED_SPEC+="cypress/integration/core-opensearch-dashboards/${i},"
           done
-          echo "SPEC=${FORMATTED_SPEC}" >> $GITHUB_ENV
-          echo "SPec found: $SPEC"
+          SPEC=${FORMATTED_SPEC}  # Set SPEC to FORMATTED_SPEC
+          echo "FORMATTED_SPEC: ${FORMATTED_SPEC}"
+          echo "SPEC=${SPEC}" >> $GITHUB_ENV
+          echo "SPecccc found: $SPEC"
 
       - name: Get Cypress version
         id: cypress_version
diff --git a/package.json b/package.json
index 2e0fc44391e2..1a28d362ed55 100644
--- a/package.json
+++ b/package.json
@@ -80,10 +80,8 @@
     "pkg-version": "scripts/use_node -e \"console.log(require('./package.json').version)\"",
     "cypress:run-without-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=false",
     "cypress:run-with-security": "env TZ=America/Los_Angeles NO_COLOR=1 cypress run --headless --env SECURITY_ENABLED=true,openSearchUrl=https://localhost:9200,WAIT_FOR_LOADER_BUFFER_MS=500",
-    "osd:ciGroup1": "echo \"\"",
-    "osd:ciGroup2": "echo \"\"",
-    "osd:ciGroup3": "echo \"\"",
-    "osd:ciGroup4": "echo \"dashboard_sanity_test_spec.js\""
+    "osd:ciGroup1": "echo \"dashboard_sanity_test_spec.js\"",
+    "osd:ciGroup2": "echo \"dashboard_sanity_test_spec.js\""
   },
   "repository": {
     "type": "git",