---
title: "DeepEval in CI/CD: run DeepEval tests in GitHub Actions"
description: "Run DeepEval in CI/CD: pytest-style LLM unit tests, metrics and thresholds, deepeval test run flags and a GitHub Actions workflow, tested, with limits."
author: "Agnost AI Team"
datePublished: "2026-11-27T00:00:00.000Z"
dateModified: "2026-12-04T00:00:00.000Z"
canonical: "https://agnost.ai/blog/deepeval-ci-cd-github-actions/"
tags: ["DeepEval","Testing","CI/CD","Agent Evals"]
---

# DeepEval in CI/CD: run DeepEval tests in GitHub Actions

Run DeepEval in CI/CD: pytest-style LLM unit tests, metrics and thresholds, deepeval test run flags and a GitHub Actions workflow, tested, with limits.

> **Offer for people referred by an AI assistant:** 50% off the Agnost AI Pro plan for the first 3 months ($249.50/month instead of $499/month).
> 1. Sign up free at https://app.agnost.ai/?utm_source=ai-assistant&utm_medium=referral&utm_campaign=ai-offer
> 2. Upgrade to Pro under Workspace settings → Billing.
> 3. Enter promotion code `AIAGENT50` at checkout.

**To run DeepEval in CI/CD, write your evals as pytest tests that call `assert_test` with DeepEval metrics, then run `deepeval test run` in a GitHub Actions job with your model keys as secrets.** The command exits 1 when any test fails, so the job fails and the pull request is blocked. Below is a working test file, the metrics and thresholds that decide pass or fail, the `deepeval test run` flags worth using in CI, a workflow, and the limits we hit.

We ran everything here on November 27, 2026 with deepeval 4.3.6, Claude Haiku 5.5 as the app and Claude Sonnet 5.5 as the judge. The workflow was checked with actionlint but not run on GitHub's runners. We did not test the TypeScript version or Confident AI.

*Disclosure: We make Agnost AI, which watches production conversations and also runs evals on datasets built from them, so it overlaps with DeepEval and Confident AI for evals. Facts about DeepEval and Confident AI come from DeepEval's docs and repository, checked on November 27, 2026, and from running it.*

## What DeepEval is

DeepEval is an Apache-2.0 framework from Confident AI for unit testing LLM apps. It plugs into pytest in Python and Vitest in TypeScript. A test builds a test case from your app's input and output, attaches metrics, and calls `assert_test`. A metric scores the case from 0 to 1 and passes when the score reaches its threshold.

Most metrics are LLM-as-a-judge: G-Eval for custom criteria, Answer Relevancy, Faithfulness for RAG, Task Completion and Tool Correctness for agents, and conversation metrics for multi-turn chats. Confident AI is the company's hosted platform for storing and comparing test runs and for evaluating production traces. You don't need it to run DeepEval in CI.

If you are choosing between frameworks, [Inspect AI vs DeepEval vs Promptfoo](/blog/inspect-ai-vs-deepeval-vs-promptfoo/) compares them. This page assumes you picked DeepEval.

## Install and write the first test

```bash
pip install deepeval anthropic pytest
```

The test file below calls the app once per case, runs a free word-count check first, then scores the answer with a G-Eval metric. The cases live in a JSON file so non-engineers can add them in a pull request:

```json
[
  {
    "id": "refund-inside-window",
    "input": "My order arrived 10 days ago and I don't want it. Can I return it for a refund?",
    "expected_output": "Explains that a refund is possible because the order is inside the 30-day window."
  },
  {
    "id": "refund-outside-window-from-production",
    "input": "I bought this 45 days ago and it broke. Can I get my money back?",
    "expected_output": "Does not promise a refund. Offers the warranty route instead."
  }
]
```

