CircleCI + Bitbucket + Nx (Manual Single-File Integration)
🎯 Goal of This Phase
The purpose of this setup is to:
- Validate CI configuration and permissions
- Ensure Early can run successfully in your environment
- Confirm test generation works end-to-end
- Avoid introducing automation too early
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 pipeline:
- Checks out the repository
- 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 from CircleCI.
🛠️ Example CircleCI Configuration (Nx Workspace)
Below is a complete CircleCI configuration for manual, single-file integration:
version: 2.1
parameters:
target_directory:
type: string
default: ""
description: "Target directory for EarlyAI test generation"
jobs:
earlyai-test-generation:
docker:
- image: cimg/node:22.19
steps:
- checkout
- run:
name: Install dependencies
command: npm ci
- run:
name: Setup environment variables and run EarlyAI
command: |
export NODE_OPTIONS="--max-old-space-size=6144"
export SCM_PROVIDER="bitbucket"
export API_KEY="$EARLY_SECRET_TOKEN"
export REF_NAME="$CIRCLE_BRANCH"
export TOKEN="$BB_ACCESS_TOKEN"
export GIT_USER_EMAIL="$BB_USER_EMAIL"
export TEST_COMMAND="nx test --skip-nx-cache --coverage=false \$early_filename --json --silent"
export COVERAGE_COMMAND="nx test --skip-nx-cache --coverage --coverageProvider=v8 --coverageReporters=json --coverageDirectory=\$early_coverage_dir --silent --passWithNoTests"
export TARGET_DIRECTORY="<< pipeline.parameters.target_directory >>"
npx @earlyai/cli generate-project
workflows:
earlyai-workflow:
when: << pipeline.parameters.target_directory >>
jobs:
- earlyai-test-generation:
context: early
🔐 Required Secrets & Context
This example assumes the following environment variables are provided via a CircleCI context or project settings:
EARLY_SECRET_TOKEN– Early API keyBB_ACCESS_TOKEN– Bitbucket repository access tokenBB_USER_EMAIL– Email used for commits
✅ 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 pipeline completes without errors
- Logs show coverage analysis and test generation steps
Once validated, you can safely move on to automated PR-based workflows.
🔁 Next Step
Proceed to Phase 2 and enable automated test generation:
This guide follows the general Integration Guide and adapts it specifically for CircleCI, Bitbucket, and Nx workspaces.