Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

... #5

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ runs:
- uses: actions/setup-node@v3
with:
node-version: 18
- name: diff
shell: bash
run: 'git --no-pager diff HEAD^ HEAD --output=diff-file'
- name: check
shell: bash
run: 'node dist/index.js'
Expand Down
32 changes: 27 additions & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8697,6 +8697,18 @@ return new B(c,{type:"multipart/form-data; boundary="+b})}
/******/ __nccwpck_require__.m = __webpack_modules__;
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __nccwpck_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __nccwpck_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
Expand Down Expand Up @@ -10950,16 +10962,29 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {

// EXTERNAL MODULE: ./node_modules/@octokit/graphql/dist-node/index.js
var dist_node = __nccwpck_require__(7105);
// EXTERNAL MODULE: external "fs"
var external_fs_ = __nccwpck_require__(7147);
var external_fs_default = /*#__PURE__*/__nccwpck_require__.n(external_fs_);
;// CONCATENATED MODULE: ./index.js





async function reviewPR() {
try {
console.log("process.env.GITHUB_TOKEN length", process.env.GITHUB_TOKEN.length)
// const octokit = github.getOctokit(process.env.GITHUB_TOKEN)

let RAW_TEXT = `Act as an expert software engineer reviewing code.
You need to find errors and suggest a fix.
Format your output to include file_name, line_number and comment.`

const gitDiff = external_fs_default().readFileSync('diff-file', { encoding: 'utf8', flag: 'r' });
console.log('git diff:', gitDiff);

RAW_TEXT += `Here is a git diff for changes: ${gitDiff}`

const ctx = {
owner: process.env.PR_OWNER,
repo: process.env.PR_REPO,
Expand Down Expand Up @@ -11026,10 +11051,7 @@ async function reviewPR() {

const pr_title = data.repository.pullRequest.title
const pr_descr = data.repository.pullRequest.body
let RAW_TEXT = `Act as an expert software engineer reviewing code.
You need to find errors and suggest a fix.
Format your output to include file_name, line_number and comment.
Last pull request was titled "${pr_title} and had a description "${pr_descr}".`;
RAW_TEXT += `Last pull request was titled "${pr_title} and had a description "${pr_descr}".`;

const commit_msg = data.repository.pullRequest.commits.edges[0].node.commit.message
RAW_TEXT += `Last commit message was "${commit_msg}". `
Expand Down Expand Up @@ -11075,7 +11097,7 @@ async function reviewPR() {
return
}

console.log(clarifaiData)
console.log("clarifai response:", clarifaiData)
const clarifaiResponse = clarifaiData['outputs'][0]['data']['text']['raw']

await (0,dist_node.graphql)(`
Expand Down
17 changes: 12 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import * as core from '@actions/core'
import fetch from 'node-fetch';
import {graphql} from "@octokit/graphql";
import fs from 'fs'

async function reviewPR() {
try {
console.log("process.env.GITHUB_TOKEN length", process.env.GITHUB_TOKEN.length)
// const octokit = github.getOctokit(process.env.GITHUB_TOKEN)

let RAW_TEXT = `Act as an expert software engineer reviewing code.
You need to find errors and suggest a fix.
Format your output to include file_name, line_number and comment.`

const gitDiff = fs.readFileSync('diff-file', { encoding: 'utf8', flag: 'r' });
console.log('git diff:', gitDiff);

RAW_TEXT += `Here is a git diff for changes: ${gitDiff}`

const ctx = {
owner: process.env.PR_OWNER,
repo: process.env.PR_REPO,
Expand Down Expand Up @@ -73,10 +83,7 @@ async function reviewPR() {

const pr_title = data.repository.pullRequest.title
const pr_descr = data.repository.pullRequest.body
let RAW_TEXT = `Act as an expert software engineer reviewing code.
You need to find errors and suggest a fix.
Format your output to include file_name, line_number and comment.
Last pull request was titled "${pr_title} and had a description "${pr_descr}".`;
RAW_TEXT += `Last pull request was titled "${pr_title} and had a description "${pr_descr}".`;

const commit_msg = data.repository.pullRequest.commits.edges[0].node.commit.message
RAW_TEXT += `Last commit message was "${commit_msg}". `
Expand Down Expand Up @@ -122,7 +129,7 @@ async function reviewPR() {
return
}

console.log(clarifaiData)
console.log("clarifai response:", clarifaiData)
const clarifaiResponse = clarifaiData['outputs'][0]['data']['text']['raw']

await graphql(`
Expand Down
Loading