This GitHub Action runs CodeBeaver tests in your CI/CD pipeline. CodeBeaver is an open-source testing automation tool that leverages AI to simplify the testing process.
- 🤖 Run end-to-end tests using natural language descriptions
- 🧪 Generate and maintain unit tests automatically for your codebase
- 🐛 Detect potential bugs and provide detailed fix explanations
- ⚡ Reduce testing overhead while improving code quality
name: Run CodeBeaver Tests
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run CodeBeaver Tests
uses: codebeaver-ai/codebeaver-action@v1
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
name: CodeBeaver Testing
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
# Optional: Run E2E tests on release
release:
types: [published]
jobs:
unit-tests:
name: Run Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run CodeBeaver Unit Tests
uses: codebeaver-ai/codebeaver-action@v1
with:
action-type: "unit"
max-files-to-test: "20"
verbose: "true"
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
e2e-tests:
name: Run E2E Tests
runs-on: ubuntu-latest
# Only run E2E tests on release or when explicitly requested
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Run CodeBeaver E2E Tests
uses: codebeaver-ai/codebeaver-action@v1
with:
action-type: "e2e"
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
STARTING_URL: "https://staging.example.com" # Optional: override URL from config
Input | Description | Required | Default |
---|---|---|---|
action-type |
Type of tests to run (unit , e2e , or both ) |
No | both |
file-path |
Path to the file to analyze for unit tests | No | |
config-file |
Path to the YAML configuration file | No | codebeaver.yml |
template |
Testing framework template (e.g., pytest, jest) | No | |
max-files-to-test |
Maximum number of files to test | No | 10 |
verbose |
Enable verbose logging output | No | false |
open-pull-request |
Whether to open a pull request with the changes | No | true |
github-token |
GitHub token for authentication. If not provided, GITHUB_TOKEN will be used | No |
Variable | Description | Required |
---|---|---|
OPENAI_API_KEY |
Your OpenAI API key | Yes |
STARTING_URL |
Override the base URL for E2E tests | No |
Create a codebeaver.yml
file in the root of your repository:
# Unit test configuration
unit:
from: pytest # The unit testing framework you want to use
# E2E test configuration
e2e:
login-test: # Name of the test
url: "https://your-app-url.com" # Starting URL
steps:
- "Navigate to the login page"
- "Enter 'testuser' in the username field"
- "Enter 'password123' in the password field"
- "Click the 'Login' button"
- "Check that the dashboard page is displayed"
Add your OpenAI API key as a secret in your GitHub repository:
- Go to your repository on GitHub
- Click on "Settings" > "Secrets and variables" > "Actions"
- Click on "New repository secret"
- Name:
OPENAI_API_KEY
- Value: Your OpenAI API key
- Click "Add secret"
This action uses peter-evans/create-pull-request to create a pull request with the updated Unit Tests. Otherwise, follow peter's instructions to create a GitHub token and add it as a secret in your repository.
CodeBeaver currently supports:
- Python with pytest
- TypeScript/JavaScript with jest or vitest
This project is licensed under the AGPL-3.0 License - see the LICENSE file for details.