Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
14b836f
ci/cd pipeline
NalinDalal May 25, 2025
0f4eabe
Update ci-cd.yml, optimised it
NalinDalal May 26, 2025
439f1fa
updated the ci-cd for the correct folder
NalinDalal May 26, 2025
4ec08a5
updated path to resolve conflicts
NalinDalal May 26, 2025
3f2b87c
check
NalinDalal May 26, 2025
e862db7
i pray to god
NalinDalal May 26, 2025
bc883cf
improved error handling
NalinDalal May 26, 2025
3b85d2e
updated package
NalinDalal May 26, 2025
c1ce332
updated the code as per review
NalinDalal May 29, 2025
c1e62d5
updated ci/cd as per review, removed makefile,updated error handling …
NalinDalal May 29, 2025
981ba6a
update logical order to lint β†’ test β†’ build.
NalinDalal May 29, 2025
bfbda73
Merge branch 'Mentro-Org:main' into main
NalinDalal Jun 2, 2025
600b1b4
Merge branch 'main' into main
NalinDalal Jun 9, 2025
dbb4e2d
Merge branch 'Mentro-Org:main' into main
NalinDalal Jun 25, 2025
f611653
update architecture
NalinDalal Jun 25, 2025
436f5c9
check
NalinDalal Jun 25, 2025
07884f9
check
NalinDalal Jun 25, 2025
a40c4a2
chechk
NalinDalal Jun 25, 2025
8b02734
check
NalinDalal Jun 25, 2025
42682eb
testing and ci-cd init
NalinDalal Sep 17, 2025
d14d764
redundancy removed
NalinDalal Sep 17, 2025
3b1899f
exception handling
NalinDalal Sep 17, 2025
15f80f2
Add GitHub Action for static analysis with golangci-lint
NalinDalal Sep 17, 2025
d05c98a
done
NalinDalal Sep 17, 2025
487a573
removed errors
NalinDalal Sep 17, 2025
513cfea
removed errors by importing correct files
NalinDalal Sep 17, 2025
c21f203
removed errors by importing correct files
NalinDalal Sep 17, 2025
20f2c5a
build error due to dependency issues, need to clean up the imports
NalinDalal Sep 17, 2025
069254e
imports updated to ensure workflow runs
NalinDalal Sep 17, 2025
01e726d
mst run
NalinDalal Sep 17, 2025
1ef0fa4
workflow update, should run
NalinDalal Sep 17, 2025
ed9df3f
updated code format which was producing error
NalinDalal Sep 17, 2025
3150a15
updated code format which was producing error
NalinDalal Sep 17, 2025
681da60
took care
NalinDalal Sep 17, 2025
4a104d4
hope it runs
NalinDalal Sep 17, 2025
a7b55d2
removed problematic imports
NalinDalal Sep 17, 2025
22bfd1f
done
NalinDalal Sep 17, 2025
d928f88
2nd workflow
NalinDalal Sep 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: CI/CD Pipeline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will review later ⏳


on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]

jobs:
ci:
if: github.event_name != 'push' || !startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '^1.20'
- name: Lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
working-directory: server

- name: Test
run: go test ./internal/...
working-directory: server

- name: Build
run: go build ./...
working-directory: server

cd:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v4
with:
go-version: '^1.20'
- name: Build release binary
run: go build -o build/app
working-directory: server

- name: Upload binaries
uses: actions/upload-artifact@v4
with:
name: release-binaries
path: server/build/
36 changes: 36 additions & 0 deletions .github/workflows/static-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Static Analysis (golangci-lint)

on:
pull_request:
paths:
- 'server/**.go'
- 'server/go.mod'
- 'server/go.sum'
push:
branches: [ main ]
paths:
- 'server/**.go'
- 'server/go.mod'
- 'server/go.sum'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Install golangci-lint
uses: golangci/golangci-lint-action@v4
with:
version: latest
working-directory: server
args: --timeout=5m

- name: Run golangci-lint
run: golangci-lint run ./server/... --timeout=5m
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"main"
]
}
90 changes: 63 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,78 @@
# Guidelines for Contributing to This Repository

We’re glad you want to contribute! To get started, please **fork the repository**, create your own branch from your fork, and follow the guidelines below to ensure your changes align with the project’s workflow and quality standards.
# Guidelines for Contributing to CodeLookout

## Working on changes
We’re glad you want to contribute! Please read these rules and setup instructions before submitting a pull request.

