|
| 1 | +# BrowserStack AI Evals — GitHub Action |
| 2 | + |
| 3 | +Run AI evaluation experiments on every pull request. Compares scores against the previous baseline and reports pass/regression status with a sticky PR comment, Job Summary, and CI metadata tracking. |
| 4 | + |
| 5 | +## How it works |
| 6 | + |
| 7 | +1. Looks up the experiment by name (configured in the BrowserStack AI Evals UI) |
| 8 | +2. Triggers a new experiment run with CI metadata (branch, commit, actor, PR number) |
| 9 | +3. Waits for the run to complete |
| 10 | +4. Fetches a server-computed comparison against the previous baseline run |
| 11 | +5. Posts a sticky PR comment and Job Summary with per-evaluator scores, deltas, and threshold status |
| 12 | +6. Fails the job if any threshold is breached (configurable) |
| 13 | + |
| 14 | +## Quickstart |
| 15 | + |
| 16 | +```yaml |
| 17 | +name: AI Evals |
| 18 | +on: |
| 19 | + pull_request: |
| 20 | + paths: ['src/**', 'prompts/**'] |
| 21 | + |
| 22 | +jobs: |
| 23 | + evals: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + permissions: |
| 26 | + pull-requests: write |
| 27 | + contents: read |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + - uses: browserstack/github-actions/ai-evals@v1 |
| 31 | + with: |
| 32 | + experiment: refund-bot-eval |
| 33 | + public-key: ${{ secrets.AISDK_PUBLIC_KEY }} |
| 34 | + secret-key: ${{ secrets.AISDK_SECRET_KEY }} |
| 35 | +``` |
| 36 | +
|
| 37 | +## Inputs |
| 38 | +
|
| 39 | +| Name | Required | Default | Description | |
| 40 | +|---|---|---|---| |
| 41 | +| `experiment` | yes | — | Experiment name (configured in the UI). | |
| 42 | +| `public-key` | no | — | API public key. Falls back to `AISDK_PUBLIC_KEY` env var. | |
| 43 | +| `secret-key` | no | — | API secret key. Falls back to `AISDK_SECRET_KEY` env var. | |
| 44 | +| `github-token` | no | `${{ github.token }}` | Token for the PR comment. | |
| 45 | +| `fail-on-regression` | no | `true` | Fail the job when a threshold is breached. | |
| 46 | +| `comment-on-pr` | no | `true` | Post/edit a sticky PR comment. | |
| 47 | +| `timeout` | no | `900` | Max seconds to wait for the run to complete and its comparison scores to be ready. | |
| 48 | + |
| 49 | +## Exit codes |
| 50 | + |
| 51 | +| Code | Meaning | |
| 52 | +|---|---| |
| 53 | +| 0 | All thresholds passed | |
| 54 | +| 1 | At least one threshold breached | |
| 55 | +| 2 | Experiment not found | |
| 56 | +| 3 | Run failed or timed out | |
| 57 | + |
| 58 | +## Multiple experiments |
| 59 | + |
| 60 | +Each experiment gets its own sticky comment. Run them in parallel or sequence: |
| 61 | + |
| 62 | +```yaml |
| 63 | +steps: |
| 64 | + - uses: browserstack/github-actions/ai-evals@v1 |
| 65 | + with: |
| 66 | + experiment: refund-bot-eval |
| 67 | + public-key: ${{ secrets.AISDK_PUBLIC_KEY }} |
| 68 | + secret-key: ${{ secrets.AISDK_SECRET_KEY }} |
| 69 | +
|
| 70 | + - uses: browserstack/github-actions/ai-evals@v1 |
| 71 | + with: |
| 72 | + experiment: search-ranking-eval |
| 73 | + public-key: ${{ secrets.AISDK_PUBLIC_KEY }} |
| 74 | + secret-key: ${{ secrets.AISDK_SECRET_KEY }} |
| 75 | +``` |
0 commit comments