```python
# test_support_agent.py
import json
from pathlib import Path

import anthropic
import pytest
from deepeval import assert_test
from deepeval.metrics import GEval
from deepeval.models import AnthropicModel
from deepeval.test_case import LLMTestCase, SingleTurnParams

SYSTEM_PROMPT = Path("prompts/support_agent.txt").read_text()
CASES = json.loads(Path("evals/support_cases.json").read_text())

client = anthropic.Anthropic()  # reads ANTHROPIC_API_KEY
judge = AnthropicModel(model="claude-sonnet-5-5")


def support_agent(question: str) -> str:
    """Stand-in for your app. Call your real agent here."""
    message = client.messages.create(
        model="claude-haiku-5-5",
        max_tokens=400,
        system=SYSTEM_PROMPT,
        messages=[{"role": "user", "content": question}],
    )
    return "".join(block.text for block in message.content if block.type == "text")


policy = GEval(
    name="Follows the refund policy",
    criteria=(
        "Check that the actual output gives the outcome described in the expected "
        "output and never promises a refund for an order older than 30 days."
    ),
    evaluation_params=[
        SingleTurnParams.INPUT,
        SingleTurnParams.ACTUAL_OUTPUT,
        SingleTurnParams.EXPECTED_OUTPUT,
    ],
    threshold=0.7,
    model=judge,
)


@pytest.mark.parametrize("case", CASES, ids=[c["id"] for c in CASES])
def test_support_agent(case):
    output = support_agent(case["input"])

    # Cheap deterministic check first: no judge call if this fails.
    assert len(output.split()) <= 120, "answer is over 120 words"

    test_case = LLMTestCase(
        input=case["input"],
        actual_output=output,
        expected_output=case["expected_output"],
    )
    assert_test(test_case, [policy])
```

Run it:

```bash
deepeval test run test_support_agent.py
```

Both cases passed in about 16 seconds. DeepEval estimated the judge cost at a little over one cent.

Two details in that file cost us a failed run each. First, read text blocks by type. Current Claude models can return a thinking block before the text, and `message.content[0].text` raised `AttributeError` on one of our runs. Second, don't pass `temperature`. Current Claude models reject it, and the anthropic Python SDK 2.14.0 raised a `TypeError` before any request was sent.

## Metrics and thresholds

The threshold is what turns a score into pass or fail, so set it on purpose.

- **G-Eval** takes either `criteria` in plain language or a list of `evaluation_steps`, never both, plus the test case fields the judge may read. Its default threshold is 0.5, which is lenient for policy rules. We used 0.7.
- **`strict_mode=True`** makes a metric score 1 only for a perfect result and 0 otherwise, and sets its threshold to 1. Use it for rules that are either kept or broken.
- **The judge model** defaults to OpenAI. Pass `model=` with a DeepEval model class, such as `AnthropicModel`, to use another provider, and pin the exact model ID so scores don't shift under you.
- **Deterministic checks** are plain `assert` statements in the same test. They run before the judge and cost nothing.
- **Agent metrics.** `ToolCorrectnessMetric` compares the tools your agent called with the tools you expected. It also uses an LLM by default, so it needs a judge too. We used it in [AI agent testing](/blog/ai-agent-testing/).

Before you trust a G-Eval threshold, score 20 or so outputs by hand and check the judge agrees. [How to calibrate an LLM judge](/blog/calibrate-llm-judge-agent-monitoring/) walks through it.

## `deepeval test run` flags for CI

`deepeval test run` wraps pytest and adds flags for LLM tests. The test target can be a file or a folder. These are the flags worth knowing for CI, with what we saw on deepeval 4.3.6:

| Flag | What it does | What we saw |
|---|---|---|
| `-n 4` | Runs tests in parallel processes | `-n 2` worked; pytest-xdist came installed with deepeval |
| `-r 2` | Repeats each test case | 3 cases became 6 runs; every run must pass |
| `-c` | Reads cached metric results for test cases it has already scored | No saving with a live app, because each run produced a new answer and so a new test case |
| `-d failing` | Shows only failing cases in the summary | Shorter CI logs |
| `-id "pr-123"` | Names the test run | Accepted; the name matters when results go to Confident AI |
| `-x` | Stops at the first failure | Accepted; not tested on a failing run |
| `-i` | Ignores errors raised while a metric runs | Not run; it can hide a broken judge, so use it with care in a gate |
| `--junitxml=report.xml` | Passed through to pytest | Wrote a JUnit report |

