Repository navigation
179 lines (165 loc) · 7.45 KB
/
Copy pathevals-command.yml
File metadata and controls
179 lines (165 loc) · 7.45 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
name: On-Demand Cloud MCP Evals
on:
workflow_dispatch:
inputs:
pr:
description: 'PR Number'
type: string
required: true
comment-id:
description: 'Comment ID (Optional)'
type: string
required: false
full:
description: 'Run the full suite instead of only scenarios using changed MCP tools'
type: string
required: false
default: 'false'
env:
AIRBYTE_ANALYTICS_ID: ${{ vars.AIRBYTE_ANALYTICS_ID }}
permissions:
contents: read
issues: write
pull-requests: write
concurrency:
group: evals-command-${{ inputs.pr }}
cancel-in-progress: false
jobs:
run-evals:
name: Run Cloud MCP Evals
runs-on: ubuntu-24.04
timeout-minutes: 90
env:
PR: ${{ inputs.pr }}
FULL: ${{ inputs.full }}
EVALS_REPO: airbytehq/cloud-mcp-evals
steps:
- name: Resolve workflow variables
id: vars
uses: aaronsteers/resolve-ci-vars-action@2e56afab0344bbe03c047dfa39bae559d0291472 # v0.1.6
- name: Resolve eval mode
id: mode
env:
SHA: ${{ steps.vars.outputs.pr-source-git-sha }}
run: |
set -euo pipefail
[[ "$PR" =~ ^[0-9]+$ ]] || { echo "::error::Invalid PR number: $PR"; exit 1; }
if [ "$FULL" = "true" ]; then
echo "changed-only=false" >> "$GITHUB_OUTPUT"
echo "label=full suite" >> "$GITHUB_OUTPUT"
else
echo "changed-only=true" >> "$GITHUB_OUTPUT"
echo "label=changed tools only" >> "$GITHUB_OUTPUT"
fi
echo "short-sha=${SHA:0:7}" >> "$GITHUB_OUTPUT"
- name: Append comment with job run link
id: first-comment-action
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ inputs.comment-id }}
issue-number: ${{ inputs.pr }}
body: |
> Cloud MCP evals queued for `${{ steps.mode.outputs.short-sha }}` (${{ steps.mode.outputs.label }}). [Check job output.](${{ steps.vars.outputs.run-url }})
# The token lasts one hour; a full evals run takes about 20 minutes.
- name: Authenticate as GitHub App
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
id: get-app-token
with:
owner: "airbytehq"
repositories: "cloud-mcp-evals"
app-id: ${{ secrets.OCTAVIA_BOT_APP_ID }}
private-key: ${{ secrets.OCTAVIA_BOT_PRIVATE_KEY }}
permission-actions: write
- name: Dispatch evals and find the run
id: dispatch
env:
GH_TOKEN: ${{ steps.get-app-token.outputs.token }}
CHANGED_ONLY: ${{ steps.mode.outputs.changed-only }}
run: |
set -euo pipefail
since=$(date -u +%Y-%m-%dT%H:%M:%SZ)
gh workflow run evals.yml -R "$EVALS_REPO" --ref main \
-f pyairbyte="#$PR" -f changed_tools_only="$CHANGED_ONLY"
title="PyAirbyte evals: #$PR"
for _ in $(seq 18); do
sleep 10
run=$(gh run list -R "$EVALS_REPO" -w evals.yml --event workflow_dispatch --limit 20 \
--json databaseId,createdAt,displayTitle,url |
jq -c --arg since "$since" --arg title "$title" '[.[] | select(.createdAt >= $since
and (.displayTitle == $title or (.displayTitle | startswith($title + " "))))] | last')
if [ "$run" != "null" ]; then
echo "run-id=$(jq -r .databaseId <<< "$run")" >> "$GITHUB_OUTPUT"
echo "run-url=$(jq -r .url <<< "$run")" >> "$GITHUB_OUTPUT"
exit 0
fi
done
echo "::error::No '$title' run created after $since appeared in $EVALS_REPO within 3 minutes."
exit 1
- name: Append comment with evals run link
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
body: |
> Evals running: [${{ steps.dispatch.outputs.run-url }}](${{ steps.dispatch.outputs.run-url }})
- name: Wait for evals and summarize
id: report
env:
GH_TOKEN: ${{ steps.get-app-token.outputs.token }}
RUN_ID: ${{ steps.dispatch.outputs.run-id }}
RUN_URL: ${{ steps.dispatch.outputs.run-url }}
LABEL: ${{ steps.mode.outputs.label }}
CHANGED_ONLY: ${{ steps.mode.outputs.changed-only }}
run: |
set -euo pipefail
# Eval failures are expected (model variance); they are reported, not fatal.
gh run watch "$RUN_ID" -R "$EVALS_REPO" --interval 30 > /dev/null
conclusion=$(gh run view "$RUN_ID" -R "$EVALS_REPO" --json conclusion --jq .conclusion)
# A changed-tools run with nothing to run uploads no evidence; any other
# listing or download failure fails the job.
artifacts=$(gh api "repos/$EVALS_REPO/actions/runs/$RUN_ID/artifacts" --paginate \
--jq '.artifacts[] | select(.name | startswith("all-evidence-")) | .name')
results=""
if [ -n "$artifacts" ]; then
dir=$(mktemp -d)
gh run download "$RUN_ID" -R "$EVALS_REPO" -p 'all-evidence-*' -D "$dir"
results=$(find "$dir" -name results.json | head -n 1)
[ -n "$results" ] || { echo "::error::all-evidence artifact has no results.json."; exit 1; }
fi
if [ -n "$results" ]; then
run_json=$(dirname "$results")/run.json
commit=$(jq -r '.mcp.airbyte.direct_url.vcs_info.commit_id // "unknown"' "$run_json")
expected=$(jq -r '.expected_trials // empty' "$run_json")
body=$(jq -r --arg expected "$expected" --arg commit "${commit:0:7}" --arg label "$LABEL" '
(if $expected == "" then length else ($expected | tonumber) end) as $total
| (map(select(.status == "pass")) | length) as $passed
| ((group_by(.status) | map(select(.[0].status != "pass")
| "\(length) \({fail: "failed", error: "errored"}[.[0].status] // .[0].status)"))
+ (if $total > length then ["\($total - length) missing"] else [] end)) as $other
| "Cloud MCP evals on `\($commit)` (\($label)): **\($passed) / \($total) passed**"
+ (if ($other | length) > 0 then " (\($other | join(", ")))" else "" end)' "$results")
body="$body · [summary]($RUN_URL)"
elif [ "$conclusion" = "success" ] && [ "$CHANGED_ONLY" = "true" ]; then
body="No evals ran: no scenario uses the MCP tools this PR changed. [summary]($RUN_URL)"
elif [ "$conclusion" = "success" ]; then
echo "::error::Full evals run succeeded but uploaded no all-evidence artifact."
exit 1
else
body="Evals run ended ($conclusion) before producing results. [summary]($RUN_URL)"
fi
echo "$body"
echo "body=$body" >> "$GITHUB_OUTPUT"
- name: Append results comment
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
body: |
> ${{ steps.report.outputs.body }}
- name: Append failure comment
if: failure()
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
comment-id: ${{ steps.first-comment-action.outputs.comment-id }}
issue-number: ${{ inputs.pr }}
reactions: confused
body: |
> ❌ Cloud MCP evals could not be run or reported. [Check job output.](${{ steps.vars.outputs.run-url }})