This is an automated email from the ASF dual-hosted git repository.

hubcio pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iggy.git


The following commit(s) were added to refs/heads/master by this push:
     new ddead57af fix(ci): make README CLI preflight execute its commands 
(#3792)
ddead57af is described below

commit ddead57afff1b7a26b486302e80c592bff61d2a4
Author: Ethan Lin <[email protected]>
AuthorDate: Mon Aug 3 11:59:42 2026 -0700

    fix(ci): make README CLI preflight execute its commands (#3792)
---
 examples/java/README.md                    |  2 +-
 examples/node/README.md                    |  2 +-
 examples/rust/README.md                    |  2 +-
 examples/rust/src/tcp-tls/consumer/main.rs |  2 +-
 examples/rust/src/tcp-tls/producer/main.rs |  2 +-
 scripts/run-examples-from-readme.sh        | 31 +++++++++++++++++++-----------
 scripts/utils.sh                           |  8 +++++++-
 7 files changed, 32 insertions(+), 17 deletions(-)

diff --git a/examples/java/README.md b/examples/java/README.md
index 5058b1808..aca1b8be6 100644
--- a/examples/java/README.md
+++ b/examples/java/README.md
@@ -191,7 +191,7 @@ These examples require a TLS-enabled Iggy server. Start the 
server with:
 IGGY_TCP_TLS_ENABLED=true \
 IGGY_TCP_TLS_CERT_FILE=core/certs/iggy_cert.pem \
 IGGY_TCP_TLS_KEY_FILE=core/certs/iggy_key.pem \
-cargo r --bin iggy-server
+cargo run --bin iggy-server
 ```
 
 Uses `IggyTcpClientBuilder` with TLS options (`enableTls`, `tlsDomain`, 
`tlsCaCertPath`) to establish TLS-encrypted TCP connections with CA certificate 
verification.
diff --git a/examples/node/README.md b/examples/node/README.md
index e25098bba..90447387a 100644
--- a/examples/node/README.md
+++ b/examples/node/README.md
@@ -125,7 +125,7 @@ These examples require a TLS-enabled Iggy server. Start the 
server with:
 IGGY_TCP_TLS_ENABLED=true \
 IGGY_TCP_TLS_CERT_FILE=core/certs/iggy_cert.pem \
 IGGY_TCP_TLS_KEY_FILE=core/certs/iggy_key.pem \
-cargo r --bin iggy-server
+cargo run --bin iggy-server
 ```
 
 Demonstrates how to configure the client with `transport: 'TLS'` and a custom 
CA certificate for secure communication.
diff --git a/examples/rust/README.md b/examples/rust/README.md
index d1bd36693..d14b5491f 100644
--- a/examples/rust/README.md
+++ b/examples/rust/README.md
@@ -202,7 +202,7 @@ These examples require a TLS-enabled Iggy server. Start the 
server with:
 IGGY_TCP_TLS_ENABLED=true \
 IGGY_TCP_TLS_CERT_FILE=core/certs/iggy_cert.pem \
 IGGY_TCP_TLS_KEY_FILE=core/certs/iggy_key.pem \
-cargo r --bin iggy-server
+cargo run --bin iggy-server
 ```
 
 Uses `IggyClientBuilder` with TLS options (`with_tls_enabled`, 
`with_tls_domain`, `with_tls_ca_file`) to establish TLS-encrypted TCP 
connections with CA certificate verification.
diff --git a/examples/rust/src/tcp-tls/consumer/main.rs 
b/examples/rust/src/tcp-tls/consumer/main.rs
index 1379868fe..2f48e464f 100644
--- a/examples/rust/src/tcp-tls/consumer/main.rs
+++ b/examples/rust/src/tcp-tls/consumer/main.rs
@@ -25,7 +25,7 @@
 //     IGGY_TCP_TLS_ENABLED=true \
 //     IGGY_TCP_TLS_CERT_FILE=core/certs/iggy_cert.pem \
 //     IGGY_TCP_TLS_KEY_FILE=core/certs/iggy_key.pem \
-//     cargo r --bin iggy-server
+//     cargo run --bin iggy-server
 //
 // Run this example (from repo root):
 //   cargo run --example tcp-tls-consumer -p iggy_examples
diff --git a/examples/rust/src/tcp-tls/producer/main.rs 
b/examples/rust/src/tcp-tls/producer/main.rs
index a0bd556ad..38b04738f 100644
--- a/examples/rust/src/tcp-tls/producer/main.rs
+++ b/examples/rust/src/tcp-tls/producer/main.rs
@@ -25,7 +25,7 @@
 //     IGGY_TCP_TLS_ENABLED=true \
 //     IGGY_TCP_TLS_CERT_FILE=core/certs/iggy_cert.pem \
 //     IGGY_TCP_TLS_KEY_FILE=core/certs/iggy_key.pem \
-//     cargo r --bin iggy-server
+//     cargo run --bin iggy-server
 //
 // Run this example (from repo root):
 //   cargo run --example tcp-tls-producer -p iggy_examples
diff --git a/scripts/run-examples-from-readme.sh 
b/scripts/run-examples-from-readme.sh
index 223199d78..58efa0f5b 100755
--- a/scripts/run-examples-from-readme.sh
+++ b/scripts/run-examples-from-readme.sh
@@ -106,6 +106,13 @@ run_language_examples() {
             report_result "${EXAMPLES_EXIT_CODE}"
             return "${EXAMPLES_EXIT_CODE}"
         fi
+        # The pre-flight leaves streams behind, and examples with
+        # hardcoded IDs assume a fresh server; restart with clean state.
+        stop_server
+        cleanup_server_state
+        # shellcheck disable=SC2086
+        start_plain_server ${server_extra_args}
+        wait_for_server_ready "${lang}"
     fi
 
     if [ "${workdir}" != "." ]; then
@@ -175,17 +182,25 @@ run_rust_examples() {
     resolve_server_binary "${TARGET}"
     resolve_cli_binary "${TARGET}"
 
+    # The README documents credentials as <iggy_username>/<iggy_password>
+    # placeholders; the test server starts with iggy/iggy.
     if [ -n "${TARGET}" ]; then
         TRANSFORM_COMMAND() {
-            echo "$1" | sed "s|cargo r |cargo r --target ${TARGET} |g" | sed 
"s|cargo run |cargo run --target ${TARGET} |g"
+            echo "$1" | sed "s|<iggy_username>|iggy|g; 
s|<iggy_password>|iggy|g; s|cargo run |cargo run --target ${TARGET} |g"
         }
     else
-        unset -f TRANSFORM_COMMAND 2>/dev/null || true
+        TRANSFORM_COMMAND() {
+            echo "$1" | sed "s|<iggy_username>|iggy|g; 
s|<iggy_password>|iggy|g"
+        }
     fi
 
     # Pre-flight: run CLI commands from root README
     _rust_preflight() {
-        run_readme_commands "README.md" '^\`cargo r --bin iggy -- '
+        run_readme_commands "README.md" '^[`]cargo run --bin iggy -- '
+        if [ "${README_COMMANDS_EXECUTED}" -eq 0 ]; then
+            echo -e "\e[31mNo CLI commands extracted from README.md; the 
preflight pattern is stale.\e[0m"
+            EXAMPLES_EXIT_CODE=1
+        fi
     }
 
     run_language_examples \
@@ -345,21 +360,15 @@ run_csharp_examples() {
     resolve_server_binary "${TARGET}"
     unset -f TRANSFORM_COMMAND 2>/dev/null || true
 
-    # Pre-flight: run CLI commands from root README
-    _csharp_preflight() {
-        run_readme_commands "README.md" '^\`cargo r --bin iggy -- '
-    }
-
     run_language_examples \
         "C#" \
         "." \
-        "README.md examples/csharp/README.md" \
+        "examples/csharp/README.md" \
         "^dotnet run --project" \
         "TcpTls" \
         "^dotnet run --project.*TcpTls" \
         0 \
-        "" \
-        "_csharp_preflight"
+        ""
 }
 
 # ---------------------------------------------------------------------------
diff --git a/scripts/utils.sh b/scripts/utils.sh
index 458a4267d..331280c3e 100755
--- a/scripts/utils.sh
+++ b/scripts/utils.sh
@@ -301,13 +301,18 @@ function portable_timeout() {
 # Usage: run_readme_commands readme_file grep_pattern [cmd_timeout 
[grep_exclude]]
 # Reads matching lines, strips backticks/comments, executes each.
 # Calls TRANSFORM_COMMAND function on each command if defined.
-# Returns: sets global EXAMPLES_EXIT_CODE.
+# Returns: sets global EXAMPLES_EXIT_CODE and README_COMMANDS_EXECUTED.
+# Zero matches is not an error here: callers iterate multiple README
+# files per pattern, and a file legitimately matching nothing must not
+# abort the pass. Callers that require matches check the counter.
 function run_readme_commands() {
     local readme_file="$1"
     local grep_pattern="$2"
     local cmd_timeout="${3:-0}"
     local grep_exclude="${4:-}"
 
+    README_COMMANDS_EXECUTED=0
+
     if [ ! -f "${readme_file}" ]; then
         return
     fi
@@ -326,6 +331,7 @@ function run_readme_commands() {
         if [ -z "${command}" ]; then
             continue
         fi
+        ((README_COMMANDS_EXECUTED += 1))
 
         if declare -f TRANSFORM_COMMAND >/dev/null 2>&1; then
             command=$(TRANSFORM_COMMAND "${command}")

Reply via email to