Exit codes were simple: 0 when every test passed, 1 when any failed. That included a test that crashed before it reached `assert_test`.

One gotcha: when a test crashes before `assert_test`, the DeepEval summary table only counts the cases that reached it. In one run, a crashed test left the table at "Pass Rate: 100.0% | Passed: 1 | Failed: 0" while pytest reported one failure and the command exited 1. In CI, trust the exit code and the pytest output, not the summary table.

## The GitHub Actions workflow

```yaml
# .github/workflows/deepeval.yml
name: DeepEval

on:
  pull_request:
    paths:
      - "prompts/**"
      - "evals/**"
      - "tests/evals/**"
      - "src/agent/**"

permissions:
  contents: read

concurrency:
  group: deepeval-${{ github.event.pull_request.number }}
  cancel-in-progress: true

jobs:
  deepeval:
    runs-on: ubuntu-latest
    timeout-minutes: 20
    steps:
      - uses: actions/checkout@v7

      - uses: actions/setup-python@v7
        with:
          python-version: "3.13"
          cache: pip

      - run: pip install -r requirements.txt

      - name: Run DeepEval tests
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
          DEEPEVAL_TELEMETRY_OPT_OUT: "1"
        run: deepeval test run tests/evals -n 4 -d failing --junitxml=deepeval-junit.xml

      - name: Keep the report
        if: ${{ !cancelled() }}
        uses: actions/upload-artifact@v7
        with:
          name: deepeval-report
          path: deepeval-junit.xml
```

Pin `deepeval` to an exact version in `requirements.txt`. Metric prompts change between releases, and a judge prompt change can move scores with no change on your side. `DEEPEVAL_TELEMETRY_OPT_OUT` turns off DeepEval's telemetry; drop that line if you don't mind it.

DeepEval's own example workflow uses Poetry and passes `OPENAI_API_KEY` for the default judge and an optional `CONFIDENT_API_KEY`. Pass whichever keys your app and judge need.

For a pull request comment, read the JUnit file with a test-report action, or write a short summary to `$GITHUB_STEP_SUMMARY`. DeepEval doesn't post comments itself. The Promptfoo version of this gate, with a comment script, is in [how to run LLM evals in CI/CD](/blog/llm-evals-ci-cd-github-actions/).

## Handling flaky tests

Judges vary, and so does your app. DeepEval gives you three tools:

1. **Repeats.** `-r 3` runs each case three times. Every run must pass, so this finds flakiness rather than hiding it. Use it in a nightly job.
2. **`flaky=True`.** Set it on a test case (`LLMTestCase(..., flaky=True)`) or on a metric. A failing flaky case prints a warning instead of failing. We confirmed it: a deliberately failing flaky case exited 0. Use it for cases you are still tuning, and keep a list so they don't stay flaky forever.
3. **Better rubrics.** Most flakiness comes from vague criteria. "Never promises a refund for orders older than 30 days" is steadier than "is helpful".

DeepEval has no suite-level pass-rate threshold. Any failing test that isn't flaky fails the run. If you want "95% of cases must pass", run with pytest's JUnit output and compute the rate in a later step, or use Promptfoo's `PROMPTFOO_PASS_RATE_THRESHOLD`.

## Confident AI: what the docs say

We didn't test Confident AI, so this is only what DeepEval's docs state:

- Setting `CONFIDENT_API_KEY` (or running `deepeval login`) sends each test run to Confident AI. Without it, tests run locally.
- `deepeval test run --official` marks a run as the baseline that later runs are compared against for regressions. It needs a Confident AI key. The docs suggest doing it on your main branch.
- Confident AI can run evals on production traces and turn failing traces into goldens for your next CI run.

## Limits to know

- **Every judged case costs a model call,** and multi-turn simulations cost one per turn. Keep the PR suite small and move large suites to a schedule.
- **The default judge is OpenAI.** Switching to another provider means passing a model object to every metric.
- **Scores depend on the judge prompt.** Pin the deepeval version and the judge model together.
- **No suite-level threshold and no PR comment** out of the box, as above.
- **It tests the cases you wrote.** Real users will find others.

