Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

Test Impact Analyzer Agent

A smart GitHub webhook service that analyzes pull requests to determine which tests should be run based on code changes. The agent uses AI to understand code dependencies and suggest relevant tests.

Features

  • GitHub webhook integration for pull request events
  • Intelligent test impact analysis
  • Automatic PR comments with analysis results
  • Support for multiple programming languages
  • Configurable via environment variables

Overall Architecture

+------------------+    +------------------+    +------------------+
|  GitHub Webhook  |--->|    AI Agent      |--->|   Test Runner    |
|   (PR Events)    |    |(Direct Git API)  |    |  (pytest/jest)   |
+------------------+    +------------------+    +------------------+
                               |
                       +------------------+
                       |   Local Git +    |
                       |   GitHub API     |
                       +------------------+
                               |
                       +------------------+
                       |  Ollama (Local   |
                       |      LLM)        |
                       +------------------+

Prerequisites

System Requirements

  • Python 3.8 or higher
  • Git 2.x or higher
  • Node.js 16+ (for JavaScript/TypeScript projects)
  • Docker (optional, for containerized deployment)
  • 8GB RAM minimum (16GB recommended for Ollama LLM)
  • Operating System:
    • Linux (Ubuntu 20.04+, CentOS 7+)
    • macOS (Big Sur or newer)
    • Windows 10/11 with WSL2
  • Disk Space:
    • 5GB for base installation
    • 4GB+ for Ollama models
    • Additional space for analyzed repositories

Ollama Setup

  1. Install Ollama:
# macOS and Linux
curl -fsSL https://ollama.com/install.sh | sh

# Windows
# Download from https://ollama.com/download/windows
  1. Pull the required model:
ollama pull qwen2.5-coder:7b
  1. Update your .env file with Ollama configuration:
OLLAMA_HOST=http://localhost:11434
OLLAMA_MODEL=qwen2.5-coder:7b
  1. Verify Ollama is running:
curl http://localhost:11434/api/health

Note: Ensure Ollama is running before starting the webhook server.

Agent Installation and Configurations

  1. Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate
  1. Set up environment variables in .env:
# GitHub token with minimal scope (pull_request:write) for PR comments
GITHUB_TOKEN=your_github_token

# Server configuration (optional, defaults shown)
PORT=5043
HOST=0.0.0.0
DEBUG=False
Note: For security best practices, limit the GitHub token scope to only `pull_request:write` access. Here's how to create a token with minimal permissions:

1. Go to GitHub Settings > Developer Settings > Personal access tokens > Fine-grained tokens
2. Click "Generate new token"
3. Set token name (e.g., "Test Impact Analyzer")
4. Set expiration date
5. Select the specific repository you want to analyze
6. Under "Repository permissions":
   - Pull requests: Access level "Write"
   - Leave all other permissions unchecked
7. Click "Generate token"
8. Copy the token and add it to your `.env` file
  1. Install agent from PyPI (Recommended)
pip install test-impact-analyzer
  1. Install ngrok (this is required for configuring Github Webhook for listening to PR events):
# macOS with Homebrew
brew install ngrok

# Windows with Chocolatey
choco install ngrok

# Or download from https://ngrok.com/download
  1. In a new terminal, create a public URL with ngrok (note down the public URL):
ngrok http 5043
  1. Configure your GitHub repository webhook:
    • Copy the ngrok URL from previous step (e.g., https://a1b2-c3d4.ngrok.io)
    • Navigate to your Github Repo => Settings => Webhooks
    • Webhook URL: https://your-ngrok-url/webhook
    • Events: Select "Pull requests"
    • Content type: application/json
    • Secret: Leave empty for testing
    💡 Want to know more about creating Github Webhooks, refer official documentation here: https://docs.github.com/en/webhooks/using-webhooks/creating-webhooks
    

Note: The ngrok URL changes each time you restart ngrok. Update your webhook URL in GitHub repository settings accordingly.

Usage

Following the instructions given in Agent Installation and Configurations section, AI Agent is ready to use

Running as a Webhook Server

  1. Start the server:
test-impact-analyzer

The server will automatically:

  • Analyze new pull requests (created/reopened in your project in Github)
  • Comment with test recommendations
  • Update analysis when PRs are updated

Limitations/Upcoming Features

  • Currently it Supports Python and Node JS projects only.
  • For Node JS projects the Runner for tests is configured as npm test. More will be added soon

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a Pull Request

License

MIT License - see LICENSE file for details

Metadata

Release files for test-impact-analyzer 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for test-impact-analyzer 0.2.0
File Size Uploaded Provenance
test_impact_analyzer-0.2.0.tar.gz 15.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for test-impact-analyzer 0.2.0
File Interpreter ABI Platform
test_impact_analyzer-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 28.1 kB

Release files / test_impact_analyzer-0.2.0.tar.gz

Download URL test_impact_analyzer-0.2.0.tar.gz
Size 15.5 kB
Tags Source
SHA-256 checksum
How to use checksums
309edf277d31481f3bb5deb00977a01f8affd604878d63e7fdb23f05d53758ef
BLAKE2b-256 checksum
How to use checksums
b198e9097c38c5a46904cfe6f16139bfe2c4fa6b3f5057305694294ab611873c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / test_impact_analyzer-0.2.0-py3-none-any.whl

Download URL test_impact_analyzer-0.2.0-py3-none-any.whl
Size 12.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51c5fd0fa0ef8affc0b255a68a3b01037e647b1bdd050b5da5b268a16fd0d214
BLAKE2b-256 checksum
How to use checksums
5777b08a8b50bb23d660b86e9059b7c143b549f9f1899f3a7f903d83b8913c39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Security for test-impact-analyzer 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page