-
-
Notifications
You must be signed in to change notification settings - Fork 183
215 lines (183 loc) · 7.6 KB
/
Copy pathevals-smoke.yml
File metadata and controls
215 lines (183 loc) · 7.6 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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
name: Evals Smoke
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: evals-smoke-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
plan:
name: Plan changed skills
runs-on: ubuntu-latest
outputs:
run_count: ${{ steps.plan.outputs.run_count }}
skill_count: ${{ steps.plan.outputs.skill_count }}
base_ref: ${{ steps.plan.outputs.base_ref }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install planning dependency
run: python -m pip install --upgrade pip pyyaml
- name: Fetch base branch
if: github.event_name == 'pull_request'
run: git fetch origin "${{ github.base_ref }}" --depth=1
- name: Resolve eval plan
id: plan
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_REF="origin/${{ github.base_ref }}"
else
BASE_REF="origin/master"
fi
python evals/run_evals.py \
--changed-only \
--base-ref "$BASE_REF" \
--plan-only \
--selection-json eval-plan.json
python - <<'PY'
import json
import os
from pathlib import Path
plan = json.loads(Path("eval-plan.json").read_text())
with Path(os.environ["GITHUB_OUTPUT"]).open("a") as fh:
fh.write(f"run_count={plan['run_count']}\n")
fh.write(f"skill_count={plan['skill_count']}\n")
fh.write(f"base_ref={plan.get('base_ref') or ''}\n")
with Path(os.environ["GITHUB_STEP_SUMMARY"]).open("a") as fh:
fh.write("## Eval plan\n\n")
fh.write(f"- Base ref: `{plan.get('base_ref') or 'n/a'}`\n")
fh.write(f"- Skills: {plan['skill_count']}\n")
fh.write(f"- Scenarios: {plan['scenario_count']}\n")
fh.write(f"- Runs: {plan['run_count']}\n")
if plan["skills"]:
fh.write(f"- Selected: `{', '.join(plan['skills'])}`\n")
else:
fh.write("- Selected: none\n")
PY
- name: Note fork PR limitation
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository
run: |
{
echo
echo "Model-backed smoke evals are skipped for fork PRs because repository secrets are not exposed to untrusted pull_request runs."
echo "Maintainers can run the workflow manually with workflow_dispatch after reviewing the branch."
} >> "$GITHUB_STEP_SUMMARY"
- uses: actions/upload-artifact@v4
with:
name: eval-plan
path: eval-plan.json
smoke:
name: Run smoke evals
runs-on: ubuntu-latest
needs: plan
if: needs.plan.outputs.run_count != '0' && (github.event_name == 'workflow_dispatch' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository))
timeout-minutes: 45
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
steps:
- name: Check ANTHROPIC_API_KEY availability
id: key
run: |
if [ -z "$ANTHROPIC_API_KEY" ]; then
echo "available=false" >> "$GITHUB_OUTPUT"
{
echo "Model-backed smoke evals skipped: the ANTHROPIC_API_KEY repository secret is not configured."
echo "Configure it to enable smoke evals on internal PRs, or run evals locally (evals/run_evals.py)."
} >> "$GITHUB_STEP_SUMMARY"
else
echo "available=true" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@v4
if: steps.key.outputs.available == 'true'
with:
fetch-depth: 0
- uses: actions/setup-python@v5
if: steps.key.outputs.available == 'true'
with:
python-version: "3.12"
- name: Install Python dependency
if: steps.key.outputs.available == 'true'
run: python -m pip install --upgrade pip pyyaml
- name: Fetch base branch
if: github.event_name == 'pull_request' && steps.key.outputs.available == 'true'
run: git fetch origin "${{ github.base_ref }}" --depth=1
- name: Restore eval cache
if: steps.key.outputs.available == 'true'
id: cache-restore
uses: actions/cache/restore@v4
with:
path: evals-workspace/cache
key: evals-cache-${{ runner.os }}-${{ github.repository }}-${{ github.ref_name }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
evals-cache-${{ runner.os }}-${{ github.repository }}-${{ github.base_ref }}-
evals-cache-${{ runner.os }}-${{ github.repository }}-${{ github.ref_name }}-
evals-cache-${{ runner.os }}-${{ github.repository }}-
- name: Install claude CLI
if: steps.key.outputs.available == 'true'
run: |
curl -fsSL https://claude.ai/install.sh | bash
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Verify claude CLI
if: steps.key.outputs.available == 'true'
run: |
export PATH="$HOME/.local/bin:$PATH"
claude --version
- name: Run smoke evals
if: steps.key.outputs.available == 'true'
run: |
export PATH="$HOME/.local/bin:$PATH"
if [ "${{ github.event_name }}" = "pull_request" ]; then
BASE_REF="origin/${{ github.base_ref }}"
else
BASE_REF="origin/master"
fi
python evals/run_evals.py \
--changed-only \
--base-ref "$BASE_REF" \
--reuse-cache \
--selection-json eval-plan.json \
--iteration "ci-${{ github.run_id }}-${{ github.run_attempt }}" \
--workers 6
- name: Write benchmark summary
if: always() && steps.key.outputs.available == 'true'
run: |
python - <<'PY'
import json
import os
from pathlib import Path
summary = Path(os.environ["GITHUB_STEP_SUMMARY"])
benchmark_files = sorted(Path("evals-workspace").glob("iteration-ci-*/benchmark.json"))
if not benchmark_files:
with summary.open("a") as fh:
fh.write("\nNo benchmark artifact was produced.\n")
raise SystemExit(0)
benchmark = json.loads(benchmark_files[-1].read_text())
agg = benchmark["aggregate"]
with summary.open("a") as fh:
fh.write("\n## Smoke benchmark\n\n")
fh.write(f"- With skill: {agg['with_skill']['mean_pass_rate']:.0%}\n")
fh.write(f"- Without skill: {agg['without_skill']['mean_pass_rate']:.0%}\n")
fh.write(f"- Delta: {agg['delta']:+.0%}\n")
fh.write(f"- Cost (with skill): ${agg['with_skill']['total_cost_usd']:.2f}\n")
fh.write(f"- Cost (without skill): ${agg['without_skill']['total_cost_usd']:.2f}\n")
PY
- name: Save eval cache
if: always() && steps.key.outputs.available == 'true'
uses: actions/cache/save@v4
with:
path: evals-workspace/cache
key: ${{ steps.cache-restore.outputs.cache-primary-key }}
- uses: actions/upload-artifact@v4
if: always() && steps.key.outputs.available == 'true'
with:
name: eval-benchmark
path: |
eval-plan.json
evals-workspace/iteration-ci-*/benchmark.json