Skip to main content

Automatically assign review on gitlab/heptapod

Project description

This project aims to automatically assign unassigned pending merge-requests on a gitlab/heptapod instance.

Each member of a project can be randomly assigned to a pending merge-requests.

Assignbot assigns reviews to users, based on their preferences. Their preferences are store in a simple yaml file. The history of the assignment is stored in a CSV file, in a S3 storage.

The preferences file

The users define their “review preferences” in a preferences file, formatted in yaml.

The “preferences file” is a yaml file constructed as follow :

username_1:
    max_auto_review_per_week: XXX
    max_auto_review_per_day: YYY
username_2:
    max_auto_review_per_week: ZZZ
    max_auto_review_per_day: WWW

where username_1 is the username of a gitlab user, and max_auto_review_per_week (max_auto_review_per_day) is the maximum of automatically assigned review per week (per day).

The S3 storage

Assignbot uses a CSV file to keep track of users assignments. This CSV file is stored in an S3 storage. When you execute the bot, you must provide the following environment variables:

  • AWS_ACCESS_KEY_ID: your S3 key ID

  • AWS_SECRET_ACCESS_KEY: your S3 secret access key

  • S3_ENDPOINT_URL: your S3 endpoint url

  • S3_BUCKET_NAME: the S3 bucket to be used

Executing the bot

Once assignbot installed, you can run it as follow :

$ GITLAB_URL="https://your.forge.org" \
  GITLAB_TOKEN="XXX-an-api-token" \
  S3_ENDPOINT_URL="https://your.s3.storage.fr" \
  S3_BUCKET_NAME="you_bucket_name" \
  AWS_SECRET_ACCESS_KEY="your_secret_access_key" \
  AWS_ACCESS_KEY_ID="your_access_key_id" \
  python3 -m assignbot ./users_preferences.yml

and the bot should start assigning merge requests to the users.

Use case example

To use this bot, you can add a new repository on your forge with the following .gitlab-ci.yml :

assign:
  stage: assign
  only:
    - schedules
  variables:
      # there is a gitlab bug in the validation of AWS variables. We work
      # around it while waiting for the correction.
      # see: https://gitlab.com/gitlab-org/gitlab/-/issues/215927
      AWS_ACCESS_KEY_ID: "$_AWS_ACCESS_KEY_ID"
      AWS_SECRET_ACCESS_KEY: "$_AWS_SECRET_ACCESS_KEY"
  script:
    - pip install assignbot
    - python -m assignbot ./users_preferences.yml

This job assumes that you have defined the appropriate environment variables, and that you have a users_preferences.yml file at the root of this repository.

Then, you can create a new “schedule job” in gitlab, to call this job periodically.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

assignbot-2.0.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

assignbot-2.0.1-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file assignbot-2.0.1.tar.gz.

File metadata

  • Download URL: assignbot-2.0.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for assignbot-2.0.1.tar.gz
Algorithm Hash digest
SHA256 1096e6ce253f89f2e0c0e479f4e243cbcb1876a0e040dca857744284c7035882
MD5 e2f0e264d0a61fdd0f3779dba220f8db
BLAKE2b-256 28d5074cd94acf91f59e8ccd1f905aedac771efff0ec3a160d3e1542c55e1e4c

See more details on using hashes here.

File details

Details for the file assignbot-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: assignbot-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 14.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2

File hashes

Hashes for assignbot-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 24e2506b71bbedf1f86fabfc7879027480773dae3ad59da45ac1fa7ba45a483d
MD5 87748ae05cdf42d998469e0d94b757f8
BLAKE2b-256 bdd828f9c6d1d5d91ca994a09b4f5a79c674ac56682e80bb2e632c6628970d86

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page