Skip to main content

CI/CD Integrations

GitHub Action

CodeBeaver can be triggered by a GitHub Action to automatically generate unit tests for your code changes. The action analyzes your code changes and creates comprehensive test suites, helping maintain high test coverage with minimal effort. To get started, follow these steps:

  1. After you signed up for CodeBeaver, get your CodeBeaver API key from the Team page.

  2. Add the API key to your repository's secrets:

    • Go to your repository's Settings
    • Navigate to Secrets and Variables > Actions
    • Create a new secret named CODEBEAVER_API_KEY
  3. Create a workflow file (e.g., .github/workflows/codebeaver.yml):

For Pull Requests

name: CodeBeaver Test Generation on PR

on:
pull_request:
types: [opened, synchronize, reopened]

jobs:
generate-tests:
runs-on: ubuntu-latest
steps:
- uses: codebeaver-ai/codebeaver-action@v0.1.0
with:
api-key: ${{ secrets.CODEBEAVER_API_KEY }}
action-type: "analyze-and-generate"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

For Push Events

name: CodeBeaver Test Generation on Push

on:
push:
branches: [main, develop] # Customize branches as needed

jobs:
generate-tests:
runs-on: ubuntu-latest
steps:
- uses: codebeaver-ai/codebeaver-action@v0.1.0
with:
api-key: ${{ secrets.CODEBEAVER_API_KEY }}
action-type: "analyze-and-generate"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

The action supports different operation modes through the action-type parameter:

  • analyze: Analyzes changes and provides test results and bug detection analysis as a PR comment
  • analyze-and-generate: Does everything analyze does, plus generates test files and creates a new PR with the changes
  • dry-run: Performs analysis and shows what would be generated without making any changes

You can customize the behavior with these parameters:

InputDescriptionRequiredDefault
api-keyCodeBeaver API KeyYesN/A
action-typeType of action to performNo"analyze-and-generate"
repositoryRepository in owner/repo formatNoCurrent repository
pr-numberPull request numberNoCurrent PR number (empty for push events)
commit_shaCommit SHA to analyzeNoCurrent commit SHA

For example, to analyze a specific PR in another repository:

- uses: codebeaver-ai/codebeaver-action@v0.1.0
with:
api-key: ${{ secrets.CODEBEAVER_API_KEY }}
repository: "octocat/Hello-World"
pr-number: "123"
action-type: "analyze-and-generate"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Check out the README in the GitHub Action repo for more information.

CI integrations roadmap

We are working on adding CI integrations for:

  • Jenkins
  • GitLab CI
  • Azure DevOps
  • CircleCI
  • Bitbucket Pipelines

If you need a specific CI integration, please let us know in the Discord server or contact us at info@codebeaver.ai.