Go to file
zhangxunhui cbbf53058b change readme 2021-08-21 23:25:21 +08:00
app remove nrows 2021-08-21 22:32:36 +08:00
tests try to change from decision to latency 2021-08-21 15:41:34 +08:00
.env.yaml.example modify alembic 2021-08-21 15:40:40 +08:00
.gitignore update .gitignore 2021-08-21 14:03:47 +08:00
LICENSE Initial commit 2021-08-21 13:48:41 +08:00
README.md change readme 2021-08-21 23:25:21 +08:00
alembic.ini modify alembic 2021-08-21 15:40:40 +08:00
poetry.lock add dependencies 2021-08-21 14:04:05 +08:00
pr-latency-bot.sh modified the latency shell start file 2021-08-21 15:41:07 +08:00
pyproject.toml add dependencies 2021-08-21 14:04:05 +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-latency-bot, we will use this environment name in the following text)
  • install mysql and create a database (here we name the database pr-latency-bot)

run commands to start the program

1. install python dependencies

git clone https://github.com/PR-bots/PR-latency-bot.git
cd PR-latency-bot
conda activate pr-latency-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 latency 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-latency-bot.sh start
  • stop/restart the service using the following commands (for windows server, you need to write your own shell):
bash pr-latency-bot.sh stop
bash pr-latency-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!