- Python 56%
- HCL 25.1%
- Shell 18.9%
| config | ||
| infra | ||
| .gitignore | ||
| .pre-commit-config.yaml | ||
| bun.lock | ||
| configure_gitlab.py | ||
| CONTRIBUTING.md | ||
| deploy.sh | ||
| package.json | ||
| README.md | ||
| ruff.toml | ||
PR-Agent for GitLab on AWS Lambda
This repository contains the configuration, infrastructure, and deployment scripts to run PR-Agent as an on-demand AWS Lambda function integrated with GitLab, using GLM-5 via Amazon Bedrock as the model backend.
Prerequisites
- AWS CLI: Authenticated with credentials that have permission to create IAM Roles, ECR repositories, Secrets Manager secrets, and Lambda functions.
- Docker: Running locally to build the container image.
- Bun: Installed for formatting and linting tools (
bun run format). - Python 3: To run the interactive
configure_gitlab.pyscript. - Pre-commit: Installed locally to run pre-commit quality checks.
Deployment & Setup
Step 1: Bootstrap Infrastructure and Deploy
Execute the deployment script to initialize Terraform, build the Docker image, push it to AWS ECR, and deploy the Lambda function. This will also clone the upstream PR-Agent source into pr-agent-src/ if it doesn't already exist:
./deploy.sh
This will output your API Gateway URL (preferred) and Lambda Function URL when complete.
Step 2: Register GitLab Webhooks
Create a .env file in the root of the repository. (This file is ignored by Git to keep your token secure):
GITLAB_URL=https://gitlab.com # Or your self-hosted GitLab instance URL
GITLAB_PERSONAL_ACCESS_TOKEN=glpat-your-bots-personal-access-token
GITLAB_ADMIN_TOKEN=glpat-admin-personal-access-token
Note
The GitLab Personal Access Token requires
apiscope to list projects and configure webhooks automatically.
Then run the interactive configuration script to upload your GitLab credentials to Secrets Manager and register the webhook on your target projects:
python3 configure_gitlab.py
The script will list all projects you have access to. Select the indices of the projects you wish to enable (or type all), and it will create/update the webhook.
Usage (Slash Commands)
Once set up, add comments to any Merge Request in the configured projects to trigger PR-Agent:
/review— Full line-by-line code review with inline comments/describe— Regenerate/update the MR description/improve— Suggest specific code improvements/ask <question>— Ask PR-Agent a question about the MR diff
Linting & Formatting (Pre-commit Hooks)
This repository uses pre-commit to ensure code quality, formatting, and validation automatically before every commit.
Setup
-
Install
pre-commiton your machine:brew install pre-commit -
Register the hooks in your local Git repository:
pre-commit install
Once installed, the hooks will automatically run on the staged files every time you execute git commit.
Running Manually
You can manually run the hooks against all files in the repository at any time:
pre-commit run --all-files
If you need to bypass the checks for a specific commit (e.g., temporary local work), you can use:
git commit -m "your message" --no-verify