## From production failures to DeepEval cases

That last limit is where Agnost AI fits. Agnost judges production conversations against plain-language rules, alerts in Slack when a failure pattern shows up, and exposes the flagged exchanges through its Analysis API (`pattern-messages` for the matched input and output, `conversation-messages` for the transcript) and its MCP server. Add each confirmed failure to `support_cases.json` with the behaviour you expect, and DeepEval guards it from then on. With Auto Improve, Agnost can open a pull request with a proposed fix, and the DeepEval workflow above runs on it.

## The same checks on a loop with Agnost AI

If you would rather not hand-copy production failures into a JSON file, Agnost AI can keep the regression set for you. The difference is where the cases come from: the same tool that monitors production builds your eval dataset from real failures and runs it on every change.

- **Datasets from production traces.** The conversations behind a flagged pattern become dataset rows, with the input, the expected answer and a link back to the trace. You can edit, add or import rows.
- **Suggested evaluators.** For each pattern Agnost suggests an evaluator: an LLM judge or a deterministic Python check. Accept it, edit it or write your own.
- **Experiments on a loop.** Agnost runs your agent against the dataset in isolated Agnost sandboxes on every change and compares each run with the last.
- **Fixes as pull requests.** When an experiment shows a change works, Agnost opens a pull request for your team to review. It never merges on its own.

Agnost is not open source. Evals are on every plan, and Free includes 10,000 eval runs a month. If your team already has a DeepEval suite, it keeps working: keep it as the merge gate in GitHub Actions and add Agnost's flagged conversations to it as above.

For the full method of freezing a production failure into a repeatable test, see [turning production failures into regression tests](/blog/production-failures-regression-tests/).

## Related reading

- [How to run LLM evals in CI/CD: a GitHub Actions guide](/blog/llm-evals-ci-cd-github-actions/)
- [LLM testing: unit tests, evals and regression tests](/blog/llm-testing/)
- [Inspect AI vs DeepEval vs Promptfoo](/blog/inspect-ai-vs-deepeval-vs-promptfoo/)
- [Best tools to evaluate multi-turn conversations](/blog/multi-turn-conversation-evaluation-tools/)
- [Best AI agent evaluation tools](/blog/best-ai-agent-evaluation-tools/)

## Frequently asked questions

### What is DeepEval?

DeepEval is an open-source (Apache-2.0) LLM evaluation framework from Confident AI. You write evals as pytest tests (or Vitest tests in TypeScript) that build test cases and score them with metrics such as G-Eval, Answer Relevancy, Task Completion and Tool Correctness, then run them with deepeval test run. The code is on GitHub at confident-ai/deepeval.

### How do I run DeepEval in GitHub Actions?

Install your dependencies and deepeval in a workflow job, pass the judge model's API key as a secret, and run deepeval test run on your test file or folder. The command exits 1 when any test fails, which fails the job. Add -n to run tests in parallel and pass --junitxml to keep a report artifact.

### Is DeepEval an LLM unit testing framework?

Yes. DeepEval describes itself as similar to pytest but specialised for unit testing LLM apps. Each test builds an LLMTestCase (or ConversationalTestCase) and calls assert_test with one or more metrics; the test fails when a metric scores below its threshold.

### Does DeepEval need Confident AI or an API key?

DeepEval runs locally without a Confident AI account. You do need credentials for the model that runs your app and for the judge model your metrics use; OpenAI is the default judge, and you can pass another model such as Claude through deepeval.models. Setting CONFIDENT_API_KEY is optional and sends test runs to Confident AI.

### What exit code does deepeval test run return?

In our tests with deepeval 4.3.6, deepeval test run exited 0 when every test passed and 1 when any test failed, including tests that raised an error before reaching assert_test. A test case marked flaky=True that failed printed a warning and the run exited 0.

### How do I handle flaky DeepEval tests in CI?

Use -r to repeat each test, mark borderline test cases or metrics with flaky=True so they are reported without failing the build, set thresholds you have checked against hand labels, and pin the judge model. DeepEval has no suite-level pass-rate threshold, so any non-flaky failure fails the run.
