atharvalade commented on code in PR #2920:
URL: https://github.com/apache/iggy/pull/2920#discussion_r2926642341


##########
scripts/run-examples-from-readme.sh:
##########
@@ -0,0 +1,545 @@
+#!/bin/bash
+
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -euo pipefail
+
+# Unified script to run SDK examples from README.md files.
+# Usage: ./scripts/run-examples-from-readme.sh [OPTIONS]
+#
+#   --language LANG   Language to test: rust|go|node|python|java|csharp 
(default: all)
+#   --target TARGET   Cargo target architecture for the server binary
+#   --skip-tls        Skip TLS example tests
+#   --goos GOOS       Go OS target
+#   --goarch GOARCH   Go architecture target
+#   --csharpos OS     C# --os flag
+#   --csharparch ARCH C# --arch flag
+#
+# The script sources shared utilities from scripts/utils.sh, starts the iggy
+# server (built from source), parses example commands from each language's
+# README.md, and executes them. Non-TLS examples run first; then the server
+# is restarted with TLS for TLS-specific examples.
+
+SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+# shellcheck source=scripts/utils.sh
+source "${SCRIPT_DIR}/utils.sh"
+
+ROOT_WORKDIR="$(pwd)"
+
+# ---------------------------------------------------------------------------
+# Argument parsing
+# ---------------------------------------------------------------------------
+LANGUAGE="all"
+TARGET=""
+SKIP_TLS=false
+GOOS=""
+GOARCH=""
+CSOS=""
+CSARCH=""
+
+while [[ $# -gt 0 ]]; do
+    case "$1" in
+        --language)   LANGUAGE="$2";  shift 2 ;;
+        --target)     TARGET="$2";    shift 2 ;;
+        --skip-tls)   SKIP_TLS=true;  shift   ;;
+        --goos)       GOOS="$2";      shift 2 ;;
+        --goarch)     GOARCH="$2";    shift 2 ;;
+        --csharpos)   CSOS="$2";      shift 2 ;;
+        --csharparch) CSARCH="$2";    shift 2 ;;
+        *)
+            echo "Unknown option: $1"
+            echo "Usage: $0 [--language LANG] [--target TARGET] [--skip-tls] 
[--goos GOOS] [--goarch GOARCH] [--csharpos OS] [--csharparch ARCH]"
+            exit 1
+            ;;
+    esac
+done
+
+# ---------------------------------------------------------------------------
+# Helpers
+# ---------------------------------------------------------------------------
+
+# Run a full non-TLS + TLS cycle for one language.
+# Arguments:
+#   $1 - language label (for logging)
+#   $2 - working directory (relative to repo root, or "." for root)
+#   $3 - space-separated list of README files (relative to workdir)
+#   $4 - grep pattern for non-TLS commands
+#   $5 - grep exclude pattern for non-TLS commands (empty = no exclude)
+#   $6 - grep pattern for TLS commands (empty = no TLS examples)
+#   $7 - per-command timeout in seconds (0 = no timeout)
+#   $8 - extra server args (e.g. "--fresh")
+# shellcheck disable=SC2329
+run_language_examples() {
+    local lang="$1"
+    local workdir="$2"
+    local readme_files="$3"
+    local grep_pattern="$4"
+    local grep_exclude="$5"
+    local tls_grep_pattern="$6"
+    local cmd_timeout="$7"
+    local server_extra_args="$8"
+
+    echo ""
+    echo "============================================================"
+    echo "  Running ${lang} examples"
+    echo "============================================================"
+    echo ""
+
+    EXAMPLES_EXIT_CODE=0

Review Comment:
   `run_one` now resets `EXAMPLES_EXIT_CODE` to 0 before each language call



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to