How to Integrate Rhesis SDK into Your CI/CD Pipeline
Automate LLM testing in your CI/CD pipeline to catch quality issues before they reach production. This guide shows you how to set up automated test execution, quality gates, and failure detection in your continuous integration workflow.
What You’ll Achieve
- Automated Testing: Run LLM tests on every commit or pull request
- Quality Gates: Block deployments when tests fail
- Early Detection: Catch regressions and quality issues before production
- Test Reports: Get detailed test results in your CI/CD logs
Use Cases
- Chatbot Testing: Validate conversational AI responses
- API Validation: Test LLM-powered API endpoints
- Regression Prevention: Detect when changes break existing behaviors
Prerequisites
Before integrating Rhesis into your CI/CD pipeline, ensure you have:
- Python 3.10+ available in your CI environment
- A Rhesis account at app.rhesis.ai
- An Endpoint configured in Rhesis with your LLM application URL
- A Test Set created with test scenarios to run
- Basic familiarity with GitHub Actions, GitLab CI, or similar tools
This guide uses GitHub Actions as the example, but the principles apply to any CI/CD platform (GitLab CI, Jenkins, CircleCI, etc.).
Quick Start: All example files are available in the examples/ci-cd/ directory. Copy the workflow and script files to your repository to get started quickly.
How It Works
The CI/CD integration follows this workflow:
Setup Steps
Get Your API Credentials
- Log in to app.rhesis.ai
- Navigate to API Tokens
- Generate a new API Token
- Copy the Token (you’ll need it in the next step)
Keep your API Token secure. Never commit it directly to your repository.
Configure CI/CD Secrets
Store your Rhesis credentials as environment variables in your CI/CD platform:
For GitHub Actions:
- Go to your repository Settings → Secrets and variables → Actions
- Click New repository secret
- Add these secrets:
| Secret Name | Value | Description |
|---|---|---|
RHESIS_API_KEY | Your API key | Authentication for Rhesis API |
RHESIS_ENDPOINT_NAME | Your endpoint name | The endpoint to test |
RHESIS_TEST_SET_NAME | Your test set name | Test scenarios to run |
Find your Endpoint and Test Set names in the Rhesis dashboard. Important: Names must be unique for the SDK to identify the correct resources. While the platform allows duplicate names, this should be avoided when using the SDK for CI/CD automation.
Optional: Set the base URL if using self-hosted Rhesis:
RHESIS_BASE_URL=https://your-rhesis-instance.comCreate the Workflow File
Create .github/workflows/rhesis-tests.yml in your repository. The workflow includes these key steps:
Full workflow file available: See the complete workflow at examples/ci-cd/rhesis-tests.yml
1. Define triggers - Run tests on pushes and pull requests:
2. Set up environment - Install Python and Rhesis SDK:
3. Run tests - Execute the test runner with environment variables from secrets:
The GitHub Actions secret syntax uses ${{ secrets.SECRET_NAME }}. See the complete workflow file for the exact syntax.
4. Upload results - Save test results as artifacts:
Copy the complete workflow file from examples/ci-cd/rhesis-tests.yml to your .github/workflows/ directory.
Create the Test Runner Script
Create .github/scripts/run_rhesis_tests.py. The script follows these key steps:
Full implementation available: See the complete script at examples/ci-cd/run_rhesis_tests.py
Step 1: Get endpoint - Retrieve the endpoint configuration:
Step 2: Get test set - Fetch the test set to execute:
Step 3: Execute test set - Run the test set against the endpoint:
Step 4: Poll for test run - Wait for the test run to appear:
Step 5: Wait for completion - Monitor the test run until it finishes:
Step 6: Get results - Retrieve and analyze test results:
Step 7: Check for failures - Fail the pipeline if any tests failed:
The script includes helper functions for polling, waiting, and result analysis. Copy the complete implementation from examples/ci-cd/run_rhesis_tests.py to your .github/scripts/ directory.
Test Your Integration
-
Copy the files to your repository:
- Copy
examples/ci-cd/rhesis-tests.yml→.github/workflows/rhesis-tests.yml - Copy
examples/ci-cd/run_rhesis_tests.py→.github/scripts/run_rhesis_tests.py
- Copy
-
Commit and push your changes:
- Monitor the workflow in the Actions tab of your GitHub repository.
Customization Options
Adjust Timeouts
Modify timeouts based on your test set size:
Set Failure Threshold
Allow a percentage of test failures:
Run on Specific Events
Run tests only on pull requests to main:
Next Steps
You’re ready to automate LLM testing! Your CI/CD pipeline now catches quality issues before production.
- Learn More: Rhesis SDK Documentation
- Advanced Testing: Building Custom Metrics
- Multi-Turn Testing: Penelope Agent Testing
- Get Help: Join our Discord community
Need help with integration? Reach out on Discord or email support@rhesis.ai.