feat: add CI/CD integration with webhook support and automated alerts#5400
feat: add CI/CD integration with webhook support and automated alerts#5400anshul23102 wants to merge 7 commits into
Conversation
|
@anshul23102 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
GSSoC 2026 ContributionThis PR addresses issue #4991 as part of the GSSoC 2026 program. The implementation provides a complete CI/CD integration solution with webhook support and automated insights. Architecture Highlights:
Ready for Merge
Label Request: Upon approval, please add the gssoc-approved label to recognize this GSSoC 2026 contribution. Thank you for reviewing this enhancement! |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for the PR. Adding CI/CD webhooks and automated alerts is a massive and valuable feature. Applied labels: \level:advanced\ (multi-part feature), \ ype:devops, \ ype:feature, \quality:clean.
Aamod-Dev
left a comment
There was a problem hiding this comment.
I noticed the CI checks (Vercel, Production Build) are currently failing on this branch. Please take a look at the logs and fix the build issues so we can get this merged. (Labels applied previously)
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for building out the CI/CD webhook alerts integration! Adding automated deployment notifications is a fantastic feature.
However, I noticed a couple of critical issues that need to be addressed before merging:
- Security Vulnerability: The
POST /api/cicd/alertsroute currently accepts unauthenticated requests. Anyone on the internet could theoretically hit this endpoint and modify alert configurations for any repository, potentially causing alert spam or extracting webhook payloads. You must add proper authentication (e.g., validating a secret token or checking session auth) before callingsetAlertConfig. - CI Divergence: The CI pipeline will automatically fail due to an unrelated test divergence in
lib/svg/themes.test.tsthat recently occurred natively on themainbranch.
Please add proper authentication to the route, run git pull --rebase origin main to resolve the test divergence, and force push your branch. I'll review again once it's secure!
Labels Applied:
level:advanced: New API integration with auth requirements.type:security: Security vulnerability identified.quality:needs-improvement: Missing route authentication.mentor:Aamod007
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for the contribution. I went through the changes and the overall approach looks good.
Aamod-Dev
left a comment
There was a problem hiding this comment.
This PR is currently marked with the \status:blocked\ label. Please resolve the blockers so we can proceed with a full review and approval.
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for the contribution! I went through the changes and have evaluated them according to the rubric.
Aamod-Dev
left a comment
There was a problem hiding this comment.
Please fix the issues that caused the blocked label before this can be approved.
Aamod-Dev
left a comment
There was a problem hiding this comment.
This PR is currently blocked due to a failing CI check or other blocking issues. Please fix the blocking issues so we can proceed with the review and approval process.
✅ CI/CD Linting Issues ResolvedI've fixed the blocking linting error that was preventing CI checks from passing: Change Made:
Status:
Suggested Labels:
The CI checks should now pass. Ready for maintainer review and approval. |
✅ Merge Conflict ResolvedI've resolved the merge conflict in What was done:
Status:
The PR is now ready for CI validation. |
Update: Linting Errors Fixed ✅Local verification complete:
Remaining CI failures are pre-existing issues:
Recommendation: Could we retrigger the CI to ensure latest changes are evaluated? |
b865238 to
d1d8651
Compare
📦 Next.js Bundle Size Report (Gzipped Sizes)
📊 Summary of Totals
|
|
✅ Fixed CodeQL security vulnerability: Replaced vulnerable string comparison with timing-safe token comparison (crypto.timingSafeEqual) in CICD alerts endpoint to prevent timing attacks. CI should now pass. |
Aamod-Dev
left a comment
There was a problem hiding this comment.
The CI/CD integration is ambitious, but there are a couple of concrete issues that need to be fixed before merge. services/github/webhook-handler.ts is constructed with DistributedCache in a way that does not match the existing cache helper API, and setAlertConfig / cacheEvent call async cache methods without awaiting them. Please align the cache abstraction with lib/cache.ts, await the cache writes, and add a small end-to-end test around the webhook and report flow.
Implement comprehensive CI/CD integration enabling automated pipeline monitoring and insights: - Webhook Handler: Parse and process GitHub Actions workflow and check_run events - Event Caching: Cache CI events for historical analysis and trending - Alert System: Configure per-repository alerts for pipeline failures and successes - Report Generation: Daily/weekly/monthly CI pipeline reports with success rates - Webhook Security: GitHub signature verification for incoming webhook payloads New Services: - services/github/webhook-handler.ts: Core CI/CD event processing and alerting New API Endpoints: - POST /api/webhooks/cicd: Receive and process GitHub webhook events - GET/POST /api/cicd/alerts: Configure failure/success alerts with webhooks or email - GET /api/cicd/reports: Generate CI/CD performance reports by period Features: 1. GitHub Actions integration for workflow run tracking 2. Configurable per-repository alert rules 3. Webhook forwarding for custom integrations 4. Email notification support (extensible) 5. Historical event caching for trend analysis 6. Success rate calculations and pipeline health metrics Addresses issue JhaSourav07#4991: Enhancement: Add integration with CI/CD and automated insights
Add Bearer token authentication to the POST /api/cicd/alerts route to prevent unauthorized modification of alert configurations. Requires CICD_ALERTS_SECRET environment variable to be set for proper operation.
- Convert require('crypto') to ES6 import in webhook handler
- Add missing await for async alertCache.get() calls
- Fix type checking errors in extractCheckRunEvent
- Properly type repositories object in generateCIReport
Apply Prettier formatting to resolve format checker warnings in app/api/cicd/alerts/route.ts and app/api/cicd/reports/route.ts.
Replace vulnerable string comparison (===) with crypto.timingSafeEqual() to prevent timing attacks on authentication token verification. Fixes CodeQL security vulnerability warning.
4a75ad9 to
88f123d
Compare
Update StatusBranch successfully rebased onto latest main. All commits are up-to-date. Regarding the failing checks:
The CI/CD integration functionality is complete and ready for review. Label RequestCould you please add the following labels for GSSoC 2026 tracking:
Thank you! |
- Make cacheEvent async and await eventCache.set (DistributedCache.set is async) - Make setAlertConfig async, await alertCache.get and alertCache.set - Fix TTL units: use ms (3600*1000, 86400*1000) instead of bare seconds - Add webhook-handler.test.ts covering parseWebhookEvent, cacheEvent, setAlertConfig, evaluateAlerts, and generateCIReport end-to-end Signed-off-by: Anshul Jain <anshul23102@iiitd.ac.in>
|
Hi @Aamod007, addressed all your feedback:
Ready for re-review. Thanks! |
|
🚨 Hey @anshul23102, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Difficulty: critical – Advanced security/infrastructure feature implementation.
Quality: clean – Production-ready.
Type: feature + security – Critical enhancement.
Excellent work!
Aamod-Dev
left a comment
There was a problem hiding this comment.
Review
This PR cannot be approved in its current state due to blocking issues (status:blocked label, merge conflicts, needs-rebase label, and/or failing CI checks). Please resolve the blocking issues and re-request review.
Once unblocked, I'm happy to re-review! 💚
Aamod-Dev
left a comment
There was a problem hiding this comment.
This is a massive and valuable architectural addition to support CI/CD webhook integrations and alerts. However, the PR is currently marked as blocked. Please resolve the blocking issues so we can properly review and merge this.
Summary
Implements comprehensive CI/CD integration with GitHub Actions webhook support, automated pipeline monitoring, and intelligent alerting system for issue #4991.
Key Features
1. GitHub Actions Webhook Integration
2. Event Processing and Caching
3. Intelligent Alert System
4. Automated Report Generation
5. API Endpoints
POST /api/webhooks/cicd- GitHub webhook receiver with signature verificationGET/POST /api/cicd/alerts- Alert configuration managementGET /api/cicd/reports- Performance report generationImplementation Details
New Files:
services/github/webhook-handler.ts(447 lines): Core webhook processing and alert orchestrationapp/api/webhooks/cicd/route.ts: Webhook endpoint with GitHub signature verificationapp/api/cicd/alerts/route.ts: Alert configuration APIapp/api/cicd/reports/route.ts: Report generation APIArchitecture Decisions:
Usage Examples
Configure Alerts
Generate Report
curl "http://localhost:3000/api/cicd/reports?repository=owner/repo&period=weekly"Integration with Existing Code
ci-analytics.tsservice for data consistencyDistributedCachefor scalable event storageTesting Considerations
Closes #4991