Skip to content

kevilkhadka/FlakeSpy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ•΅οΈ FlakeSpy

Automatically detects flaky tests in your nightly GitLab CI pipeline β€” no branch push required.

Java Spring Boot React PostgreSQL Groq AI GitLab Vite


πŸ“Œ What is FlakeSpy?

Flaky tests are the silent killers of QA confidence. A test that passes sometimes and fails sometimes is worse than no test at all β€” it trains your team to ignore failures.

FlakeSpy fixes that β€” without touching your main branch.

FlakeSpy connects to your GitLab project using a personal access token, pulls the JUnit XML artifacts from your nightly CI pipeline automatically every morning, and builds a living picture of your test suite health:

  • πŸ† Flakiness leaderboard β€” ranked list of your most unreliable tests
  • πŸ“ˆ 30-night trend chart β€” pass/fail history + duration over time
  • πŸ€– AI root cause classification β€” timing? locator? data dependency?
  • πŸ”§ Fix suggestions β€” specific, actionable advice per flaky test
  • πŸ”„ Fully automatic β€” no CI changes, no push to main, just a GitLab personal token
  • πŸ” Test detail page β€” deep dive into any test's full history and AI analysis

🧱 Tech Stack

Layer Technology
Frontend React 18, Vite 5, Axios, Recharts
Backend Java 17, Spring Boot 3.2.3
AI Engine Groq API (LLaMA 3)
Database PostgreSQL 15
GitLab Integration GitLab REST API v4
Scheduler Spring @Scheduled (runs at 6am daily)
XML Parsing JAXB / Java DOM Parser
ZIP Extraction Apache Commons Compress
Build Maven

πŸ“ Project Structure

flakespy/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ src/main/java/com/flakespy/
β”‚   β”‚   β”œβ”€β”€ controller/
β”‚   β”‚   β”‚   β”œβ”€β”€ GitLabController.java
β”‚   β”‚   β”‚   β”œβ”€β”€ TestController.java
β”‚   β”‚   β”‚   └── DashboardController.java
β”‚   β”‚   β”œβ”€β”€ service/
β”‚   β”‚   β”‚   β”œβ”€β”€ GitLabService.java
β”‚   β”‚   β”‚   β”œβ”€β”€ XmlParserService.java
β”‚   β”‚   β”‚   β”œβ”€β”€ FlakinessAnalyserService.java
β”‚   β”‚   β”‚   β”œβ”€β”€ GroqAIService.java
β”‚   β”‚   β”‚   └── NightlyScheduler.java
β”‚   β”‚   β”œβ”€β”€ model/
β”‚   β”‚   β”‚   β”œβ”€β”€ GitLabProject.java
β”‚   β”‚   β”‚   β”œβ”€β”€ TestRun.java
β”‚   β”‚   β”‚   └── TestResult.java
β”‚   β”‚   β”œβ”€β”€ repository/
β”‚   β”‚   β”‚   β”œβ”€β”€ GitLabProjectRepository.java
β”‚   β”‚   β”‚   β”œβ”€β”€ TestRunRepository.java
β”‚   β”‚   β”‚   └── TestResultRepository.java
β”‚   β”‚   β”œβ”€β”€ dto/
β”‚   β”‚   β”‚   β”œβ”€β”€ GitLabConnectRequest.java
β”‚   β”‚   β”‚   β”œβ”€β”€ FlakyTestSummary.java
β”‚   β”‚   β”‚   β”œβ”€β”€ TestAnalysis.java
β”‚   β”‚   β”‚   └── DashboardSummary.java
β”‚   β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”‚   └── CorsConfig.java
β”‚   β”‚   └── FlakespyApplication.java
β”‚   β”œβ”€β”€ src/main/resources/
β”‚   β”‚   β”œβ”€β”€ application.yml
β”‚   β”‚   └── application-local.yml   ← gitignored, your secrets
β”‚   └── pom.xml
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ GitLabConnect.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ SuiteHealthBadge.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ FlakyLeaderboard.jsx
β”‚   β”‚   β”‚   └── TrendChart.jsx
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx
β”‚   β”‚   β”‚   └── TestDetail.jsx
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── flakespyApi.js
β”‚   β”‚   β”œβ”€β”€ App.jsx
β”‚   β”‚   β”œβ”€β”€ main.jsx
β”‚   β”‚   └── index.css
β”‚   └── package.json
β”‚
β”œβ”€β”€ .gitignore
└── README.md

