Regression-Testing a Prompt in GitHub Actions with Promptfoo
Someone tweaks a system prompt to fix one complaint, the pull request looks harmless, and a week later a different kind of request starts coming back wrong. Nobody ran the old examples against the new wording, because nothing made them. A prompt is code that changes behaviour, so it deserves the same thing your other code gets: a test that runs on every pull request.
Promptfoo is a command-line tool for exactly this. You describe prompts, providers and test cases in a YAML file, it runs every combination, and each output is checked against assertions. This walkthrough takes one prompt from "it seemed fine when I tried it" to a GitHub Actions check that comments on the pull request. Everything below comes from the promptfoo docs as of November 2026; I've linked the page each piece comes from.
Start with a config that fails for the right reasons
Install isn't really a step. The getting started page runs it through npx, and also offers a global npm install or Homebrew:
npx promptfoo@latest init --example getting-started
cd getting-started
export OPENAI_API_KEY=sk-...
npx promptfoo@latest eval
npx promptfoo@latest view
eval runs the tests and view opens a local web UI with the result grid. The example config it creates has this shape (model names are the ones the docs use today):
prompts:
- 'Convert the following English text to {{language}}: {{input}}'
providers:
- openai:gpt-6-sol
- openai:gpt-6-luna
tests:
- vars:
language: French
input: Hello world
assert:
- type: contains
value: 'Bonjour le monde'
- vars:
language: Spanish
input: Where is the library?
assert:
- type: icontains
value: 'Dónde está la biblioteca'
Three things are going on. prompts holds one or more templates with {{variables}}. providers lists the models to run them against, so you can compare two models in the same run. tests gives each case its variables and, optionally, assertions. Every prompt runs against every provider for every test.
The assertions are where the value is. The getting started page lists contains, icontains, icontains-any, llm-rubric, javascript, cost and latency, among others. My rule of thumb:
- Use deterministic checks (
contains,icontains,javascript) for anything you can state exactly: a required field, a forbidden phrase, valid JSON. - Use
llm-rubricfor things only a reader can judge, like "doesn't apologise" or "answers in one paragraph". It costs another model call and it can be wrong, so keep these few. - Add
costorlatencywhen a prompt change might quietly make every request longer.
If you're new to what makes a good test set, our post on evaluating LLM applications covers the thinking behind picking cases. The short version: every bug report about a bad answer becomes a test case, the same way a fixed bug gets a regression test.
Lay out the repo so CI knows when to run
The official GitHub Action expects your prompts and config in a predictable place. The GitHub Action docs use this layout:
prompts/
promptfooconfig.yaml
support-reply.json
summarise-ticket.json
.github/workflows/prompt-eval.yml
Keeping prompts in their own folder pays off twice. The workflow can trigger only on changes under prompts/**, so you're not spending tokens on every CSS fix, and reviewers can see at a glance that a pull request touches model behaviour.
The workflow file
Here's the workflow, built from the example on the GitHub Action page. I've used tag-based uses: lines for readability; the docs pin actions/setup-node to a commit SHA with a # v6 comment, which is the safer habit (our GitHub Actions cheat sheet has more on pinning).
name: Prompt eval
on:
pull_request:
paths:
- 'prompts/**'
jobs:
evaluate:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version: '24'
- name: Cache promptfoo results
uses: actions/cache@v4
with:
path: ~/.cache/promptfoo
key: ${{ runner.os }}-promptfoo-v1
restore-keys: |
${{ runner.os }}-promptfoo-
- name: Run promptfoo evaluation
uses: promptfoo/promptfoo-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
prompts: 'prompts/**/*.json'
config: 'prompts/promptfooconfig.yaml'
cache-path: ~/.cache/promptfoo
A few details from the docs worth knowing before you copy it:
| Input | Required | What it's for |
|---|---|---|
github-token | yes | GitHub API calls, including the PR comment |
prompts | yes | glob for the prompt files to evaluate |
config | yes | path to promptfooconfig.yaml |
openai-api-key | no | only if your providers are OpenAI models |
cache-path | no | where request and output caches live |
The pull-requests: write permission is there so the action can post its comment. The page says the runner needs Node.js 22.22.0 or newer and recommends Node 24, which is why setup-node sits before the action.
The cache step matters more than it looks. Promptfoo caches LLM requests and outputs, and the docs point out that restoring that cache between runs lets later runs reuse earlier responses, which saves money. Unchanged test cases against an unchanged prompt don't need a fresh call.
Make it a gate, not just a report
The action posts results, but you probably also want a red X when tests fail. The CI/CD integration page shows the plain-CLI route, which gives you more control:
- name: Run eval
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
run: npx promptfoo@latest eval -c prompts/promptfooconfig.yaml -o results.json -o report.html
- name: Quality gate
run: |
FAILURES=$(jq '.results.stats.failures' results.json)
if [ "$FAILURES" -gt 0 ]; then exit 1; fi
You can pass -o more than once, and the docs list JSON, HTML and JUnit XML among the formats. JUnit is handy if you already show test reports in CI. The same page documents --fail-on-error for failing on any test failure, and a variant of the gate script that computes a pass rate from results.json and fails below a threshold (95% in their example).
Which should you choose? I'd start strict: zero failures on deterministic assertions. Once you add llm-rubric checks, a small pass-rate tolerance makes sense, because a judge model will sometimes disagree with itself. Pick the threshold deliberately and write it in the workflow, not in someone's head.
The docs also mention --share, which uploads results and puts a shareableUrl in the JSON output. Think before turning it on for a private repo: your prompts and outputs leave the runner.
Gotchas
- Rate limits. A config with many tests, several providers and a few prompt variants multiplies quickly. The CI page suggests enabling caching or dropping concurrency with
-j 1if you hit limits. - Cache staleness. A cached answer is reused even if the provider changed the model behind the same name.
PROMPTFOO_CACHE_TTL(the docs' example is 86400 seconds) bounds how old a cached response can be. - Flaky assertions. If a test fails one run in five, it's usually the assertion, not the model. Loosen
containstoicontains-anywith a few acceptable phrasings, or move it to a rubric. - Model names drift. The provider IDs in the docs change as vendors ship models. Pin the exact model you run in production, not a nickname you saw in an example.
Where this fits with the rest of your tooling
Promptfoo answers "did this change make known cases worse?" before merge. It doesn't tell you how real traffic behaves after deploy; that's the job of tracing tools like Langfuse, compared in our LLM observability roundup. Many teams feed interesting production traces back in as new promptfoo test cases, which closes the loop.
If your CI already runs coding agents, the permissions advice in running AI coding agents in GitHub Actions applies here too: give the eval job read access to contents and write access to pull requests, nothing more.
A sensible first week looks like this:
- Put your most important prompt in
prompts/with five to ten test cases taken from real requests. - Add only deterministic assertions at first.
- Add the workflow with the cache step, and a quality gate that fails on any failure.
- Each time someone reports a bad answer, add it as a test before fixing the prompt.
- Once the suite is stable, add one or two
llm-rubricchecks and a pass-rate threshold for those.
Written by AIDToolStack Editorial
Researched from official documentation, specifications and vendor pages, listed under Sources below. Last checked November 2026.