GitHub Actions + GitHub – Manual Single-File Integration
This guide shows how to run the Early Agent using GitHub Actions for a GitHub repository, generating tests for a single file using the generate-for-project command.
This workflow is intended for initial integration and validation, before enabling automated PR- or commit-based test generation.
🎯 Goal of This Phase
The purpose of this setup is to:
- Validate GitHub Actions configuration and permissions
- Ensure Early can run successfully in your repository
- Confirm test generation works end-to-end
- Explicitly control the test framework used for generation
Test generation is intentionally scoped to one medium-sized file
(not too small to be trivial, and not too large to complicate validation).
🧩 How It Works
At a high level, this workflow:
- Checks out the repository
- Sets up Node.js
- Configures npm authentication
- Installs project dependencies
- Sets required environment variables
- Runs
early generate-for-projecton a single file - Commits generated tests to the specified branch
Execution is manually triggered using GitHub Actions.
🛠️ Example GitHub Actions Workflow
Below is a complete GitHub Actions workflow for manual, single-file integration:
name: early-single-file-integration
on:
workflow_dispatch:
jobs:
early-single-file:
runs-on: ubuntu-latest
permissions:
contents: write
packages: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm clean-install
- name: Install @earlyai/cli
run: npm install -g @earlyai/cli
- name: Generate tests (single file)
env:
API_KEY: ${{ secrets.EARLY_API_KEY }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
SCM_PROVIDER: github
TARGET_DIRECTORY: src/path/to/file.ts
REF_NAME: ${{ github.ref_name }}
TEST_FRAMEWORK: jest
NODE_OPTIONS: --max-old-space-size=5120
run: early generate-for-project
🔐 Required Secrets
This workflow assumes the following secrets are configured in your repository:
EARLY_API_KEY– Early API key
The built-in GITHUB_TOKEN is used for:
- Repository access
- Committing generated test files
- npm package authentication
✅ Success Criteria
This phase is considered successful when:
- Test files are generated for the selected file
- Generated tests are committed to the target branch
- The workflow completes without errors
- Logs show coverage analysis and test generation steps
Once validated, you can safely move on to automated workflows.
🔁 Next Step
Proceed to Phase 2 and enable automated test generation on pull requests or commits.
This guide follows the general Integration Guide and adapts it specifically for GitHub Actions and GitHub.