Go to file
zhangxunhui 7485b7ecb5 update .env.yaml.example 2022-04-28 00:38:36 +08:00
app add traceback of each exception handler 2021-08-21 12:31:40 +08:00
tests add test service 2021-08-19 10:13:28 +08:00
.env.yaml.example update .env.yaml.example 2022-04-28 00:38:36 +08:00
.gitignore update .gitignore 2021-08-18 23:15:31 +08:00
LICENSE Initial commit 2021-08-12 14:58:19 +08:00
README.md change README 2021-08-21 23:25:10 +08:00
alembic.ini add alembic initialization and add two tables 2021-08-14 13:39:23 +08:00
poetry.lock add packages for training 2021-08-17 14:13:39 +08:00
pr-decision-bot.sh change start shell 2021-08-21 11:11:32 +08:00
pyproject.toml add packages for training 2021-08-17 14:13:39 +08:00

README.md

Installation

environment installation

  • install poetry if it's not in your environment (see python-poerty/poerty)
  • use pyenv or conda to create a virtual environment of python version=3.8 (env name=pr-decision-bot, we will use this environment name in the following text)
  • install mysql and create a database (here we name the database pr-decision-bot)

run commands to start the program

1. install python dependencies

git clone https://github.com/PR-bots/PR-decision-bot.git
cd PR-decision-bot
conda activate pr-decision-bot
poetry install
poetry shell

2. migrate database

  • change the configuration of your mysql database in .env.yaml file ("MYSQL" part)
  • create a database with the name you defined in the configuration file
  • run the following commands to create tables in the target database
alembic upgrade head

3. run the service

  • create a new GitHub App on GitHub web page according to the instruction.
    • set the "Webhook URL" to your service url+port
    • set repository permissions as follows:
      • Contents: Read-only
      • Discussions: Read-only
      • Metadata: Read-only
      • Pull requests: Read & write
    • subscribe to events:
      • Pull request
    • set the access of your GitHub App
      • Only on this account: create your own private App
      • Any account: create a public App
    • [optional] after creating your App, you can set the Display information by uploading a logo of your App
    • generate your own private key of your GitHub App (see GitHub Doc), and download it to your own path.
  • change the configuration of your installed App on GitHub in .env.yaml file ("APP" part)
    • change "APP_SLUG" according to your own settings, see GitHub Doc for more information.
    • change "PRIVATE_KEY_PATH" according to the path you store your private key (pem file).
    • change "PERSONAL_TOKEN" according to GitHub Doc. Here it uses the personal token just for the initialization of service, as the APP_ID will change if you change the setting of your own deployed App. Therefore, it just uses the token to access your current APP_ID. (The personal token is the token of whom your App is created by. For organization accounts, please use the token of the member that is allowed to manage all GitHub Apps belonging to this organization.)
  • change the configuration of the pull request decision making service in .env.yaml file ("SERVICE" part).
    • change the port ("PORT") of your service.
    • change the number of hours of "REMIND_EVERY_HOURS". This means how often do you want your pull requests receive the remind message.
    • change the number of hours needed for scheduler ("SCHEDULER") to cycle ("CYCLE_MINUTES"). This represents how often does the background scheduler run for 1-round check.
  • start the service using the following commands (for windows server, you need to write your own shell). It will take some time for the training of the model. If your server's performance is not good, try running command python app/prediction_service/trainer.py and train the model at somewhere else before the start of the service.
poetry shell
bash pr-decision-bot.sh start
  • stop/restart the service using the following commands (for windows server, you need to write your own shell):
bash pr-decision-bot.sh stop
bash pr-decision-bot.sh restart

4. install your GitHub App

find your app through your app's public link and install it to your target personal/organization account that want to use the app.

That's it! You can use your own App now! Good luck!