-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathci_eval_pipeline.sh
More file actions
executable file
·84 lines (75 loc) · 2.2 KB
/
Copy pathci_eval_pipeline.sh
File metadata and controls
executable file
·84 lines (75 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash
# 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.
# Example: CI/CD evaluation pipeline using bq-agent-sdk CLI.
#
# This script runs multiple evaluations and gates the build on their
# results. Use it in GitHub Actions, Cloud Build, or any CI system.
#
# Prerequisites:
# pip install bigquery-agent-analytics
# export BQ_AGENT_PROJECT=my-project
# export BQ_AGENT_DATASET=agent_analytics
#
# Usage:
# bash examples/ci_eval_pipeline.sh
#
# In GitHub Actions:
# - name: Run agent evaluation gate
# env:
# BQ_AGENT_PROJECT: ${{ secrets.BQ_PROJECT }}
# BQ_AGENT_DATASET: ${{ secrets.BQ_DATASET }}
# run: bash examples/ci_eval_pipeline.sh
set -euo pipefail
echo "=== Agent Evaluation Pipeline ==="
echo ""
# Step 1: Health check
echo "--- Step 1: Health check ---"
if ! bq-agent-sdk doctor --format=text; then
echo "FAIL: Health check failed. Aborting pipeline."
exit 2
fi
echo ""
# Step 2: Latency evaluation (last 24h)
echo "--- Step 2: Latency gate ---"
bq-agent-sdk evaluate \
--evaluator=latency \
--threshold=5000 \
--last=24h \
--exit-code \
--format=text
echo ""
# Step 3: Error rate evaluation
echo "--- Step 3: Error rate gate ---"
bq-agent-sdk evaluate \
--evaluator=error_rate \
--threshold=0.1 \
--last=24h \
--exit-code \
--format=text
echo ""
# Step 4: Cost evaluation
echo "--- Step 4: Cost gate ---"
bq-agent-sdk evaluate \
--evaluator=cost \
--threshold=2.0 \
--last=24h \
--exit-code \
--format=text
echo ""
# Step 5: Generate insights report (informational, does not gate)
echo "--- Step 5: Insights report ---"
bq-agent-sdk insights --last=24h --format=text || true
echo ""
echo "=== All evaluation gates passed ==="