2222 - name : Checkout Branch
2323 uses : actions/checkout@v5
2424
25+ - name : Set up JDK 21 for build
26+ uses : actions/setup-java@v4
27+ with :
28+ distribution : temurin
29+ java-version : ' 21'
30+
2531 - name : Set env
2632 run : |
2733 opensearch_version=$(node -p "require('./package.json').opensearchDashboards.version")
@@ -40,44 +46,40 @@ jobs:
4046
4147 # build sample-resource-plugin from source (Linux runner)
4248 - name : Build sample-resource-plugin (server)
43- if : ${{ runner.os == 'Linux' }}
4449 shell : bash
4550 run : |
4651 set -euo pipefail
4752
48- # Derive Security repo tag from your OpenSearch version: 3.2.0 -> 3.2.0.0
49- SEC_TAG="${OPENSEARCH_VERSION}.0"
50- echo "SEC_TAG=$SEC_TAG"
53+ # Shallow clone at main
54+ git clone --depth 1 https://github.com/opensearch-project/security.git security-src
5155
52- # Shallow clone at tag; fall back to main if that tag doesn't exist
53- git clone --depth 1 --branch "$SEC_TAG" https://github.com/opensearch-project/security.git security-src \
54- || git clone --depth 1 https://github.com/opensearch-project/security.git security-src
56+ pushd security-src
57+ # Build the sample plugin from the repo root
58+ chmod +x ./gradlew
59+ ./gradlew :opensearch-sample-resource-plugin:assemble
5560
56- pushd security-src/sample-resource-plugin
57- # Build the plugin ZIP
58- ./gradlew assemble
59- # Grab the ZIP (there should be exactly one)
60- ZIP_PATH=$(ls build/distributions/*.zip | head -n1)
61+ # Pick the built zip
62+ ZIP_PATH=$(ls -t sample-resource-plugin/build/distributions/*.zip | head -n1)
6163 echo "Built sample plugin: $ZIP_PATH"
64+
65+ # Copy to workspace for installation
6266 cp "$ZIP_PATH" "$GITHUB_WORKSPACE/sample-resource-plugin.zip"
6367 popd
6468
69+
6570 echo "SAMPLE_PLUGIN_ZIP=$GITHUB_WORKSPACE/sample-resource-plugin.zip" >> $GITHUB_ENV
6671
67- # Replace your "Run OpenSearch with security and resource plugins" step's plugins list
6872 - name : Run Opensearch with security + sample resource plugin
6973 uses : derek-ho/start-opensearch@v8
7074 with :
7175 opensearch-version : ${{ env.OPENSEARCH_VERSION }}
72- # Keep security.zip from your existing download step, add the newly built sample plugin:
7376 plugins : " file:$(pwd)/opensearch-security.zip,file:${{ env.SAMPLE_PLUGIN_ZIP }}"
7477 security-enabled : true
7578 admin-password : ${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }}
7679 jdk-version : 21
7780 resource-sharing-enabled : true
7881
7982 - name : Check OpenSearch is running
80- # Verify that the server is operational
8183 run : |
8284 curl https://localhost:9200/_cat/plugins -v -u admin:${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }} -k
8385 shell : bash
@@ -87,43 +89,47 @@ jobs:
8789 uses : derek-ho/setup-opensearch-dashboards@v1
8890 with :
8991 plugin_name : security-dashboards-plugin
90- opensearch_dashboards_yml : ${{ inputs.dashboards_config_file }}
9192
9293 - name : Compile OpenSearch Dashboards
9394 run : |
94- cd OpenSearch-Dashboards
9595 node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers=10 --verbose
9696 shell : bash
97+ working-directory : OpenSearch-Dashboards
9798
98- - name : Run OpenSearch Dashboards with provided configuration
99- if : ${{ runner.os == 'Linux' }}
99+ - name : Run OpenSearch Dashboards
100100 run : |
101- cd ./OpenSearch-Dashboards
102- if [ -z "${{ inputs.osd_base_path }}" ]; then
103- nohup yarn start --no-base-path --no-watch --csp.warnLegacyBrowsers=false | tee dashboard.log &
104- else
105- nohup yarn start --no-watch --csp.warnLegacyBrowsers=false | tee dashboard.log &
106- fi
101+ nohup yarn start --no-base-path --no-watch --csp.warnLegacyBrowsers=false | tee dashboard.log &
107102 shell : bash
103+ working-directory : OpenSearch-Dashboards
108104
109- # Check if OSD is ready with a max timeout of 600 seconds
110- - name : Check If OpenSearch Dashboards Is Ready
111- if : ${{ runner.os == 'Linux' }}
105+ # Check if OSD is ready with a max timeout of 300 seconds
106+ - name : Wait for OpenSearch Dashboards (status API)
107+ shell : bash
108+ working-directory : OpenSearch-Dashboards
109+ env :
110+ OSD_URL : http://localhost:5601
111+ OSD_USER : admin
112+ OSD_PASS : ${{ env.OPENSEARCH_INITIAL_ADMIN_PASSWORD }}
112113 run : |
113- cd ./OpenSearch-Dashboards
114- echo "Start checking OpenSearch Dashboards."
115- for i in {1..6}; do
116- if grep -q "http server running" "dashboard.log"; then
117- echo "OpenSearch Dashboards started successfully."
118- break
119- fi
120- if [ $i -eq 6 ]; then
121- echo "Timeout for 60 seconds reached. OpenSearch Dashboards did not start."
122- exit 1
114+ set -euo pipefail
115+ TIMEOUT=300; INTERVAL=5; end=$((SECONDS + TIMEOUT))
116+ code=""; resp=""
117+
118+ while (( SECONDS < end )); do
119+ resp="$(curl -s -k -u "${OSD_USER}:${OSD_PASS}" -H 'kbn-xsrf: true' "${OSD_URL}/api/status" || echo "")"
120+ code="$(curl -s -k -o /dev/null -w '%{http_code}' -u "${OSD_USER}:${OSD_PASS}" -H 'kbn-xsrf: true' "${OSD_URL}/api/status" || echo "")"
121+
122+ if [ "${code:-}" = "200" ] && echo "${resp:-}" | grep -Eiq '"(overall|status)".*"(available|green)"'; then
123+ echo "OpenSearch Dashboards status is green."
124+ exit 0
123125 fi
124- sleep 10
126+ sleep "${INTERVAL}"
125127 done
126- shell : bash
128+
129+ echo "Timed out after ${TIMEOUT}s waiting for OpenSearch Dashboards status."
130+ tail -n 200 dashboard.log || true
131+ exit 1
132+
127133
128134 - name : Run Cypress Tests with retry
129135 uses : Wandalen/wretry.action@v3.3.0
0 commit comments