mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-03 19:55:31 -05:00
Compare commits
9 Commits
quickstart
...
link-check
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cbbf23b70 | ||
|
|
f1c366162e | ||
|
|
6467a3ea46 | ||
|
|
215ac01787 | ||
|
|
854e0433ee | ||
|
|
6e981a3e50 | ||
|
|
05f0eabbd6 | ||
|
|
9a097a6e4a | ||
|
|
5f5935b938 |
@@ -23,18 +23,13 @@ steps:
|
|||||||
- |
|
- |
|
||||||
set -ex
|
set -ex
|
||||||
export VERSION=$(cat ./cmd/version.txt)
|
export VERSION=$(cat ./cmd/version.txt)
|
||||||
chmod +x .ci/sample_tests/run_tests.sh
|
chmod +x .ci/quickstart_test/run_go_tests.sh
|
||||||
.ci/sample_tests/run_tests.sh
|
.ci/quickstart_test/run_go_tests.sh
|
||||||
env:
|
env:
|
||||||
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
||||||
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
||||||
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
||||||
- 'DB_USER=${_DB_USER}'
|
- 'DB_USER=${_DB_USER}'
|
||||||
- 'TARGET_ROOT=docs/en/getting-started/quickstart/go'
|
|
||||||
- 'TARGET_LANG=go'
|
|
||||||
- 'TABLE_NAME=hotels_go'
|
|
||||||
- 'SQL_FILE=.ci/sample_tests/setup_hotels.sql'
|
|
||||||
- 'AGENT_FILE_PATTERN=quickstart.go'
|
|
||||||
secretEnv: ['TOOLS_YAML_CONTENT', 'GOOGLE_API_KEY', 'DB_PASSWORD']
|
secretEnv: ['TOOLS_YAML_CONTENT', 'GOOGLE_API_KEY', 'DB_PASSWORD']
|
||||||
|
|
||||||
availableSecrets:
|
availableSecrets:
|
||||||
@@ -23,18 +23,13 @@ steps:
|
|||||||
- |
|
- |
|
||||||
set -ex
|
set -ex
|
||||||
export VERSION=$(cat ./cmd/version.txt)
|
export VERSION=$(cat ./cmd/version.txt)
|
||||||
chmod +x .ci/sample_tests/run_tests.sh
|
chmod +x .ci/quickstart_test/run_js_tests.sh
|
||||||
.ci/sample_tests/run_tests.sh
|
.ci/quickstart_test/run_js_tests.sh
|
||||||
env:
|
env:
|
||||||
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
||||||
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
||||||
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
||||||
- 'DB_USER=${_DB_USER}'
|
- 'DB_USER=${_DB_USER}'
|
||||||
- 'TARGET_ROOT=docs/en/getting-started/quickstart/js'
|
|
||||||
- 'TARGET_LANG=js'
|
|
||||||
- 'TABLE_NAME=hotels_js'
|
|
||||||
- 'SQL_FILE=.ci/sample_tests/setup_hotels.sql'
|
|
||||||
- 'AGENT_FILE_PATTERN=quickstart.js'
|
|
||||||
secretEnv: ['TOOLS_YAML_CONTENT', 'GOOGLE_API_KEY', 'DB_PASSWORD']
|
secretEnv: ['TOOLS_YAML_CONTENT', 'GOOGLE_API_KEY', 'DB_PASSWORD']
|
||||||
|
|
||||||
availableSecrets:
|
availableSecrets:
|
||||||
@@ -23,18 +23,13 @@ steps:
|
|||||||
- |
|
- |
|
||||||
set -ex
|
set -ex
|
||||||
export VERSION=$(cat ./cmd/version.txt)
|
export VERSION=$(cat ./cmd/version.txt)
|
||||||
chmod +x .ci/sample_tests/run_py_tests.sh
|
chmod +x .ci/quickstart_test/run_py_tests.sh
|
||||||
.ci/sample_tests/run_py_tests.sh
|
.ci/quickstart_test/run_py_tests.sh
|
||||||
env:
|
env:
|
||||||
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
||||||
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
||||||
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
||||||
- 'DB_USER=${_DB_USER}'
|
- 'DB_USER=${_DB_USER}'
|
||||||
- 'TARGET_ROOT=docs/en/getting-started/quickstart/python'
|
|
||||||
- 'TARGET_LANG=python'
|
|
||||||
- 'TABLE_NAME=hotels_python'
|
|
||||||
- 'SQL_FILE=.ci/sample_tests/setup_hotels.sql'
|
|
||||||
- 'AGENT_FILE_PATTERN=quickstart.py'
|
|
||||||
secretEnv: ['TOOLS_YAML_CONTENT', 'GOOGLE_API_KEY', 'DB_PASSWORD']
|
secretEnv: ['TOOLS_YAML_CONTENT', 'GOOGLE_API_KEY', 'DB_PASSWORD']
|
||||||
|
|
||||||
availableSecrets:
|
availableSecrets:
|
||||||
125
.ci/quickstart_test/run_go_tests.sh
Normal file
125
.ci/quickstart_test/run_go_tests.sh
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed 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.
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TABLE_NAME="hotels_go"
|
||||||
|
QUICKSTART_GO_DIR="docs/en/getting-started/quickstart/go"
|
||||||
|
SQL_FILE=".ci/quickstart_test/setup_hotels_sample.sql"
|
||||||
|
|
||||||
|
PROXY_PID=""
|
||||||
|
TOOLBOX_PID=""
|
||||||
|
|
||||||
|
install_system_packages() {
|
||||||
|
apt-get update && apt-get install -y \
|
||||||
|
postgresql-client \
|
||||||
|
wget \
|
||||||
|
gettext-base \
|
||||||
|
netcat-openbsd
|
||||||
|
}
|
||||||
|
|
||||||
|
start_cloud_sql_proxy() {
|
||||||
|
wget "https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.10.0/cloud-sql-proxy.linux.amd64" -O /usr/local/bin/cloud-sql-proxy
|
||||||
|
chmod +x /usr/local/bin/cloud-sql-proxy
|
||||||
|
cloud-sql-proxy "${CLOUD_SQL_INSTANCE}" &
|
||||||
|
PROXY_PID=$!
|
||||||
|
|
||||||
|
for i in {1..30}; do
|
||||||
|
if nc -z 127.0.0.1 5432; then
|
||||||
|
echo "Cloud SQL Proxy is up and running."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Cloud SQL Proxy failed to start within the timeout period."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_toolbox() {
|
||||||
|
TOOLBOX_YAML="/tools.yaml"
|
||||||
|
echo "${TOOLS_YAML_CONTENT}" > "$TOOLBOX_YAML"
|
||||||
|
if [ ! -f "$TOOLBOX_YAML" ]; then echo "Failed to create tools.yaml"; exit 1; fi
|
||||||
|
wget "https://storage.googleapis.com/genai-toolbox/v${VERSION}/linux/amd64/toolbox" -O "/toolbox"
|
||||||
|
chmod +x "/toolbox"
|
||||||
|
/toolbox --tools-file "$TOOLBOX_YAML" &
|
||||||
|
TOOLBOX_PID=$!
|
||||||
|
sleep 2
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_orch_table() {
|
||||||
|
export TABLE_NAME
|
||||||
|
envsubst < "$SQL_FILE" | psql -h "$PGHOST" -p "$PGPORT" -U "$DB_USER" -d "$DATABASE_NAME"
|
||||||
|
}
|
||||||
|
|
||||||
|
run_orch_test() {
|
||||||
|
local orch_dir="$1"
|
||||||
|
local orch_name
|
||||||
|
orch_name=$(basename "$orch_dir")
|
||||||
|
|
||||||
|
if [ "$orch_name" == "openAI" ]; then
|
||||||
|
echo -e "\nSkipping framework '${orch_name}': Temporarily excluded."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
setup_orch_table
|
||||||
|
|
||||||
|
echo "--- Preparing module for $orch_name ---"
|
||||||
|
cd "$orch_dir"
|
||||||
|
|
||||||
|
if [ -f "go.mod" ]; then
|
||||||
|
go mod tidy
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
export ORCH_NAME="$orch_name"
|
||||||
|
|
||||||
|
echo "--- Running tests for $orch_name ---"
|
||||||
|
go test -v ./...
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup_all() {
|
||||||
|
echo "--- Final cleanup: Shutting down processes and dropping table ---"
|
||||||
|
if [ -n "$TOOLBOX_PID" ]; then
|
||||||
|
kill $TOOLBOX_PID || true
|
||||||
|
fi
|
||||||
|
if [ -n "$PROXY_PID" ]; then
|
||||||
|
kill $PROXY_PID || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap cleanup_all EXIT
|
||||||
|
|
||||||
|
# Main script execution
|
||||||
|
install_system_packages
|
||||||
|
start_cloud_sql_proxy
|
||||||
|
|
||||||
|
export PGHOST=127.0.0.1
|
||||||
|
export PGPORT=5432
|
||||||
|
export PGPASSWORD="$DB_PASSWORD"
|
||||||
|
export GOOGLE_API_KEY="$GOOGLE_API_KEY"
|
||||||
|
|
||||||
|
setup_toolbox
|
||||||
|
|
||||||
|
for ORCH_DIR in "$QUICKSTART_GO_DIR"/*/; do
|
||||||
|
if [ ! -d "$ORCH_DIR" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
run_orch_test "$ORCH_DIR"
|
||||||
|
done
|
||||||
125
.ci/quickstart_test/run_js_tests.sh
Normal file
125
.ci/quickstart_test/run_js_tests.sh
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed 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.
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TABLE_NAME="hotels_js"
|
||||||
|
QUICKSTART_JS_DIR="docs/en/getting-started/quickstart/js"
|
||||||
|
SQL_FILE=".ci/quickstart_test/setup_hotels_sample.sql"
|
||||||
|
|
||||||
|
# Initialize process IDs to empty at the top of the script
|
||||||
|
PROXY_PID=""
|
||||||
|
TOOLBOX_PID=""
|
||||||
|
|
||||||
|
install_system_packages() {
|
||||||
|
apt-get update && apt-get install -y \
|
||||||
|
postgresql-client \
|
||||||
|
wget \
|
||||||
|
gettext-base \
|
||||||
|
netcat-openbsd
|
||||||
|
}
|
||||||
|
|
||||||
|
start_cloud_sql_proxy() {
|
||||||
|
wget "https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.10.0/cloud-sql-proxy.linux.amd64" -O /usr/local/bin/cloud-sql-proxy
|
||||||
|
chmod +x /usr/local/bin/cloud-sql-proxy
|
||||||
|
cloud-sql-proxy "${CLOUD_SQL_INSTANCE}" &
|
||||||
|
PROXY_PID=$!
|
||||||
|
|
||||||
|
for i in {1..30}; do
|
||||||
|
if nc -z 127.0.0.1 5432; then
|
||||||
|
echo "Cloud SQL Proxy is up and running."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Cloud SQL Proxy failed to start within the timeout period."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_toolbox() {
|
||||||
|
TOOLBOX_YAML="/tools.yaml"
|
||||||
|
echo "${TOOLS_YAML_CONTENT}" > "$TOOLBOX_YAML"
|
||||||
|
if [ ! -f "$TOOLBOX_YAML" ]; then echo "Failed to create tools.yaml"; exit 1; fi
|
||||||
|
wget "https://storage.googleapis.com/genai-toolbox/v${VERSION}/linux/amd64/toolbox" -O "/toolbox"
|
||||||
|
chmod +x "/toolbox"
|
||||||
|
/toolbox --tools-file "$TOOLBOX_YAML" &
|
||||||
|
TOOLBOX_PID=$!
|
||||||
|
sleep 2
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_orch_table() {
|
||||||
|
export TABLE_NAME
|
||||||
|
envsubst < "$SQL_FILE" | psql -h "$PGHOST" -p "$PGPORT" -U "$DB_USER" -d "$DATABASE_NAME"
|
||||||
|
}
|
||||||
|
|
||||||
|
run_orch_test() {
|
||||||
|
local orch_dir="$1"
|
||||||
|
local orch_name
|
||||||
|
orch_name=$(basename "$orch_dir")
|
||||||
|
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
echo "--- Preparing environment for $orch_name ---"
|
||||||
|
setup_orch_table
|
||||||
|
|
||||||
|
cd "$orch_dir"
|
||||||
|
echo "Installing dependencies for $orch_name..."
|
||||||
|
if [ -f "package-lock.json" ]; then
|
||||||
|
npm ci
|
||||||
|
else
|
||||||
|
npm install
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd ..
|
||||||
|
|
||||||
|
echo "--- Running tests for $orch_name ---"
|
||||||
|
export ORCH_NAME="$orch_name"
|
||||||
|
node --test quickstart.test.js
|
||||||
|
|
||||||
|
echo "--- Cleaning environment for $orch_name ---"
|
||||||
|
rm -rf "${orch_name}/node_modules"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup_all() {
|
||||||
|
echo "--- Final cleanup: Shutting down processes and dropping table ---"
|
||||||
|
if [ -n "$TOOLBOX_PID" ]; then
|
||||||
|
kill $TOOLBOX_PID || true
|
||||||
|
fi
|
||||||
|
if [ -n "$PROXY_PID" ]; then
|
||||||
|
kill $PROXY_PID || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap cleanup_all EXIT
|
||||||
|
|
||||||
|
# Main script execution
|
||||||
|
install_system_packages
|
||||||
|
start_cloud_sql_proxy
|
||||||
|
|
||||||
|
export PGHOST=127.0.0.1
|
||||||
|
export PGPORT=5432
|
||||||
|
export PGPASSWORD="$DB_PASSWORD"
|
||||||
|
export GOOGLE_API_KEY="$GOOGLE_API_KEY"
|
||||||
|
|
||||||
|
setup_toolbox
|
||||||
|
|
||||||
|
for ORCH_DIR in "$QUICKSTART_JS_DIR"/*/; do
|
||||||
|
if [ ! -d "$ORCH_DIR" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
run_orch_test "$ORCH_DIR"
|
||||||
|
done
|
||||||
115
.ci/quickstart_test/run_py_tests.sh
Normal file
115
.ci/quickstart_test/run_py_tests.sh
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
# Copyright 2025 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed 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.
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
TABLE_NAME="hotels_python"
|
||||||
|
QUICKSTART_PYTHON_DIR="docs/en/getting-started/quickstart/python"
|
||||||
|
SQL_FILE=".ci/quickstart_test/setup_hotels_sample.sql"
|
||||||
|
|
||||||
|
PROXY_PID=""
|
||||||
|
TOOLBOX_PID=""
|
||||||
|
|
||||||
|
install_system_packages() {
|
||||||
|
apt-get update && apt-get install -y \
|
||||||
|
postgresql-client \
|
||||||
|
python3-venv \
|
||||||
|
wget \
|
||||||
|
gettext-base \
|
||||||
|
netcat-openbsd
|
||||||
|
}
|
||||||
|
|
||||||
|
start_cloud_sql_proxy() {
|
||||||
|
wget "https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.10.0/cloud-sql-proxy.linux.amd64" -O /usr/local/bin/cloud-sql-proxy
|
||||||
|
chmod +x /usr/local/bin/cloud-sql-proxy
|
||||||
|
cloud-sql-proxy "${CLOUD_SQL_INSTANCE}" &
|
||||||
|
PROXY_PID=$!
|
||||||
|
|
||||||
|
for i in {1..30}; do
|
||||||
|
if nc -z 127.0.0.1 5432; then
|
||||||
|
echo "Cloud SQL Proxy is up and running."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Cloud SQL Proxy failed to start within the timeout period."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_toolbox() {
|
||||||
|
TOOLBOX_YAML="/tools.yaml"
|
||||||
|
echo "${TOOLS_YAML_CONTENT}" > "$TOOLBOX_YAML"
|
||||||
|
if [ ! -f "$TOOLBOX_YAML" ]; then echo "Failed to create tools.yaml"; exit 1; fi
|
||||||
|
wget "https://storage.googleapis.com/genai-toolbox/v${VERSION}/linux/amd64/toolbox" -O "/toolbox"
|
||||||
|
chmod +x "/toolbox"
|
||||||
|
/toolbox --tools-file "$TOOLBOX_YAML" &
|
||||||
|
TOOLBOX_PID=$!
|
||||||
|
sleep 2
|
||||||
|
}
|
||||||
|
|
||||||
|
setup_orch_table() {
|
||||||
|
export TABLE_NAME
|
||||||
|
envsubst < "$SQL_FILE" | psql -h "$PGHOST" -p "$PGPORT" -U "$DB_USER" -d "$DATABASE_NAME"
|
||||||
|
}
|
||||||
|
|
||||||
|
run_orch_test() {
|
||||||
|
local orch_dir="$1"
|
||||||
|
local orch_name
|
||||||
|
orch_name=$(basename "$orch_dir")
|
||||||
|
(
|
||||||
|
set -e
|
||||||
|
setup_orch_table
|
||||||
|
cd "$orch_dir"
|
||||||
|
local VENV_DIR=".venv"
|
||||||
|
python3 -m venv "$VENV_DIR"
|
||||||
|
source "$VENV_DIR/bin/activate"
|
||||||
|
pip install -r requirements.txt
|
||||||
|
echo "--- Running tests for $orch_name ---"
|
||||||
|
cd ..
|
||||||
|
ORCH_NAME="$orch_name" pytest
|
||||||
|
rm -rf "$VENV_DIR"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup_all() {
|
||||||
|
echo "--- Final cleanup: Shutting down processes and dropping table ---"
|
||||||
|
if [ -n "$TOOLBOX_PID" ]; then
|
||||||
|
kill $TOOLBOX_PID || true
|
||||||
|
fi
|
||||||
|
if [ -n "$PROXY_PID" ]; then
|
||||||
|
kill $PROXY_PID || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap cleanup_all EXIT
|
||||||
|
|
||||||
|
# Main script execution
|
||||||
|
install_system_packages
|
||||||
|
start_cloud_sql_proxy
|
||||||
|
|
||||||
|
export PGHOST=127.0.0.1
|
||||||
|
export PGPORT=5432
|
||||||
|
export PGPASSWORD="$DB_PASSWORD"
|
||||||
|
export GOOGLE_API_KEY="$GOOGLE_API_KEY"
|
||||||
|
|
||||||
|
setup_toolbox
|
||||||
|
|
||||||
|
for ORCH_DIR in "$QUICKSTART_PYTHON_DIR"/*/; do
|
||||||
|
if [ ! -d "$ORCH_DIR" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
run_orch_test "$ORCH_DIR"
|
||||||
|
done
|
||||||
@@ -1,202 +0,0 @@
|
|||||||
# Copyright 2026 Google LLC
|
|
||||||
#
|
|
||||||
# Licensed 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 -e
|
|
||||||
|
|
||||||
# --- Configuration (from Environment Variables) ---
|
|
||||||
# TARGET_ROOT: The directory to search for tests (e.g., docs/en/getting-started/quickstart/js)
|
|
||||||
# TARGET_LANG: python, js, go
|
|
||||||
# TABLE_NAME: Database table name to use
|
|
||||||
# SQL_FILE: Path to the SQL setup file
|
|
||||||
# AGENT_FILE_PATTERN: Filename to look for (e.g., quickstart.js or agent.py)
|
|
||||||
|
|
||||||
VERSION=$(cat ./cmd/version.txt)
|
|
||||||
|
|
||||||
# Process IDs & Logs
|
|
||||||
PROXY_PID=""
|
|
||||||
TOOLBOX_PID=""
|
|
||||||
PROXY_LOG="cloud_sql_proxy.log"
|
|
||||||
TOOLBOX_LOG="toolbox_server.log"
|
|
||||||
|
|
||||||
install_system_packages() {
|
|
||||||
echo "Installing system packages..."
|
|
||||||
apt-get update && apt-get install -y \
|
|
||||||
postgresql-client \
|
|
||||||
wget \
|
|
||||||
gettext-base \
|
|
||||||
netcat-openbsd
|
|
||||||
|
|
||||||
if [[ "$TARGET_LANG" == "python" ]]; then
|
|
||||||
apt-get install -y python3-venv
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
start_cloud_sql_proxy() {
|
|
||||||
echo "Starting Cloud SQL Proxy..."
|
|
||||||
wget -q "https://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.10.0/cloud-sql-proxy.linux.amd64" -O /usr/local/bin/cloud-sql-proxy
|
|
||||||
chmod +x /usr/local/bin/cloud-sql-proxy
|
|
||||||
cloud-sql-proxy "${CLOUD_SQL_INSTANCE}" > "$PROXY_LOG" 2>&1 &
|
|
||||||
PROXY_PID=$!
|
|
||||||
|
|
||||||
# Health Check
|
|
||||||
for i in {1..30}; do
|
|
||||||
if nc -z 127.0.0.1 5432; then
|
|
||||||
echo "Cloud SQL Proxy is up and running."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
echo "ERROR: Cloud SQL Proxy failed to start. Logs:"
|
|
||||||
cat "$PROXY_LOG"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_toolbox() {
|
|
||||||
echo "Setting up Toolbox server..."
|
|
||||||
TOOLBOX_YAML="/tools.yaml"
|
|
||||||
echo "${TOOLS_YAML_CONTENT}" > "$TOOLBOX_YAML"
|
|
||||||
wget -q "https://storage.googleapis.com/genai-toolbox/v${VERSION}/linux/amd64/toolbox" -O "/toolbox"
|
|
||||||
chmod +x "/toolbox"
|
|
||||||
/toolbox --tools-file "$TOOLBOX_YAML" > "$TOOLBOX_LOG" 2>&1 &
|
|
||||||
TOOLBOX_PID=$!
|
|
||||||
|
|
||||||
# Health Check
|
|
||||||
for i in {1..15}; do
|
|
||||||
if nc -z 127.0.0.1 5000; then
|
|
||||||
echo "Toolbox server is up and running."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
echo "ERROR: Toolbox server failed to start. Logs:"
|
|
||||||
cat "$TOOLBOX_LOG"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_db_table() {
|
|
||||||
echo "Setting up database table $TABLE_NAME using $SQL_FILE..."
|
|
||||||
export TABLE_NAME
|
|
||||||
envsubst < "$SQL_FILE" | psql -h 127.0.0.1 -p 5432 -U "$DB_USER" -d "$DATABASE_NAME"
|
|
||||||
}
|
|
||||||
|
|
||||||
run_python_test() {
|
|
||||||
local dir=$1
|
|
||||||
local name=$(basename "$dir")
|
|
||||||
echo "--- Running Python Test: $name ---"
|
|
||||||
(
|
|
||||||
cd "$dir"
|
|
||||||
python3 -m venv .venv
|
|
||||||
source .venv/bin/activate
|
|
||||||
pip install -q -r requirements.txt pytest
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
local test_file=$(find . -maxdepth 1 -name "*test.py" | head -n 1)
|
|
||||||
if [ -n "$test_file" ]; then
|
|
||||||
echo "Found native test: $test_file. Running pytest..."
|
|
||||||
export ORCH_NAME="$name"
|
|
||||||
export PYTHONPATH="../"
|
|
||||||
pytest "$test_file"
|
|
||||||
else
|
|
||||||
echo "No native test found. running agent directly..."
|
|
||||||
export PYTHONPATH="../"
|
|
||||||
python3 "${name}/${AGENT_FILE_PATTERN}"
|
|
||||||
fi
|
|
||||||
rm -rf "${name}/.venv"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
run_js_test() {
|
|
||||||
local dir=$1
|
|
||||||
local name=$(basename "$dir")
|
|
||||||
echo "--- Running JS Test: $name ---"
|
|
||||||
(
|
|
||||||
cd "$dir"
|
|
||||||
if [ -f "package-lock.json" ]; then npm ci -q; else npm install -q; fi
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
# Looking for a JS test file in the parent directory
|
|
||||||
local test_file=$(find . -maxdepth 1 -name "*test.js" | head -n 1)
|
|
||||||
if [ -n "$test_file" ]; then
|
|
||||||
echo "Found native test: $test_file. Running node --test..."
|
|
||||||
export ORCH_NAME="$name"
|
|
||||||
node --test "$test_file"
|
|
||||||
else
|
|
||||||
echo "No native test found. running agent directly..."
|
|
||||||
node "${name}/${AGENT_FILE_PATTERN}"
|
|
||||||
fi
|
|
||||||
rm -rf "${name}/node_modules"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
run_go_test() {
|
|
||||||
local dir=$1
|
|
||||||
local name=$(basename "$dir")
|
|
||||||
|
|
||||||
if [ "$name" == "openAI" ]; then
|
|
||||||
echo -e "\nSkipping framework '${name}': Temporarily excluded."
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "--- Running Go Test: $name ---"
|
|
||||||
(
|
|
||||||
cd "$dir"
|
|
||||||
if [ -f "go.mod" ]; then
|
|
||||||
go mod tidy
|
|
||||||
fi
|
|
||||||
|
|
||||||
cd ..
|
|
||||||
local test_file=$(find . -maxdepth 1 -name "*test.go" | head -n 1)
|
|
||||||
if [ -n "$test_file" ]; then
|
|
||||||
echo "Found native test: $test_file. Running go test..."
|
|
||||||
export ORCH_NAME="$name"
|
|
||||||
go test -v ./...
|
|
||||||
else
|
|
||||||
echo "No native test found. running agent directly..."
|
|
||||||
cd "$name"
|
|
||||||
go run "."
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
cleanup() {
|
|
||||||
echo "Cleaning up background processes..."
|
|
||||||
[ -n "$TOOLBOX_PID" ] && kill "$TOOLBOX_PID" || true
|
|
||||||
[ -n "$PROXY_PID" ] && kill "$PROXY_PID" || true
|
|
||||||
}
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
# --- Execution ---
|
|
||||||
install_system_packages
|
|
||||||
start_cloud_sql_proxy
|
|
||||||
|
|
||||||
export PGHOST=127.0.0.1
|
|
||||||
export PGPORT=5432
|
|
||||||
export PGPASSWORD="$DB_PASSWORD"
|
|
||||||
export GOOGLE_API_KEY="$GOOGLE_API_KEY"
|
|
||||||
|
|
||||||
setup_toolbox
|
|
||||||
setup_db_table
|
|
||||||
|
|
||||||
echo "Scanning $TARGET_ROOT for tests with pattern $AGENT_FILE_PATTERN..."
|
|
||||||
|
|
||||||
find "$TARGET_ROOT" -name "$AGENT_FILE_PATTERN" | while read -r agent_file; do
|
|
||||||
sample_dir=$(dirname "$agent_file")
|
|
||||||
if [[ "$TARGET_LANG" == "python" ]]; then
|
|
||||||
run_python_test "$sample_dir"
|
|
||||||
elif [[ "$TARGET_LANG" == "js" ]]; then
|
|
||||||
run_js_test "$sample_dir"
|
|
||||||
elif [[ "$TARGET_LANG" == "go" ]]; then
|
|
||||||
run_go_test "$sample_dir"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
26
.github/workflows/link_checker_workflow.yaml
vendored
26
.github/workflows/link_checker_workflow.yaml
vendored
@@ -32,29 +32,37 @@ jobs:
|
|||||||
restore-keys: cache-lychee-
|
restore-keys: cache-lychee-
|
||||||
|
|
||||||
- name: Link Checker
|
- name: Link Checker
|
||||||
|
id: lychee-check
|
||||||
uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2
|
uses: lycheeverse/lychee-action@a8c4c7cb88f0c7386610c35eb25108e448569cb0 # v2
|
||||||
|
continue-on-error: true
|
||||||
with:
|
with:
|
||||||
args: >
|
args: >
|
||||||
--verbose
|
--quiet
|
||||||
--no-progress
|
--no-progress
|
||||||
--cache
|
--cache
|
||||||
--max-cache-age 1d
|
--max-cache-age 1d
|
||||||
--exclude '^neo4j\+.*' --exclude '^bolt://.*'
|
--exclude '^neo4j\+.*' --exclude '^bolt://.*'
|
||||||
README.md
|
README.md
|
||||||
docs/
|
docs/
|
||||||
output: /tmp/foo.txt
|
output: lychee-report.md
|
||||||
fail: true
|
format: markdown
|
||||||
jobSummary: true
|
fail: true
|
||||||
debug: true
|
jobSummary: false
|
||||||
|
debug: false
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
# This step only runs if the 'lychee_check' step fails, ensuring the
|
|
||||||
# context note only appears when the developer needs to troubleshoot.
|
- name: Display Failure Report
|
||||||
- name: Display Link Context Note on Failure
|
# Run this ONLY if the link checker failed
|
||||||
if: ${{ failure() }}
|
if: steps.lychee-check.outcome == 'failure'
|
||||||
run: |
|
run: |
|
||||||
echo "## Link Resolution Note" >> $GITHUB_STEP_SUMMARY
|
echo "## Link Resolution Note" >> $GITHUB_STEP_SUMMARY
|
||||||
echo "Local links and directory changes work differently on GitHub than on the docsite." >> $GITHUB_STEP_SUMMARY
|
echo "Local links and directory changes work differently on GitHub than on the docsite." >> $GITHUB_STEP_SUMMARY
|
||||||
echo "You must ensure fixes pass the **GitHub check** and also work with **\`hugo server\`**." >> $GITHUB_STEP_SUMMARY
|
echo "You must ensure fixes pass the **GitHub check** and also work with **\`hugo server\`**." >> $GITHUB_STEP_SUMMARY
|
||||||
|
echo "See [Link Checking and Fixing with Lychee](https://github.com/googleapis/genai-toolbox/blob/main/DEVELOPER.md#link-checking-and-fixing-with-lychee) for more details." >> $GITHUB_STEP_SUMMARY
|
||||||
echo "---" >> $GITHUB_STEP_SUMMARY
|
echo "---" >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
echo "### Broken Links Found" >> $GITHUB_STEP_SUMMARY
|
||||||
|
cat ./lychee-report.md >> $GITHUB_STEP_SUMMARY
|
||||||
|
|
||||||
|
exit 1
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ https://cloud.dgraph.io/login
|
|||||||
https://dgraph.io/docs
|
https://dgraph.io/docs
|
||||||
|
|
||||||
# MySQL Community downloads and main site (often protected by bot mitigation)
|
# MySQL Community downloads and main site (often protected by bot mitigation)
|
||||||
https://dev.mysql.com/downloads/installer/
|
^https?://(.*\.)?mysql\.com/.*
|
||||||
https://www.mysql.com/
|
|
||||||
|
|
||||||
# Claude desktop download link
|
# Claude desktop download link
|
||||||
https://claude.ai/download
|
https://claude.ai/download
|
||||||
@@ -37,8 +36,8 @@ https://dev.mysql.com/doc/refman/8.4/en/sql-prepared-statements.html
|
|||||||
https://dev.mysql.com/doc/refman/8.4/en/user-names.html
|
https://dev.mysql.com/doc/refman/8.4/en/user-names.html
|
||||||
|
|
||||||
# npmjs links can occasionally trigger rate limiting during high-frequency CI builds
|
# npmjs links can occasionally trigger rate limiting during high-frequency CI builds
|
||||||
https://www.npmjs.com/package/@toolbox-sdk/core
|
^https?://(www\.)?npmjs\.com/.*
|
||||||
https://www.npmjs.com/package/@toolbox-sdk/adk
|
|
||||||
https://www.oceanbase.com/
|
https://www.oceanbase.com/
|
||||||
|
|
||||||
# Ignore social media and blog profiles to reduce external request overhead
|
# Ignore social media and blog profiles to reduce external request overhead
|
||||||
|
|||||||
Reference in New Issue
Block a user