This guide explains how to test the web-code-reviewer GitHub Action locally on your machine.
The action uses standard git commands to get file changes:
# Get list of changed files
git diff --name-only --diff-filter=AMRC origin/master...HEAD
# Get full diff for each file
git diff origin/master...HEAD --unified=10 -- "path/to/file.js"This works exactly the same locally and in GitHub Actions!
-
Git repository with:
- A branch with committed changes
- Remote configured (usually
origin) - Base branch fetched from remote
-
Node.js installed (v20 or higher)
-
API Key for your chosen LLM provider:
- Claude: Get from https://console.anthropic.com/
- OpenAI: Get from https://platform.openai.com/
npm install
npm install --save-dev dotenv# Copy example file
cp .env.local.example .env.local
# Edit with your API keys
nano .env.local # or use your favorite editorMinimal .env.local:
CLAUDE_API_KEY=sk-ant-api03-your-actual-key-here# Make sure you're on a branch (not master)
git checkout -b test/local-review
# Make some changes
echo "console.log('test');" >> src/services/test.js
git add src/services/test.js
git commit -m "test: add test file"
# Verify changes exist
git diff --name-only origin/master...HEAD# Run with default settings
node scripts/test-local.js
# Or with custom configuration
LANGUAGE=python BASE_BRANCH=develop node scripts/test-local.jsYou can override any setting using environment variables:
# Use OpenAI instead of Claude
LLM_PROVIDER=openai node scripts/test-local.js
# Review Python code
LANGUAGE=python node scripts/test-local.js
# Different base branch
BASE_BRANCH=develop node scripts/test-local.js
# Custom path
PATH_TO_FILES=packages/ node scripts/test-local.js
# Combine multiple options
LANGUAGE=python PATH_TO_FILES=backend/ BASE_BRANCH=main node scripts/test-local.js| Variable | Default | Description |
|---|---|---|
LLM_PROVIDER |
claude |
LLM provider (claude or openai) |
LANGUAGE |
js |
Language to review (js, python, java, php, swift, qa_web, qa_android, qa_backend) |
PATH_TO_FILES |
src/ |
Path to files to review |
BASE_BRANCH |
master |
Base branch to compare against |
MAX_TOKENS |
8000 |
Maximum tokens for LLM response |
TEMPERATURE |
0 |
Temperature (0 for deterministic) |
TEAM |
test-team |
Team name |
DEPARTMENT |
engineering |
Department name |
-
Validates environment:
- Checks if you're in a git repo
- Verifies base branch exists
- Checks for API keys
- Detects changes to review
-
Sets up GitHub Actions environment:
- Configures all required environment variables
- Mimics GitHub Actions context
- Sets input parameters
-
Runs the action:
- Executes
src/index.jsdirectly - Uses real git commands on your repo
- Processes your actual code changes
- Calls the LLM API with your diff
- Executes
-
Shows results:
- Prints review output to console
- Shows what would be posted as PR comment
- Indicates if merge would be blocked
# Make sure you're in the repo root
cd /path/to/web-code-reviewer
pwd # Should show repo directory# Fetch the base branch
git fetch origin master
# Verify it exists
git branch -r | grep master# Check what git sees
git diff --name-only origin/master...HEAD
# If empty, make sure you have commits
git log --oneline -5
# And that you're not on master
git branch --show-current# Make sure .env.local exists and has your key
cat .env.local
# Key should start with sk-ant-
# Example: CLAUDE_API_KEY=sk-ant-api03-xxxxx# Your API key is invalid
# Get a new one from https://console.anthropic.com/
# Update .env.local with the new key# Check what files changed
git diff --name-only origin/master...HEAD
# Make sure they match your language
# For JS: files should end in .js, .jsx, .ts, .tsx
# Change language if needed: LANGUAGE=python node scripts/test-local.js# Test with minimal changes
git checkout -b test/small-change
echo "// comment" >> src/index.js
git commit -am "test: small change"
node scripts/test-local.js
# Test with multiple files
git checkout -b test/multi-file
# ... edit multiple files ...
git commit -am "test: multiple changes"
node scripts/test-local.js
# Test with security issues
git checkout -b test/security
echo "eval(userInput)" >> src/dangerous.js
git commit -am "test: security issue"
node scripts/test-local.js# Test with Claude
LLM_PROVIDER=claude node scripts/test-local.js > claude-output.txt
# Test with OpenAI (make sure OPENAI_API_KEY is set)
LLM_PROVIDER=openai node scripts/test-local.js > openai-output.txt
# Compare outputs
diff claude-output.txt openai-output.txt# Run twice and compare (should be identical)
node scripts/test-local.js > run1.txt
node scripts/test-local.js > run2.txt
diff run1.txt run2.txt # Should show no differencesThe script shows:
- Configuration - Settings being used
- Git diff command - What git command is executed
- File detection - Which files will be reviewed
- LLM interaction - Chunks being processed
- Review results - Issues found
- Merge decision - Whether PR would be blocked
- Never commit
.env.local- It contains your API keys! .gitignorealready excludes it- Use
.env.local.exampleas a template only - Rotate keys if accidentally committed
- See
src/services/file-service.jsfor git diff logic - See
src/services/llm-service.jsfor LLM interaction - See
src/services/review-service.jsfor merge decision logic - Run tests:
npm test - Check code quality:
npm run lint
If you encounter issues:
- Check prerequisites are met
- Review troubleshooting section
- Verify your
.env.localis correct - Check git state:
git statusandgit log - Try with a fresh test branch
For persistent issues, check the GitHub Actions logs to see how it runs in CI.