Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions .github/workflows/test-code-snippets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,25 @@ 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 "========================================"

for file in "${python_files[@]}"; do
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
Expand Down Expand Up @@ -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 "========================================"

Expand All @@ -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
Expand Down Expand Up @@ -229,15 +250,25 @@ 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 "========================================"

for file in "${ts_files[@]}"; do
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
Expand Down
Loading