Git Product home page Git Product logo

algorithms-keeper's Introduction

algorithms-keeper

CI codecov code style: black Checked with mypy

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 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 the stage the pull request is currently at. This is a cycle of two labels which indicates the two stages: The pull request requires a review/re-review, or a maintainer has requested changes for the pull request.
  • To indicate whether the pull request contains merge conflicts or not.

The pull request stages can be best described in a graphviz diagram whose code is in the pull requests module.

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 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. The bot will post the review with all the details regarding the missing requirements.

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

Commands

Some actions of the bot can be triggered using commands:

  • @algorithms-keeper review to trigger the checks for only added pull request files.
  • @algorithms-keeper review-all to trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command only modify the labels accordingly.

NOTE: Commands are in BETA and valid only if it is commented on a pull request and only by either a member or owner of the organization.

Logging

Logging is done using the standard library logging module. All the API calls made by the bot are being logged at INFO level and aiohttp.log.access_logger is logging the POST requests made by GitHub for delivering the payload. Other minor events relevant to the repository is also being logged along with using the using Sentry. The logs can be viewed best using the following command (requires Heroku CLI):

heroku logs -a algorithms-keeper -t

algorithms-keeper's People

Contributors

cclauss avatar dependabot[bot] avatar dhruvmanila avatar hfz1337 avatar panquesito7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

algorithms-keeper's Issues

What should the bot ignore in the PR report?

I'm opening this issue as a way to collect my thoughts on what should the bot ignore while making the report:

  • modified files: the reason being that the files modified were probably meant to improve only a part of it and not the whole. So the bot should consider only the files which were added in the PR for the report.

  • scripts/ directory: because that is unnecessary.

Should the process be fully automatic or semiautomatic?

I am OK either way.

  1. Collect all intended actions and post that to a task file in a PR?
  2. Wait for a maintainer (or two maintainers?) to approve that PR.
  3. Execute the intended actions and close the PR created in 1. above.

[bug] Bot keeps adding the awaiting reviews label

GitHub event:

  • pull_request:opened
  • pull_request:synchronize
  • pull_request:ready_for_review
  • pull_request:closed
  • pull_request:labeled
  • pull_request:unlabeled
  • pull_request_review:submitted
  • check_run:completed
  • issues:opened

Example pull request/issue:

TheAlgorithms/Python#3420

Steps to reproduce the bug:

  • Pull request has been opened, no errors found, and all tests passed => bot adds the awaiting reviews label
  • Then a maintainer approves the pull request and tries to remove the label awaiting reviews but the bot adds it back as it still thinks the review is pending.

Proposal:

The solution would be to remove the awaiting reviews label when a pull request has been approved and not add it back on the pull_request:unlabeled event.

The above example is a rare case because the bot was not installed when the pull request was opened, thus the bot did not add awaiting reviews label and so it thought the review was still pending.

A minor nit...

      - name: Upload coverage to Codecov
        run: bash <(curl -s https://codecov.io/bash)
        if: ${{ success() }}

Is this backwards? If success then run... -- I know that it runs either way but I find it a bit confusing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.