- Always **create a new branch** for your work.
- **Push regularly** to avoid data loss.
- We follow a **linear commit history** β€” always use `git rebase` instead of `git merge`.
## Contribution Rules

## Branch naming conventions
- **Fork the repository** and create a new branch for your work.
- **Branch naming:**
- New features: `feature/<feature-name>`
- Bug fixes: `fix/<bug-description>`
- Hotfixes: `hotfix/<critical-fix>`
- Security: `security/<change>`
- Maintenance: `maintenance/<task>`
- Other/dev: `<username>/<description>`
- **Push regularly** to your branch.
- **Linear commit history:** Use `git rebase` (not `git merge`).
- **Pull Requests:**
- Use clear, descriptive titles and detailed descriptions.
- Reference related issues if applicable.
- Use **Squash and Merge** after approval.
- **Commit messages:**
- Write clear, meaningful commit messages ([guide](https://cbea.ms/git-commit/)).
- **Tests:**
- Add or update tests for new features and bug fixes.
- **Code style:**
- Follow Go best practices and project conventions.
- **Review:**
- Address all review comments before merging.

Branch names should reflect the purpose of the work and follow a consistent structure.
## Local Setup Instructions

### Recommended patterns
Follow these steps to set up CodeLookout for local development:

| Type | Pattern | Example | Notes |
| ---------------------- | -------------------------- | ------------------------------------------------ | ---------------------------------------------------- |
| New Features | `feature/<feature-name>` | `feature/integrate-openai-apis-for-code-summary` | For new user-facing features |
| Bug Fixes | `fix/<fix-name>` | `fix/auth-error` | For bug fixes |
| Hotfixes | `hotfix/<fix-name>` | `hotfix/breaking-changes-openai-sdk` | For urgent, critical fixes |
| Security Updates/Fixes | `security/<change>` | `security/suppress-server-headers` | For security-related changes |
| Maintenance | `maintenance/<task>` | `maintenance/run-integration-tests-in-workflows` | For internal improvements or upkeep |
| Development / Other | `<username>/<description>` | `alex/job-queue-poc` | For work not covered above; often temporary branches |
1. **Clone your fork and install dependencies:**
```sh
git clone https://github.com/<your-username>/CodeLookout.git
cd CodeLookout
cd server
go mod download
```

> **Tip:** Avoid vague names like `fix/bug-fix`. Be clear and descriptive.
2. **Configure environment variables:**
- Copy or create a `.env` file (see `server/development.md` for details).
- Set up a local PostgreSQL and Redis instance, or use Docker Compose.

## Pull request conventions
3. **Run database migrations:**
```sh
./scripts/run_migrations.sh
```

GitHub will automatically apply the default PR template located [here](https://github.com/Mentro-Org/CodeLookout/blob/main/.github/PULL_REQUEST_TEMPLATE.md).
4. **Start the development server:**
- With Docker Compose:
```sh
docker-compose up
./scripts/run_smeeclient.sh # For GitHub webhook forwarding
```
- Or locally:
```sh
go run cmd/main.go
./scripts/run_smeeclient.sh
```

### PR guidelines
5. **Access the app:**
- API: `http://localhost:8080/api/`
- Analytics Dashboard: `http://localhost:8080/analytics`

- **Title**: Clearly describe the purpose of the PR.
- **Description**: Include a detailed explanation of what changes were made and why.
- **Merge strategy**: Use **`Squash and Merge`** once all reviews and checks are approved.
6. **Run/test LLM and SonarQube CLI tools:**
```sh
make test-llm
make test-sonarqube
```

## Commit message conventions
7. **See `server/development.md` for more details and troubleshooting.**

Good commit messages are essential for a readable project history. Please follow this guide:
---

πŸ‘‰ [How to Write a Git Commit Message](https://cbea.ms/git-commit/)
Thank you for contributing to CodeLookout!
Binary file added bin/act
Binary file not shown.
5 changes: 4 additions & 1 deletion server/.dev.env
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@ OPENAI_API_KEY=your-openai-key
DATABASE_URL=postgres://user:pass@localhost:5432/dbname
# QUEUE_SIZE=100
REDIS_ADDRESS=localhost:6379
WORKER_CONCURRENCY=5
WORKER_CONCURRENCY=5

LLM_ENDPOINT="https://api-inference.huggingface.co/models/gpt2"
LLM_AUTH_TOKEN="your_huggingface_token" # (if required, or leave blank for public models)
10 changes: 10 additions & 0 deletions server/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Makefile for testing LLM and SonarQube integrations

.PHONY: test-llm test-sonarqube


test-llm:
go run ./cmd/llm_cli/main.go

test-sonarqube:
go run ./cmd/sonarqube_cli/main.go
97 changes: 66 additions & 31 deletions server/architecture.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,70 @@
## PR Review Processing Flow (Redis + Asynq + Worker)

+----------------------+ +------------------------+ +------------------+
| GitHub Webhook | -----> | HTTP Server (API) | | AI Review |
| (PR Open/Update) | | - Validates Webhook | | Generator (LLM)|
+----------------------+ | - Enqueues Task (Asynq)| +------------------+
+------------------------+
|
v
+------------------+
| Redis (Asynq DB)|
| - Stores Queued |
| Tasks |
+------------------+
|
v
+-----------------------------+
| Asynq Worker (Goroutine) |
| - Dequeues Task |
| - Fetches PR Diff |
| - Builds Prompt |
| - Calls AI API |
| - Posts Comments via GitHub |
+-----------------------------+
```mermaid
flowchart LR
ghwebhook[GitHub Webhook PR Open or Update] --> httpapi[HTTP Server API]
httpapi --> redis[Redis Asynq DB]
redis --> worker[Asynq Worker]
worker --> ai[AI Review Engine LLM]
ai --> ghapi[GitHub API Post Comments]

httpapi --> validate[Validate Webhook]
validate --> enqueue[Enqueue Task Asynq]
enqueue --> redis

worker --> dequeue[Dequeues Task]
dequeue --> fetch[Fetch PR Diff]
fetch --> buildprompt[Build Prompt]
buildprompt --> callai[Call AI API]
callai --> postcomment[Post Comments]
postcomment --> ghapi

```

+----------------------+ +------------------------+ +------------------+
| GitHub Webhook | -----> | HTTP Server (API) | | AI Review |
| (PR Open/Update) | | - Validates Webhook | | Generator (LLM)|
+----------------------+ | - Enqueues Task (Asynq)| +------------------+
+------------------------+
|
v
+------------------+
| Redis (Asynq DB)|
| - Stores Queued |
| Tasks |
+------------------+
|
v
+-----------------------------+
| Asynq Worker (Goroutine) |
| - Dequeues Task |
| - Fetches PR Diff |
| - Builds Prompt |
| - Calls AI API |
| - Posts Comments via GitHub |
+-----------------------------+

## Understand graceful shutdown of services
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ main() β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”œβ”€ initializeDependencies()
β”œβ”€ signal listener goroutine ───┐
β”œβ”€ RunWorker() goroutine β”‚ (listens for ctx cancel)
β”œβ”€ startServer() goroutine β”‚ (listens for ctx cancel)
└─ wg.Wait() <β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ waits for both

```mermaid
flowchart TD
main[main function] --> init[Initialize Dependencies]
init --> sig[SIGINT Listener Goroutine]
init --> runworker[Run Worker Goroutine]
init --> startserver[Start Server Goroutine]
sig --> wait[Wait for Shutdown]
runworker --> wait
startserver --> wait


```

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ main() β”‚
β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”‚
β”œβ”€ initializeDependencies()
β”œβ”€ signal listener goroutine ───┐
β”œβ”€ RunWorker() goroutine β”‚ (listens for ctx cancel)
β”œβ”€ startServer() goroutine β”‚ (listens for ctx cancel)
└─ wg.Wait() <β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ waits for both
29 changes: 29 additions & 0 deletions server/cmd/llm_cli/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package main

import (
"fmt"
"os"
"github.com/nalindalal/CodeLookout/server/internal/config"
"github.com/nalindalal/CodeLookout/server/internal/llm"
)

// This CLI demonstrates LLM integration using RESTLLMClient
func main() {
cfg := config.Load()
if cfg.LLMEndpoint == "" {
fmt.Println("LLM_ENDPOINT not set in config. Exiting.")
os.Exit(1)
}
// Optionally support LLM_AUTH_TOKEN for HuggingFace
authToken := os.Getenv("LLM_AUTH_TOKEN")
client := &llm.RESTLLMClient{Endpoint: cfg.LLMEndpoint, AuthToken: authToken}
code := "func add(a int, b int) int { return a + b }"
fmt.Println("Sending code to LLM endpoint:", cfg.LLMEndpoint)
result, err := client.AnalyzeCode(code)
if err != nil {
fmt.Println("LLM error:", err)
os.Exit(1)
}
fmt.Println("LLM review result:")
fmt.Println(result)
}
Loading