mirror of
https://github.com/googleapis/genai-toolbox.git
synced 2026-02-03 19:55:31 -05:00
Compare commits
10 Commits
refactor-q
...
quickstart
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35fa73516b | ||
|
|
66df3bfd21 | ||
|
|
73e0edc3cd | ||
|
|
3f32a9aab6 | ||
|
|
28006fc9b2 | ||
|
|
56c69131b4 | ||
|
|
ad4a509340 | ||
|
|
d39acac96c | ||
|
|
6df2ad28a9 | ||
|
|
8416378613 |
52
.ci/sample_tests/quickstart/go.integration.cloudbuild.yaml
Normal file
52
.ci/sample_tests/quickstart/go.integration.cloudbuild.yaml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 'golang:1.25.1'
|
||||||
|
id: 'go-quickstart-test'
|
||||||
|
entrypoint: 'bash'
|
||||||
|
args:
|
||||||
|
# The '-c' flag tells bash to execute the following string as a command.
|
||||||
|
# The 'set -ex' enables debug output and exits on error for easier troubleshooting.
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
set -ex
|
||||||
|
export VERSION=$(cat ./cmd/version.txt)
|
||||||
|
chmod +x .ci/sample_tests/run_tests.sh
|
||||||
|
.ci/sample_tests/run_tests.sh
|
||||||
|
env:
|
||||||
|
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
||||||
|
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
||||||
|
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
||||||
|
- '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']
|
||||||
|
|
||||||
|
availableSecrets:
|
||||||
|
secretManager:
|
||||||
|
- versionName: projects/${_GCP_PROJECT}/secrets/${_TOOLS_YAML_SECRET}/versions/7
|
||||||
|
env: 'TOOLS_YAML_CONTENT'
|
||||||
|
- versionName: projects/${_GCP_PROJECT_NUMBER}/secrets/${_API_KEY_SECRET}/versions/latest
|
||||||
|
env: 'GOOGLE_API_KEY'
|
||||||
|
- versionName: projects/${_GCP_PROJECT}/secrets/${_DB_PASS_SECRET}/versions/latest
|
||||||
|
env: 'DB_PASSWORD'
|
||||||
|
|
||||||
|
timeout: 1000s
|
||||||
|
|
||||||
|
options:
|
||||||
|
logging: CLOUD_LOGGING_ONLY
|
||||||
52
.ci/sample_tests/quickstart/js.integration.cloudbuild.yaml
Normal file
52
.ci/sample_tests/quickstart/js.integration.cloudbuild.yaml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 'node:22'
|
||||||
|
id: 'js-quickstart-test'
|
||||||
|
entrypoint: 'bash'
|
||||||
|
args:
|
||||||
|
# The '-c' flag tells bash to execute the following string as a command.
|
||||||
|
# The 'set -ex' enables debug output and exits on error for easier troubleshooting.
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
set -ex
|
||||||
|
export VERSION=$(cat ./cmd/version.txt)
|
||||||
|
chmod +x .ci/sample_tests/run_tests.sh
|
||||||
|
.ci/sample_tests/run_tests.sh
|
||||||
|
env:
|
||||||
|
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
||||||
|
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
||||||
|
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
||||||
|
- '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']
|
||||||
|
|
||||||
|
availableSecrets:
|
||||||
|
secretManager:
|
||||||
|
- versionName: projects/${_GCP_PROJECT}/secrets/${_TOOLS_YAML_SECRET}/versions/6
|
||||||
|
env: 'TOOLS_YAML_CONTENT'
|
||||||
|
- versionName: projects/${_GCP_PROJECT_NUMBER}/secrets/${_API_KEY_SECRET}/versions/latest
|
||||||
|
env: 'GOOGLE_API_KEY'
|
||||||
|
- versionName: projects/${_GCP_PROJECT}/secrets/${_DB_PASS_SECRET}/versions/latest
|
||||||
|
env: 'DB_PASSWORD'
|
||||||
|
|
||||||
|
timeout: 1000s
|
||||||
|
|
||||||
|
options:
|
||||||
|
logging: CLOUD_LOGGING_ONLY
|
||||||
52
.ci/sample_tests/quickstart/py.integration.cloudbuild.yaml
Normal file
52
.ci/sample_tests/quickstart/py.integration.cloudbuild.yaml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
# 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.
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:537.0.0'
|
||||||
|
id: 'python-quickstart-test'
|
||||||
|
entrypoint: 'bash'
|
||||||
|
args:
|
||||||
|
# The '-c' flag tells bash to execute the following string as a command.
|
||||||
|
# The 'set -ex' enables debug output and exits on error for easier troubleshooting.
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
set -ex
|
||||||
|
export VERSION=$(cat ./cmd/version.txt)
|
||||||
|
chmod +x .ci/sample_tests/run_py_tests.sh
|
||||||
|
.ci/sample_tests/run_py_tests.sh
|
||||||
|
env:
|
||||||
|
- 'CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}'
|
||||||
|
- 'GCP_PROJECT=${_GCP_PROJECT}'
|
||||||
|
- 'DATABASE_NAME=${_DATABASE_NAME}'
|
||||||
|
- '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']
|
||||||
|
|
||||||
|
availableSecrets:
|
||||||
|
secretManager:
|
||||||
|
- versionName: projects/${_GCP_PROJECT}/secrets/${_TOOLS_YAML_SECRET}/versions/5
|
||||||
|
env: 'TOOLS_YAML_CONTENT'
|
||||||
|
- versionName: projects/${_GCP_PROJECT_NUMBER}/secrets/${_API_KEY_SECRET}/versions/latest
|
||||||
|
env: 'GOOGLE_API_KEY'
|
||||||
|
- versionName: projects/${_GCP_PROJECT}/secrets/${_DB_PASS_SECRET}/versions/latest
|
||||||
|
env: 'DB_PASSWORD'
|
||||||
|
|
||||||
|
timeout: 1000s
|
||||||
|
|
||||||
|
options:
|
||||||
|
logging: CLOUD_LOGGING_ONLY
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
#!/bin/bash
|
|
||||||
# Copyright 2026 Google LLC
|
# Copyright 2026 Google LLC
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@@ -102,13 +101,11 @@ run_python_test() {
|
|||||||
pip install -q -r requirements.txt pytest
|
pip install -q -r requirements.txt pytest
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
# If there is a pytest file in the parent directory (like agent_test.py or quickstart_test.py)
|
|
||||||
# we use it. Otherwise we just run the agent.
|
|
||||||
local test_file=$(find . -maxdepth 1 -name "*test.py" | head -n 1)
|
local test_file=$(find . -maxdepth 1 -name "*test.py" | head -n 1)
|
||||||
if [ -n "$test_file" ]; then
|
if [ -n "$test_file" ]; then
|
||||||
echo "Found native test: $test_file. Running pytest..."
|
echo "Found native test: $test_file. Running pytest..."
|
||||||
export ORCH_NAME="$name"
|
export ORCH_NAME="$name"
|
||||||
export PYTHONPATH="../"
|
export PYTHONPATH="../"
|
||||||
pytest "$test_file"
|
pytest "$test_file"
|
||||||
else
|
else
|
||||||
echo "No native test found. running agent directly..."
|
echo "No native test found. running agent directly..."
|
||||||
@@ -142,6 +139,36 @@ run_js_test() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
cleanup() {
|
||||||
echo "Cleaning up background processes..."
|
echo "Cleaning up background processes..."
|
||||||
[ -n "$TOOLBOX_PID" ] && kill "$TOOLBOX_PID" || true
|
[ -n "$TOOLBOX_PID" ] && kill "$TOOLBOX_PID" || true
|
||||||
@@ -169,5 +196,7 @@ find "$TARGET_ROOT" -name "$AGENT_FILE_PATTERN" | while read -r agent_file; do
|
|||||||
run_python_test "$sample_dir"
|
run_python_test "$sample_dir"
|
||||||
elif [[ "$TARGET_LANG" == "js" ]]; then
|
elif [[ "$TARGET_LANG" == "js" ]]; then
|
||||||
run_js_test "$sample_dir"
|
run_js_test "$sample_dir"
|
||||||
|
elif [[ "$TARGET_LANG" == "go" ]]; then
|
||||||
|
run_go_test "$sample_dir"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -1,59 +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.
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: "${_IMAGE}"
|
|
||||||
id: "universal-test"
|
|
||||||
entrypoint: "bash"
|
|
||||||
args:
|
|
||||||
- -c
|
|
||||||
- |
|
|
||||||
set -ex
|
|
||||||
chmod +x .ci/universal/run_tests.sh
|
|
||||||
.ci/universal/run_tests.sh
|
|
||||||
env:
|
|
||||||
- "CLOUD_SQL_INSTANCE=${_CLOUD_SQL_INSTANCE}"
|
|
||||||
- "GCP_PROJECT=${_GCP_PROJECT}"
|
|
||||||
- "DATABASE_NAME=${_DATABASE_NAME}"
|
|
||||||
- "DB_USER=${_DB_USER}"
|
|
||||||
- "TARGET_ROOT=${_TARGET_ROOT}"
|
|
||||||
- "TARGET_LANG=${_TARGET_LANG}"
|
|
||||||
- "TABLE_NAME=${_TABLE_NAME}"
|
|
||||||
- "SQL_FILE=${_SQL_FILE}"
|
|
||||||
- "AGENT_FILE_PATTERN=${_AGENT_FILE_PATTERN}"
|
|
||||||
secretEnv: ["TOOLS_YAML_CONTENT", "GOOGLE_API_KEY", "DB_PASSWORD"]
|
|
||||||
|
|
||||||
availableSecrets:
|
|
||||||
secretManager:
|
|
||||||
- versionName: projects/${_GCP_PROJECT}/secrets/${_TOOLS_YAML_SECRET}/versions/5
|
|
||||||
env: "TOOLS_YAML_CONTENT"
|
|
||||||
- versionName: projects/${_GCP_PROJECT_NUMBER}/secrets/${_API_KEY_SECRET}/versions/latest
|
|
||||||
env: "GOOGLE_API_KEY"
|
|
||||||
- versionName: projects/${_GCP_PROJECT}/secrets/${_DB_PASS_SECRET}/versions/latest
|
|
||||||
env: "DB_PASSWORD"
|
|
||||||
|
|
||||||
|
|
||||||
timeout: 1200s
|
|
||||||
|
|
||||||
substitutions:
|
|
||||||
_TARGET_LANG: "python"
|
|
||||||
_IMAGE: "python:3.11"
|
|
||||||
_TARGET_ROOT: "docs/en/getting-started/quickstart/python"
|
|
||||||
_TABLE_NAME: "hotels_python"
|
|
||||||
_SQL_FILE: ".ci/universal/setup_hotels.sql"
|
|
||||||
_AGENT_FILE_PATTERN: "quickstart.py"
|
|
||||||
_LOG_BUCKET: "toolbox-test-logs"
|
|
||||||
|
|
||||||
options:
|
|
||||||
logging: CLOUD_LOGGING_ONLY
|
|
||||||
Reference in New Issue
Block a user