Skip to content

raakeshdev20/karate-change-impact-test

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Intelligent Cross-Repository CI Optimization System using Impact-Based Test Selection

Status Java Spring Boot Karate

⚑ Problem Statement

Modern CI pipelines often execute full regression suites even when code changes are small and localized.

This causes:

  • unnecessary compute cost
  • slower feedback loops
  • inefficient CI resource usage
  • delayed developer productivity

especially in microservice architectures with multiple repositories.


🧠 Key Idea

Transform Git changes into targeted test execution plans using deterministic impact mapping.

Instead of running full regression suites, the system dynamically executes only impacted Karate tests while maintaining baseline safety coverage through fallback smoke tests.


πŸ“Š Controlled Scenario Results

Execution Mode Runtime
Full Regression 52s
Impact-Based Execution 18s
Reduction Observed 66%

βš™οΈ Core Capabilities

  • πŸ” Cross-repository CI orchestration using GitHub Repository Dispatch
  • πŸ” JGit-based file-level Git diff analysis
  • 🧠 Rule-based impact mapping (code β†’ test tags)
  • πŸ§ͺ Dynamic Karate test selection at runtime
  • πŸ›‘οΈ Safe fallback execution using @smoke
  • πŸ“Š CI execution metrics generation

πŸ— Architecture

Dev Repository (fintech-impact-services)
        β”‚
        β”‚ Push Event
        β–Ό
GitHub Repository Dispatch
        β–Ό
Automation Repository (karate-change-impact-test)
        β”‚
        β”œβ”€β”€ Start Spring Boot App in CI
        β”œβ”€β”€ Wait for API readiness (log + HTTP check)
        β”œβ”€β”€ Call Impact API (/test-selector)
        β”œβ”€β”€ JGit-based Impact Analysis
        β”œβ”€β”€ Generate Test Tags
        β”œβ”€β”€ Run Karate Tests (tag-based)
        └── Generate Execution Metrics

πŸ” Workflow

1. Code Push (Dev Repo)

Trigger:

yaml

on: [push]

Dispatch event:

bash

POST /repos/{owner}/karate-change-impact-test/dispatches
{
  "event_type": "dev_push"
}

2. CI Pipeline Startup (Test Repo)

Steps executed in GitHub Actions:

  • Checkout both repositories
  • Start Spring Boot application
  • Wait for API readiness (log + HTTP check)

3. Impact Analysis (Spring Boot Service)

Endpoint:


HTTP GET /api/dev-ops/test-selector?targetBranch=main~1

Logic:

  • Uses JGit diff analysis
  • Maps changed files β†’ test tags

πŸ“Š Mapping Rules

Change Type Test Tag
/payments/ @payments
/transactions/ @transactions
/transfer/ @transfers
/auth/ @regression
pom.xml @regression
No match @smoke

πŸ§ͺ Test Execution

mvn test -Dkarate.options="--tags @payments,@transactions"

Safe Fallback

If no impacted tests are detected:

bash

@smoke

πŸ“ˆ Metrics Output

File:

metrics.json

Example:

json

{
  "impacted_tags": "@payments,@transactions",
  "scenarios_executed": 6,
  "scenarios_skipped": 12,
  "test_reduction_rate": "66%",
  "timing_metrics": {
    "total_workflow_seconds": 52,
    "isolated_test_seconds": 18,
    "api_overhead_seconds": 6
  }
}

πŸ§ͺ Karate Test Structure


features/
 β”œβ”€β”€ payments.feature
 β”œβ”€β”€ transactions.feature
 β”œβ”€β”€ transfers.feature
 └── smoke.feature

βš™οΈ Setup Guide

Prerequisites Java 17 Maven GitHub Actions enabled

GitHub Secrets

KARATE_REPO_PAT

πŸš€ Run Locally

Start Spring Boot service:


bash

mvn spring-boot:run

Call API:

bash

curl http://localhost:8080/api/dev-ops/test-selector

Run tests:

bash

mvn test -Dkarate.options="--tags @smoke"

πŸ“Š Key Benefits

  • ⏱ Demonstrated up to 60–70% CI runtime reduction in controlled scenarios
  • πŸ’° Reduced unnecessary regression execution and CI compute usage
  • πŸš€ Faster developer feedback cycles through selective test execution
  • πŸ” Minimized redundant test runs using deterministic impact mapping
  • πŸ§ͺ Maintained baseline regression safety using fallback smoke coverage
  • πŸ”— Enabled cross-repository CI orchestration using GitHub Actions

πŸ“Œ Why This Matters

In large-scale systems with multiple services and repositories, CI pipelines become a major bottleneck. Running full regression suites for every change leads to:

  • High infrastructure cost
  • Slow developer feedback cycles
  • Inefficient resource utilization

This system demonstrates a practical approach to impact-aware CI execution without requiring complex dependency graphs or external SaaS tooling.

πŸ‘¨β€πŸ’» Author

Designed and implemented a cross-repository DevOps intelligence framework that enables impact-based test selection, reducing full regression execution by dynamically running only affected Karate tests based on Git diff analysis.

About

karate test execution based on fintech impact services repo file changes

Topics

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors