Skip to content

Commit 787a4be

Browse files
authored
chore: update README for v2 release (#113)
1 parent 040f367 commit 787a4be

1 file changed

Lines changed: 89 additions & 71 deletions

File tree

README.md

Lines changed: 89 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,73 @@
1-
# Braintrust eval action
1+
# Braintrust Eval Action
22

3-
This project enables you to run [Braintrust evals](braintrust.dev) as part of
4-
your CI/CD workflow in Github, using
5-
[Github actions](https://github.com/features/actions). To use this action,
6-
simply include the following step in an action file:
3+
Run [Braintrust evals](https://www.braintrust.dev) in GitHub Actions and post a
4+
live summary comment on the associated pull request.
5+
6+
## Quick start
77

88
```yaml
9-
- name: Run Evals
10-
uses: braintrustdata/eval-action@v1
11-
with:
12-
api_key: ${{ secrets.BRAINTRUST_API_KEY }}
13-
runtime: node
9+
name: Braintrust evals
10+
11+
on:
12+
pull_request:
13+
push:
14+
15+
permissions:
16+
contents: read
17+
pull-requests: write
18+
19+
jobs:
20+
eval:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: 22
30+
31+
- name: Run evals
32+
uses: braintrustdata/eval-action@v2
33+
with:
34+
api_key: ${{ secrets.BRAINTRUST_API_KEY }}
35+
runtime: node
1436
```
1537
16-
You can configure the following variables:
17-
18-
- `api_key`: Your
19-
[Braintrust API key](https://www.braintrust.dev/app/settings/api-keys).
20-
- `root`: The root directory containing your evals (defaults to `'.'`). The root
21-
directory must have `node`, `python`, or `go` configured.
22-
- `paths`: Specific paths, relative to the root, containing evals you'd like to
23-
run.
24-
- `runtime`: Either `node`, `python`, or `go`
25-
- `package_manager`: Either `npm` or `pnpm` for a `node` runtime, `pip` or `uv`
26-
for a `python` runtime, or `go` for a `go` runtime. You can omit this for Go.
27-
- `use_proxy`: Either `true` or `false`. If set, `OPENAI_BASE_URL` will be set
28-
to `https://braintrustproxy.com/v1`, which will automatically cache repetitive
29-
LLM calls and run your evals faster. Defaults to `true`.
30-
- `terminate_on_failure`: Either `true` or `false`. If set to `true`, the
31-
evaluation process will stop when an error occurs. Defaults to `false`.
38+
<!-- oxfmt-ignore -->
39+
40+
> [!IMPORTANT] You must specify `permissions` for the action to leave comments
41+
> on your PR. Without these permissions, you'll see GitHub API errors.
42+
43+
## Inputs
44+
45+
| Input | Required | Description |
46+
| ---------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
47+
| `api_key` | Yes | Your [Braintrust API key](https://www.braintrust.dev/app/settings/api-keys). |
48+
| `runtime` | Yes | The runtime to use: `node`, `python`, or `go`. |
49+
| `root` | No | Root directory containing your evals. Defaults to `.`. |
50+
| `paths` | No | Paths or glob patterns, relative to `root`, containing evals to run. Defaults to `.`. |
51+
| `package_manager` | No | `npm` or `pnpm` for Node; `pip` or `uv` for Python; `go` for Go. Can be omitted for the default package manager. |
52+
| `use_proxy` | No | Set to `true` to use the Braintrust proxy at `https://braintrustproxy.com/v1`, which can cache repetitive LLM calls and speed up evals. Defaults to `true`. |
53+
| `terminate_on_failure` | No | Set to `true` to stop the eval process when an error occurs. Defaults to `false`. Ignored for Go evals. |
54+
| `github_token` | No | GitHub token used to create or update PR comments. Defaults to `${{ github.token }}`. |
3255

3356
## Full example
3457

3558
```yaml
3659
name: Run pnpm evals
3760
3861
on:
62+
pull_request:
3963
push:
40-
# Uncomment to run only when files in the 'evals' directory change
41-
# - paths:
42-
# - "evals/**"
64+
# Uncomment to run only when files in the 'evals' directory change.
65+
# paths:
66+
# - "evals/**"
4367
4468
permissions:
45-
pull-requests: write
4669
contents: read
70+
pull-requests: write
4771
4872
jobs:
4973
eval:
@@ -52,74 +76,68 @@ jobs:
5276
5377
steps:
5478
- name: Checkout
55-
id: checkout
5679
uses: actions/checkout@v4
5780
with:
5881
fetch-depth: 0
5982
6083
- name: Setup Node.js
61-
id: setup-node
6284
uses: actions/setup-node@v4
6385
with:
64-
node-version: 20
86+
node-version: 22
6587
66-
- uses: pnpm/action-setup@v3
88+
- name: Setup pnpm
89+
uses: pnpm/action-setup@v4
6790
with:
68-
version: 8
91+
version: 10
6992
70-
- name: Install Dependencies
71-
id: install
72-
run: pnpm install
93+
- name: Install dependencies
94+
run: pnpm install --frozen-lockfile
7395
74-
- name: Run Evals
75-
uses: braintrustdata/eval-action@v1
96+
- name: Run evals
97+
uses: braintrustdata/eval-action@v2
7698
with:
7799
api_key: ${{ secrets.BRAINTRUST_API_KEY }}
78100
runtime: node
101+
package_manager: pnpm
79102
root: my_eval_dir
80103
```
81104

82-
> [!IMPORTANT] You must specify `permissions` for the action to leave comments
83-
> on your PR. Without these permissions, you'll see Github API errors.
84-
85-
To see examples of fully configured templates, see the `examples` directory:
105+
For more fully configured workflows, see the `examples` directory:
86106

87107
- [`node with npm`](examples/node/npm.yml)
88108
- [`node with pnpm`](examples/node/pnpm.yml)
89109
- [`python with pip`](examples/python/pip.yml)
90110
- [`python with uv`](examples/python/uv.yml)
91111
- [`go`](examples/go/go.yml)
92112

93-
## Go evals
94-
95-
The Go runtime executes `go run ${paths}`. To include Go eval results in the PR
96-
comment, print each `ExperimentSummary` as one JSON line after calling
97-
`result.Summarize(ctx)`:
98-
99-
```go
100-
summary, err := result.Summarize(ctx)
101-
if err != nil {
102-
log.Fatal(err)
103-
}
104-
b, err := json.Marshal(summary)
105-
if err != nil {
106-
log.Fatal(err)
107-
}
108-
fmt.Println(string(b))
109-
```
113+
## Runtime behavior
114+
115+
- **Node and Python:** the action runs `braintrust eval --jsonl` from `root` and
116+
collects the emitted experiment summaries.
117+
- **Go:** the action runs `go run ${paths}` from `root`. To include Go eval
118+
results in the PR comment, print each `ExperimentSummary` as one JSON line
119+
after calling `result.Summarize(ctx)`:
110120

111-
## How it works
121+
```go
122+
summary, err := result.Summarize(ctx)
123+
if err != nil {
124+
log.Fatal(err)
125+
}
126+
b, err := json.Marshal(summary)
127+
if err != nil {
128+
log.Fatal(err)
129+
}
130+
fmt.Println(string(b))
131+
```
112132

113-
For Node and Python, the action runs `braintrust eval`. For Go, the action runs
114-
`go run` on `paths` from `root`. It collects experiment results emitted as JSONL
115-
and posts them as a comment in the PR alongside a link to Braintrust. For
116-
example:
133+
The action creates or updates a single PR comment with a Braintrust link and
134+
result table. For example:
117135

118-
### Example braintrust eval report
136+
### Example Braintrust eval report
119137

120138
**[Say Hi Bot (HEAD-1714341466)](https://www.braintrustdata.com/app/braintrustdata.com/p/Say%20Hi%20Bot/experiments/HEAD-1714341466)**
121139

122-
| Score | Average | Improvements | Regressions |
123-
| ----------- | ----------- | -----------: | ----------: |
124-
| Levenshtein | 0.83 (+3pp) | 8 🟢 | 4 🔴 |
125-
| Duration | 1s (0s) | 16 🟢 | 1 🔴 |
140+
| Score | Average | Improvements | Regressions |
141+
| ----------- | ---------- | -----------: | ----------: |
142+
| Levenshtein | 83% (+3pp) | 8 🟢 | 4 🔴 |
143+
| Duration | 1s (0s) | 16 🟢 | 1 🔴 |

0 commit comments

Comments
 (0)