Skip to main content

πŸ”— Integrating the GitHub PR Agent

This guide shows how to integrate the GitHub PR Agent into your GitHub Actions workflow to automatically generate and commit unit tests for pull requests.


⚠️ Requirements​

Before setting up the workflow:


🧩 GitHub Actions Example​

name: Early PR Test Generation

permissions:
contents: write
pull-requests: write

on:
pull_request:
types:
- opened
- reopened
branches:
- master

jobs:
early-test-generation:
runs-on: ubuntu-latest
steps:
- name: Checkout target repo
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Install dependencies
run: npm install

- name: Early PR Unit Test Generation Agent
id: early
uses: earlyai/pull-request-test-generation@v1
continue-on-error: true
env:
NODE_OPTIONS: "--max-old-space-size=5120"
with:
api-key: ${{ secrets.EARLY_SECRET_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

πŸ“Œ Event Type Guidance​

Choose a pull request trigger based on your team’s flow:

Event TypeWhen It RunsRecommended If...
openedWhen the PR is first createdDevs open PRs only after finishing work
ready_for_reviewWhen a draft PR is marked as readyDevs use draft PRs during development
synchronizeWhen commits are pushed to the PR branchYou want tests generated on every new commit

⚠️ The agent checks all uncovered functions at 0% coverage every time it's triggered.
It does not persist state between runs.



🧡 Next Steps​