πŸš€ Getting Started

Prerequisites

  • Java 17+
  • Node.js 20+
  • PostgreSQL 15+
  • Maven 3.8+
  • A free Groq API key
  • A GitLab personal access token with read_api scope

1. Generate your GitLab personal access token

  1. Log in to GitLab
  2. Go to Settings β†’ Access Tokens
  3. Create a token with read_api scope
  4. Copy the token β€” you'll paste it into FlakeSpy on first launch

No admin access needed. No push permissions needed. Read-only is enough.

2. Clone the repository

git clone https://github.com/YOUR_USERNAME/flakespy.git
cd flakespy

3. Set up the database

psql -U your_username -d postgres -c "CREATE DATABASE flakespy;"

4. Configure the backend

Create backend/src/main/resources/application-local.yml β€” this file is gitignored:

DB_USERNAME: your_postgres_username
DB_PASSWORD:
GROQ_API_KEY: your_groq_api_key

5. Run the backend

cd backend
mvn spring-boot:run

Spring Boot auto-creates all 3 PostgreSQL tables on first run. Backend starts on http://localhost:8080.

6. Run the frontend

cd frontend
npm install
npm run dev

Frontend starts on http://localhost:5173.

7. Connect your GitLab project

Open http://localhost:5173 and fill in the connect form:

  • GitLab project ID β€” found in GitLab β†’ Settings β†’ General
  • Project name β€” any display name you choose
  • Personal access token β€” the read_api token you created
  • CI job name β€” the job in your .gitlab-ci.yml that produces XML artifacts
  • GitLab URL β€” https://gitlab.com or your self-hosted URL

FlakeSpy immediately pulls your last 30 nightly runs and builds your first flakiness report.


πŸ”Œ API Endpoints

Method Endpoint Description
POST /api/gitlab/connect Connect a GitLab project
POST /api/gitlab/sync/{id} Manually trigger artifact pull
GET /api/gitlab/projects List connected projects
DELETE /api/gitlab/projects/{id} Disconnect a project
GET /api/tests/flaky?projectId=1 Flakiness leaderboard
GET /api/tests/{name}/history 30-night pass/fail history
GET /api/tests/{name}/analysis AI root cause + fix suggestion
GET /api/dashboard/summary?projectId=1 Suite health summary

πŸ” How the GitLab API integration works

FlakeSpy uses the GitLab REST API v4 β€” no pipeline changes needed:

GET /api/v4/projects/:id/jobs?scope=success
Authorization: Bearer YOUR_PERSONAL_TOKEN

Then downloads artifacts for each nightly job:

GET /api/v4/projects/:id/jobs/:job_id/artifacts

NightlyScheduler runs this automatically every morning at 6am after your nightly pipeline finishes. You can also trigger a manual sync anytime from the dashboard.


🧠 Flakiness score explained

flakiness_score = status_flips / (total_runs - 1)
Score Label Action
0.0 – 0.2 🟒 Stable No action needed
0.2 – 0.5 🟑 Unstable Monitor closely
0.5 – 0.8 🟠 Flaky Fix soon
0.8 – 1.0 πŸ”΄ Broken Fix immediately

πŸ€– AI root cause categories

Category Typical symptom
TIMING TimeoutException, StaleElementException
LOCATOR NoSuchElementException intermittently
DATA_DEPENDENCY Fails after another test, passes in isolation
NETWORK Connection timeouts, session drops
CONCURRENCY Fails in parallel runs only
ENVIRONMENT Fails on specific device/OS only

πŸ—ΊοΈ Roadmap

  • Project setup and architecture
  • Spring Boot REST API
  • PostgreSQL β€” 3 tables auto-created
  • GitLab API integration
  • JUnit XML parser
  • Flakiness score algorithm
  • Nightly scheduler (6am auto-sync)
  • Groq AI root cause classification
  • React frontend
  • GitLab connect form
  • Suite health dashboard
  • Flakiness leaderboard with filters
  • 30-night trend chart
  • Test detail + AI analysis page
  • Allure JSON format support
  • Email alerts for new broken tests
  • Multi-project support

πŸ‘€ Author

Kevil β€” QA Engineer learning full-stack development Project 2 of my coding journey | Built from a real pain I face every single night


πŸ“„ License

MIT License


πŸ’‘ Part of the QA Tools ecosystem:

About

utomatically detects flaky tests in your nightly GitLab CI pipeline

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages