From a5c7d6be3d66cd179e7bfa10e3a4ef16351223ca Mon Sep 17 00:00:00 2001 From: Manon Faour Date: Mon, 7 Aug 2023 11:51:26 +0100 Subject: [PATCH] fix: gitlab support improvements (#97) * doc: fix README use setupTarget with configure * fix: mask apiKey input with prompt * doc: change gitlab-pr template to fix naming and specify image version --- README.md | 15 +++++++-------- src/configure/index.ts | 1 + templates/gitlab-pr.yml | 23 +++++++++-------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e6512f79..c12821c9 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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: @@ -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) 🌏 @@ -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) + [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 diff --git a/src/configure/index.ts b/src/configure/index.ts index 2d37ae4a..2ef3ab4f 100644 --- a/src/configure/index.ts +++ b/src/configure/index.ts @@ -77,6 +77,7 @@ const configureGitLab = async () => { type: "input", name: "apiKey", message: "Please input your OpenAI API key:", + mask: "*", }, ]); diff --git a/templates/gitlab-pr.yml b/templates/gitlab-pr.yml index 950bb061..b6b97674 100644 --- a/templates/gitlab-pr.yml +++ b/templates/gitlab-pr.yml @@ -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