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

fix: gitlab support improvements #97

Merged
merged 3 commits into from
Aug 7, 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
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ In the root of your git repository run:

```shell
npm install code-review-gpt
npx code-review-gpt configure --ci=github
npx code-review-gpt configure --setupTarget=github
```

### Gitlab CI

```shell
npm install code-review-gpt
npx code-review-gpt configure --ci=gitlab
npx code-review-gpt configure --setupTarget=gitlab
```

See templates for example yaml files. Copy and paste them to perform a manual setup.
Expand Down Expand Up @@ -73,17 +73,18 @@ You can now run `code-review-gpt review` in the root directory of any git-enable

### Options

- `--ci` - Used with the `review` command. Options are --ci=("github" | "gitlab"). Defaults to "github" if no option is specified. Runs the application in CI mode. This will use the BASE_SHA and GITHUB_SHA environment variables to determine which files to review. It will also use the GITHUB_TOKEN environment variable to create a comment on the pull request with the review results.
- `--ci` - Used with the `review` command. Options are --ci=("github" | "gitlab"). Defaults to "github" if no option is specified. Runs the application in CI mode. This will use the BASE_SHA and GITHUB_SHA environment variables to determine which files to review. It will also use the GITHUB_TOKEN environment variable to create a comment on the pull request with the review results.

- `--reviewType` - Used with the 'review' command. The options are --reviewType=("changed" | "full" | "costOptimized). Defaults to "changed" if no option is specified. Specifies whether the review is for the full file or just the changed lines. costOptimized limits the context surrounding the changed lines to 5 lines.

- `--commentPerFile` - Used when the `--ci` flag is set. Defaults to false. It enables the bot to comment the feedback on a file-by-file basis.
- `--commentPerFile` - Used when the `--ci` flag is set. Defaults to false. It enables the bot to comment the feedback on a file-by-file basis.

- `--setupTarget` - Used with the `configure` command. Options are --setupTarget=("github" | "gitlab"). Defaults to "github" if no option is specified. Specifies for which platform ('github' or 'gitlab') the project should be configured for.

- `--model` - The model to use for the review. Defaults to `gpt-4`. You can use any openai model you have access to.

- `--debug` - Runs the application in debug mode. This will enable debug logging.

## Getting Started Contributing 💫

1. Clone the repository:
Expand All @@ -110,6 +111,7 @@ When used globally you should run `export OPENAI_API_KEY=YOUR_API_KEY` (or simil
```shell
npm start
```

See the package.json file for all the npm commands you can run.

## Roadmap (see projects tab) 🌏
Expand All @@ -129,17 +131,14 @@ See the package.json file for all the npm commands you can run.
[![Star History Chart](https://api.star-history.com/svg?repos=mattzcarey/code-review-gpt&type=Date)](https://star-history.com/#mattzcarey/code-review-gpt&Date)

<!-- Badges -->

[npm]: https://www.npmjs.com/package/code-review-gpt
[npm_badge]: https://img.shields.io/npm/dm/code-review-gpt.svg

[license]: https://opensource.org/licenses/MIT
[license_badge]: https://img.shields.io/github/license/mattzcarey/code-review-gpt.svg?color=blue&style=flat-square&ghcache=unused

[contributors]: https://github.com/mattzcarey/code-review-gpt/graphs/contributors
[contributors_badge]: https://img.shields.io/github/contributors/mattzcarey/code-review-gpt

[pulse]: https://github.com/mattzcarey/code-review-gpt/pulse
[pulse_badge]: https://img.shields.io/github/commit-activity/m/mattzcarey/code-review-gpt

[twitter]: https://twitter.com/intent/follow?screen_name=oriontools.ai
[twitter_badge]: https://img.shields.io/twitter/follow/oriontoolsai?style=social&logo=twitter
1 change: 1 addition & 0 deletions src/configure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ const configureGitLab = async () => {
type: "input",
name: "apiKey",
message: "Please input your OpenAI API key:",
mask: "*",
Copy link
Owner

Choose a reason for hiding this comment

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

Niceee

},
]);

Expand Down
23 changes: 9 additions & 14 deletions templates/gitlab-pr.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
stages:
- build
- review

variables:
GIT_DEPTH: 0

default:
image: node

build-job:
stage: build
gpt-review:
stage: review
image: "node:18.17"
before_script:
- npm install -g code-review-gpt
script:
- npm ci
- npm install code-review-gpt
- npx code-review-gpt review --ci=gitlab
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- code-review-gpt review --ci=gitlab
only:
- merge_requests