Skip to content

Commit d3de647

Browse files
authored
Merge branch 'main' into chore/GHA-190231-stepsecurity-remediation
2 parents 4da06ad + 0fe250f commit d3de647

12 files changed

Lines changed: 462 additions & 227 deletions

File tree

‎.github/workflows/check-dist.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333

3434
- name: Checkout
3535
id: checkout
36-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
36+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3737

3838
- name: Setup Node.js
3939
id: setup-node

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- name: Checkout
2626
id: checkout
27-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
27+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2828

2929
- name: Setup Node.js
3030
id: setup-node

‎.github/workflows/linter.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424

2525
- name: Checkout
2626
id: checkout
27-
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
27+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
2828

2929
- name: Setup Node.js
3030
id: setup-node

‎README.md‎

Lines changed: 106 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,76 @@
11
[![StepSecurity Maintained Action](https://raw.githubusercontent.com/step-security/maintained-actions-assets/main/assets/maintained-action-banner.png)](https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions)
22

3-
# Braintrust eval action
3+
# Braintrust Eval Action
44

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

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

3559
## Full example
3660

3761
```yaml
3862
name: Run pnpm evals
3963
4064
on:
65+
pull_request:
4166
push:
42-
# Uncomment to run only when files in the 'evals' directory change
43-
# - paths:
44-
# - "evals/**"
67+
# Uncomment to run only when files in the 'evals' directory change.
68+
# paths:
69+
# - "evals/**"
4570
4671
permissions:
47-
pull-requests: write
4872
contents: read
73+
pull-requests: write
4974
5075
jobs:
5176
eval:
@@ -54,74 +79,85 @@ jobs:
5479
5580
steps:
5681
- name: Checkout
57-
id: checkout
5882
uses: actions/checkout@v7
5983
with:
6084
fetch-depth: 0
6185
6286
- name: Setup Node.js
63-
id: setup-node
6487
uses: actions/setup-node@v7
6588
with:
66-
node-version: 20
89+
node-version: 24
6790
6891
- uses: step-security/action-setup@v5
6992
with:
70-
version: 8
93+
version: 10
7194
72-
- name: Install Dependencies
73-
id: install
74-
run: pnpm install
95+
- name: Install dependencies
96+
run: pnpm install --frozen-lockfile
7597
76-
- name: Run Evals
98+
- name: Run evals
7799
uses: step-security/eval-action@v2
78100
with:
79101
api_key: ${{ secrets.BRAINTRUST_API_KEY }}
80102
runtime: node
103+
package_manager: pnpm
81104
root: my_eval_dir
82105
```
83106

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

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

95-
## Go evals
96-
97-
The Go runtime executes `go run ${paths}`. To include Go eval results in the PR
98-
comment, print each `ExperimentSummary` as one JSON line after calling
99-
`result.Summarize(ctx)`:
100-
101-
```go
102-
summary, err := result.Summarize(ctx)
103-
if err != nil {
104-
log.Fatal(err)
105-
}
106-
b, err := json.Marshal(summary)
107-
if err != nil {
108-
log.Fatal(err)
109-
}
110-
fmt.Println(string(b))
111-
```
115+
## Runtime behavior
116+
117+
- **Node and Python:** the action runs `braintrust eval --jsonl` from `root` and
118+
collects the emitted experiment summaries.
119+
- **Go:** the action runs `go run ${paths}` from `root`. To include Go eval
120+
results in the PR comment, print each `ExperimentSummary` as one JSON line
121+
after calling `result.Summarize(ctx)`:
122+
123+
```go
124+
summary, err := result.Summarize(ctx)
125+
if err != nil {
126+
log.Fatal(err)
127+
}
128+
b, err := json.Marshal(summary)
129+
if err != nil {
130+
log.Fatal(err)
131+
}
132+
fmt.Println(string(b))
133+
```
134+
135+
The action creates or updates a single PR comment with a Braintrust link and a
136+
result table with score and metric sections. To show only selected results, set
137+
`report_scores` and `report_metrics` to their exact names:
112138

113-
## How it works
139+
```yaml
140+
- uses: step-security/eval-action@v2
141+
with:
142+
api_key: ${{ secrets.BRAINTRUST_API_KEY }}
143+
runtime: node
144+
report_scores: Levenshtein, Factuality
145+
report_metrics: |
146+
Duration
147+
Cost
148+
```
114149

115-
For Node and Python, the action runs `braintrust eval`. For Go, the action runs
116-
`go run` on `paths` from `root`. It collects experiment results emitted as JSONL
117-
and posts them as a comment in the PR alongside a link to Braintrust. For
118-
example:
150+
Each input accepts comma- or newline-separated names and filters its category
151+
independently. When an input is omitted or empty, all results in that category
152+
are included. For example:
119153

120-
### Example braintrust eval report
154+
### Example Braintrust eval report
121155

122-
**Say Hi Bot (HEAD-1714341466)**
156+
**[Say Hi Bot (HEAD-1714341466)](https://www.braintrustdata.com/app/braintrustdata.com/p/Say%20Hi%20Bot/experiments/HEAD-1714341466)**
123157

124-
| Score | Average | Improvements | Regressions |
125-
| ----------- | ----------- | -----------: | ----------: |
126-
| Levenshtein | 0.83 (+3pp) | 8 🟢 | 4 🔴 |
127-
| Duration | 1s (0s) | 16 🟢 | 1 🔴 |
158+
| Name | Average | Improvements | Regressions |
159+
| --------------- | ---------- | -----------: | ----------: |
160+
| **Scores** | | | |
161+
| Levenshtein | 83% (+3pp) | 8 🟢 | 4 🔴 |
162+
| **Metrics** | | | |
163+
| Duration | 1s (0s) | 16 🟢 | 1 🔴 |

‎action.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,18 @@ inputs:
4141
'true' or 'false'."
4242
required: false
4343
default: "false"
44+
report_scores:
45+
description:
46+
"A comma- or newline-separated list of score names to include in the PR
47+
comment. By default, all scores are included."
48+
required: false
49+
default: ""
50+
report_metrics:
51+
description:
52+
"A comma- or newline-separated list of metric names to include in the PR
53+
comment. By default, all metrics are included."
54+
required: false
55+
default: ""
4456
github_token:
4557
description: "Your GitHub token"
4658
required: true

‎eval/dist/index.js‎

Lines changed: 44 additions & 43 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎eval/dist/index.js.map‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎eval/osv-scanner.toml‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
[[IgnoredVulns]]
2-
id = "GHSA-g7r4-m6w7-qqqr"
3-
reason = "esbuild@0.28.0 is a transitive dependency of braintrust; ExperimentSummary is a type-only import erased at bundle time, so braintrust's esbuild is never exercised"
2+
id = "GHSA-82fw-gwwq-j7x9"
3+
reason = "dev dependency (@vitest/mocker, vitest) — not bundled into the action runtime"
44

55
[[IgnoredVulns]]
6-
id = "GHSA-w5hq-g745-h8pq"
7-
reason = "uuid@9.0.1 is a transitive dependency of @braintrust/core; only uuid.parse/stringify are called (not the vulnerable generators), and this action only uses capitalize() which has no uuid code path"
6+
id = "GHSA-5gmw-xhrv-c9v3"
7+
reason = "dev dependency (tinypool) — not bundled into the action runtime"
8+
9+
[[IgnoredVulns]]
10+
id = "GHSA-85c8-ppgw-ccpr"
11+
reason = "dev dependency (tinypool) — not bundled into the action runtime"

0 commit comments

Comments
 (0)