From 08b190c02c5fa0c716fc88b4d2294336aab57623 Mon Sep 17 00:00:00 2001 From: btshrewsbury-viam Date: Mon, 13 Jul 2026 09:05:01 -0600 Subject: [PATCH] Retry code samples once on failure to absorb transient backend errors Every Test Code Samples failure since the sample-bug fixes in #5120 has been a transient error that cleared within seconds: gRPC INTERNAL on DeleteDataPipeline, DEADLINE_EXCEEDED on data-query, or brief test machine connection drops. Run each sample a second time after a 30s delay before counting it as failed, so only persistent failures fail the job. Sample credentials already flow through each step's env block, so the redundant inline variable prefixes are dropped. Tracking issue: #5119 --- .github/workflows/test-code-snippets.yml | 41 +++++++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test-code-snippets.yml b/.github/workflows/test-code-snippets.yml index f30b9e7f73..bbf7747de8 100644 --- a/.github/workflows/test-code-snippets.yml +++ b/.github/workflows/test-code-snippets.yml @@ -84,6 +84,16 @@ jobs: passed_files_py=0 failed_files_py=0 + # Run a sample, retrying once after a delay. The live backend + # intermittently returns transient errors (gRPC INTERNAL, + # DEADLINE_EXCEEDED) that clear within seconds. + run_sample() { + if "$@"; then return 0; fi + echo "⚠️ Failed, retrying once in 30s in case the error is transient..." + sleep 30 + "$@" + } + echo "Starting to test Python code samples..." echo "========================================" @@ -91,8 +101,8 @@ jobs: echo "Testing: $file" total_files_py=$((total_files_py + 1)) - # Run the test with environment variables explicitly passed - if VIAM_API_KEY="$VIAM_API_KEY" VIAM_API_KEY_ID="$VIAM_API_KEY_ID" TEST_ORG_ID="$TEST_ORG_ID" VIAM_API_KEY_DATA_REGIONS="$VIAM_API_KEY_DATA_REGIONS" VIAM_API_KEY_ID_DATA_REGIONS="$VIAM_API_KEY_ID_DATA_REGIONS" python "$file"; then + # Credentials come from this step's env block. + if run_sample python "$file"; then passed_files_py=$((passed_files_py + 1)) echo "✅ PASSED: $file" else @@ -150,6 +160,16 @@ jobs: passed_files_go=0 failed_files_go=0 + # Run a sample, retrying once after a delay. The live backend + # intermittently returns transient errors (gRPC INTERNAL, + # DEADLINE_EXCEEDED) that clear within seconds. + run_sample() { + if "$@"; then return 0; fi + echo "⚠️ Failed, retrying once in 30s in case the error is transient..." + sleep 30 + "$@" + } + echo "Starting to test Go code samples..." echo "========================================" @@ -166,7 +186,8 @@ jobs: # Check if directory exists before changing to it if [ -d "$file_dir" ]; then - if (cd "$file_dir" && VIAM_API_KEY="$VIAM_API_KEY" VIAM_API_KEY_ID="$VIAM_API_KEY_ID" TEST_ORG_ID="$TEST_ORG_ID" go run "$file_name"); then + # Credentials come from this step's env block. + if (cd "$file_dir" && run_sample go run "$file_name"); then passed_files_go=$((passed_files_go + 1)) echo "✅ PASSED: $file" else @@ -229,6 +250,16 @@ jobs: passed_files_ts=0 failed_files_ts=0 + # Run a sample, retrying once after a delay. The live backend + # intermittently returns transient errors (gRPC INTERNAL, + # DEADLINE_EXCEEDED) that clear within seconds. + run_sample() { + if "$@"; then return 0; fi + echo "⚠️ Failed, retrying once in 30s in case the error is transient..." + sleep 30 + "$@" + } + echo "Starting to test TypeScript code samples..." echo "========================================" @@ -236,8 +267,8 @@ jobs: echo "Testing: $file" total_files_ts=$((total_files_ts + 1)) - # Run the test with environment variables explicitly passed - if VIAM_API_KEY="$VIAM_API_KEY" VIAM_API_KEY_ID="$VIAM_API_KEY_ID" TEST_ORG_ID="$TEST_ORG_ID" VIAM_API_KEY_DATA_REGIONS="$VIAM_API_KEY_DATA_REGIONS" VIAM_API_KEY_ID_DATA_REGIONS="$VIAM_API_KEY_ID_DATA_REGIONS" node "$file"; then + # Credentials come from this step's env block. + if run_sample node "$file"; then passed_files_ts=$((passed_files_ts + 1)) echo "✅ PASSED: $file" else