/algorithms-keeper

A bot for TheAlgorithms/Python repository.

Primary LanguagePythonMIT LicenseMIT

algorithms-keeper

GitHub Workflow Status Codecov code style: black

A bot for TheAlgorithms/Python repository. This bot is based on this tutorial and also inspired by the ones working for the CPython repository which are miss-islington, bedevere and the-knights-who-say-ni. This bot is basically a GitHub app which can be installed in any repository using this link.

NOTE: This bot is highly configured for TheAlgorithms/Python repository. DO NOT INSTALL the bot without reading what it actually does.

What the bot does:

Greet the user for installing the app

Open an issue with the message greeting the user who either installed the app or added a new repository to the installed app and then close the issue.

Add or remove label(s) to pull requests

  • To indicate that some of the tests are failing for this pull request if it is not present and remove it when all the tests are passing. It does nothing if the tests are already passing. NOTE: This check will be skipped if the pull request is in draft mode.
  • To indicate that the pull request is ready to be reviewed by a maintainer which means all the checks are passing and all the requirements have been satisfied.
  • To indicate the user that a maintainer has requested some changes to their submission. The bot will remove the label once the pull request is approved.

Close invalid pull requests

A pull request is considered invalid if:

  • It doesn't contain any description.
  • The user has not ticked any of the checkboxes in the provided pull request template.
  • The file extension is invalid. For now only PRs with extensionless files are closed.

NOTE: These checks will be skipped for any member or owner of the organization and also for the pull request which is in draft mode.

Close additional pull requests by user

A user will be allowed a fix number of pull requests at a time which will be indicated by the MAX_PR_BY_USER constant. This is done so as to avoid spam pull requests. This can be disabled by updating the constant value to 0: MAX_PR_BY_USER = 0.

NOTE: These checks will be skipped for any member or owner of the organization and also for the pull request which is in draft mode.

Check all Python files in a pull request

All the Python files will be checked for tests [doctest/unittest/pytest], type hints and descriptive class/function/parameter names. Labels will be added and/or removed according to the latest commit in a pull request. A report will be created and commented by the bot if there are any errors found, but only when a pull request is opened or is made ready for review and not on the subsequent commits.

NOTE: These checks will be skipped if the pull request is in draft mode and if the pull request is invalid.

Logging

There are three loggers out of which one is the main logger for the bot that is being used to log certain events and exceptions. The other two loggers are: aiohttp.access from aiohttp.log.access_logger, used to log POST requests made by GitHub for delivering the payload and api, used to log all the API calls made to GitHub. The logs can be viewed best using the following command (requires Heroku CLI):

heroku logs -a algorithms-keeper -d web -t