From b100e7098adf41a68e310a731310107ca5c4f0a7 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 5 Aug 2024 15:45:58 +0300 Subject: [PATCH 1/3] Add instructions for running PR-Agent as a GitLab pipeline in gitlab.md --- docs/docs/installation/gitlab.md | 39 ++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/docs/installation/gitlab.md b/docs/docs/installation/gitlab.md index cb3b7931c..844d6789c 100644 --- a/docs/docs/installation/gitlab.md +++ b/docs/docs/installation/gitlab.md @@ -1,3 +1,42 @@ +## Run as a GitLab Pipeline +You can use a pre-built Action Docker image to run PR-Agent as a GitLab pipeline. This is a simple way to get started with PR-Agent without setting up your own server. + +(1) Add the following file to your repository under `.gitlab-ci.yml`: +```yaml +stages: + - pr_agent + +pr_agent_job: + stage: pr_agent + image: + name: codiumai/pr-agent:latest + entrypoint: [""] + script: + - cd /app + - echo "Running PR Agent action step" + - export MR_URL="$CI_MERGE_REQUEST_PROJECT_URL/merge_requests/$CI_MERGE_REQUEST_IID" + - echo "MR_URL=$MR_URL" + - export gitlab__PERSONAL_ACCESS_TOKEN=$GITLAB_PERSONAL_ACCESS_TOKEN + - export config__git_provider="gitlab" + - export openai__key=$OPENAI_KEY + - python -m pr_agent.cli --pr_url="$MR_URL" describe + - python -m pr_agent.cli --pr_url="$MR_URL" review + - python -m pr_agent.cli --pr_url="$MR_URL" improve + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_EVENT_TYPE == "merge_request" && $CI_MERGE_REQUEST_STATE == "opened"' +``` +Note that this script will run PR-Agent on every new merge request. You can modify the `rules` section to run PR-Agent on different events. +You can also modify the `script` section to run different PR-Agent commands, or with different parameters by exporting different environment variables. + + +(2) Add the following variables to your GitLab repository (CI/CD -> Variables): +- `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token. +- `OPENAI_KEY`: Your OpenAI key. + +Note that if your base branches are not protected, don't set the variables as `protected`, since the pipeline will not have access to them. + + + ## Run a GitLab webhook server 1. From the GitLab workspace or group, create an access token. Enable the "api" scope only. From ac53e6728d9c18195c674004cbc6e0dc3f67d697 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 5 Aug 2024 15:48:42 +0300 Subject: [PATCH 2/3] Add instructions for running PR-Agent as a GitLab pipeline in gitlab.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 3c43ed49a..33dca81db 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,9 @@ CodiumAI PR-Agent aims to help efficiently review and handle pull requests, by p ## News and Updates +### August 5, 2024 +Added support for [GitLab pipeline](https://pr-agent-docs.codium.ai/installation/gitlab/#run-as-a-gitlab-pipeline) - you can now run easily PR-Agent as a GitLab pipeline, without needing to set up your own server. + ### July 28, 2024 (1) improved support for bitbucket server - [auto commands](https://github.com/Codium-ai/pr-agent/pull/1059) and [direct links](https://github.com/Codium-ai/pr-agent/pull/1061) From e7c99f0e6f3385797e7d9b97657aa4d97d2d7c0c Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 5 Aug 2024 15:52:13 +0300 Subject: [PATCH 3/3] Add instructions for running PR-Agent as a GitLab pipeline in gitlab.md --- docs/docs/installation/gitlab.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/installation/gitlab.md b/docs/docs/installation/gitlab.md index 844d6789c..347068565 100644 --- a/docs/docs/installation/gitlab.md +++ b/docs/docs/installation/gitlab.md @@ -23,13 +23,13 @@ pr_agent_job: - python -m pr_agent.cli --pr_url="$MR_URL" review - python -m pr_agent.cli --pr_url="$MR_URL" improve rules: - - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_EVENT_TYPE == "merge_request" && $CI_MERGE_REQUEST_STATE == "opened"' + - if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_STATE == "opened"' ``` Note that this script will run PR-Agent on every new merge request. You can modify the `rules` section to run PR-Agent on different events. You can also modify the `script` section to run different PR-Agent commands, or with different parameters by exporting different environment variables. -(2) Add the following variables to your GitLab repository (CI/CD -> Variables): +(2) Add the following masked variables to your GitLab repository (CI/CD -> Variables): - `GITLAB_PERSONAL_ACCESS_TOKEN`: Your GitLab personal access token. - `OPENAI_KEY`: Your OpenAI key.