From c23bf57bc1bbfbe3134b6b336503779efa6d302e Mon Sep 17 00:00:00 2001 From: Ratan Gulati Date: Wed, 19 Nov 2025 08:40:54 +0530 Subject: [PATCH 1/3] Add sample code for AI review --- sample-code.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 sample-code.js diff --git a/sample-code.js b/sample-code.js new file mode 100644 index 0000000..add7930 --- /dev/null +++ b/sample-code.js @@ -0,0 +1,33 @@ +// Sample code with various issues for AI review +function calculateTotal(items) { + let total = 0; + for (let i = 0; i < items.length; i++) { + total = total + items[i].price; + } + return total; +} + +// Missing error handling +function fetchUserData(userId) { + return fetch(`https://api.example.com/users/${userId}`) + .then(response => response.json()); +} + +// Security issue: SQL injection vulnerability +function getUser(username) { + const query = "SELECT * FROM users WHERE username = '" + username + "'"; + return db.query(query); +} + +// Performance issue: inefficient loop +function findDuplicates(arr) { + let duplicates = []; + for (let i = 0; i < arr.length; i++) { + for (let j = i + 1; j < arr.length; j++) { + if (arr[i] === arr[j]) { + duplicates.push(arr[i]); + } + } + } + return duplicates; +} From 0587ac5b475acd95d9553f54b4b8efd78224729d Mon Sep 17 00:00:00 2001 From: Ratan Gulati Date: Wed, 19 Nov 2025 08:49:19 +0530 Subject: [PATCH 2/3] Convert to composite action - no dist in git --- .github/workflows/ai-review.yml | 6 ++---- .gitignore | 2 ++ action.yml | 33 +++++++++++++++++++++++++++++---- package.json | 21 +++++++++++---------- 4 files changed, 44 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ai-review.yml b/.github/workflows/ai-review.yml index f3f098d..21b2611 100644 --- a/.github/workflows/ai-review.yml +++ b/.github/workflows/ai-review.yml @@ -13,12 +13,10 @@ jobs: issues: write steps: - - name: Checkout code + - name: Checkout repository uses: actions/checkout@v4 - - name: AI Code Review + - name: Run CodeBuddy AI uses: ./ with: gemini_api_key: ${{ secrets.GEMINI_API_KEY }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 0b49794..cbf66d9 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,5 @@ Thumbs.db # Logs *.log npm-debug.log* +dist/ +lib/ diff --git a/action.yml b/action.yml index 5c2b98c..ae6f6bf 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ -name: 'AI Code Review Bot' -description: 'Automatically reviews pull requests using Google Gemini AI' +name: 'CodeBuddy AI' +description: 'Your friendly AI code reviewer powered by Google Gemini' author: 'Your Name' branding: icon: 'check-circle' @@ -11,5 +11,30 @@ inputs: required: true runs: - using: 'node20' - main: 'dist/index.js' + using: 'composite' + steps: + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install dependencies + shell: bash + run: | + cd ${{ github.action_path }} + npm ci + + - name: Build action + shell: bash + run: | + cd ${{ github.action_path }} + npm run build + + - name: Run CodeBuddy AI + shell: bash + env: + INPUT_GEMINI_API_KEY: ${{ inputs.gemini_api_key }} + GITHUB_TOKEN: ${{ github.token }} + run: | + cd ${{ github.action_path }} + node dist/index.js diff --git a/package.json b/package.json index 495c7dd..b4b917d 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,25 @@ { - "name": "ai-code-review-bot", + "name": "codebuddy-ai", "version": "1.0.0", - "main": "index.js", + "description": "Your friendly AI code reviewer powered by Google Gemini", + "main": "dist/index.js", "scripts": { - "build": "ncc build src/index.ts -o dist", - "build:watch": "ncc build src/index.ts -o dist --watch", + "build": "tsc && ncc build lib/index.js -o dist", + "build:watch": "ncc build lib/index.js -o dist --watch", "clean": "rm -rf dist lib", "all": "npm run clean && npm run build" }, - "keywords": [], - "author": "Ratan Gulati", - "license": "ISC", - "description": "", + "keywords": ["github-actions", "ai", "code-review", "gemini"], + "author": "Your Name", + "license": "MIT", "dependencies": { "@actions/core": "^1.11.1", "@actions/github": "^6.0.1", - "node-fetch": "^3.3.2" + "node-fetch": "^2.7.0" }, "devDependencies": { - "@types/node": "^24.3.0", + "@types/node": "^20.14.0", + "@types/node-fetch": "^2.6.11", "@vercel/ncc": "^0.38.3", "typescript": "^5.9.2" } From 4b396b546622970c5a15675113acf58d9f4a83c8 Mon Sep 17 00:00:00 2001 From: Ratan Gulati Date: Wed, 19 Nov 2025 08:50:04 +0530 Subject: [PATCH 3/3] Test composite action --- src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.ts b/src/index.ts index 0f68560..0a21be0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -245,3 +245,4 @@ async function run() { } run(); +// test