Giter VIP home page Giter VIP logo

miq_bot's Introduction

ManageIQ Bot

CI Code Climate Test Coverage

The ManageIQ bot is the ManageIQ team's helper to automate various developer problems.

Usage

Automatic tasks

  • Commit monitoring and reaction to commits
    • Detection of changes to a product's Gemfile, and setting a label.
  • GitHub pull request monitoring
    • Label and comment on a PR when it becomes unmergeable.
    • Run Rubocop, haml-lint and yamllint against a PR diff and comment on any offenses found.

Requested tasks

The bot will react to direct messages in GitHub issues, performing actions on your behalf which would otherwise not be possible without commit rights to the repo. Just add a comment to any issue in a monitored repo, with each request on its own line, in the form @miq-bot command params. Available commands are below. Any command can also be pluralized, where sensible, or have the underscores replaced with hyphens.

  • add_label label1[, label2] Add one or more labels to an issue. Multiple labels should be comma-separated.

    Example: @miq-bot add_labels label1, label2

  • remove_label label1[, label2] Remove one or more labels to an issue. Multiple labels should be comma-separated.

    Example: @miq-bot remove_label wontfix

  • assign [@]user Assign the issue to the specified user. The leading @ for the user is optional. The user must be in the Assignees list.

    Example: @miq-bot assign @user

  • unassign [@]user Unassign the issue or pull request to the specified user(s). The leading @ for the user is optional. The user(s) must be assigned to the issue or pull request and they must be comma separated.

    Example: @miq-bot unassign @user1[, @user2]

  • add_reviewer [@]user Request for pull request review the specified user. The leading @ for the user is optional. The users must be separated by a comma and they must be in the Assignees list.

    Example: @miq-bot add_reviewer @user1[, @user2]

  • remove_reviewer [@]user Remove a request for pull request review from the specified user. The leading @ for the user is optional. The user must be in the Assignees list.

    Example: @miq-bot remove_reviewer @user

  • set_milestone milestone_name Set the specified milestone on the issue. Do not wrap the milestone in quotes.

    Example: @miq-bot set_milestone Sprint 27

  • move_issue [organization_name/]repo_name Moves the issue to the specified repo. The bot will open a new issue with your original title and description and close the current one. Useful for reorganizing issues opened on the core ManageIQ/manageiq repo to a more appropriate project (a provider or other ManageIQ plugin).

    • This command is restricted to members of the organization containing the issue.
    • The repository being moved to must be under the same organization as the issue being moved.
    • You cannot move a pull request.

    Example: @miq-bot move_issue manageiq-providers-amazon

  • close_issue Closes the issue.

    • This command is restricted to members of the organization containing the issue.
    • Restricted use on pull requests. Only the pull request author or a committer can close pull requests (who have access to close them directly anyway). This is intended.

    Example: @miq-bot close_issue

  • cross_repo_test test_repos* [including include_repos*] Runs cross repo tests that include the current PR code base. A pull request will be created in the manageiq-cross_repo-tests repo where each of the test_repos will be a separate entry in the test matrix. Those tests will run in the context of all repos declared in test_repos + include_repos + the PR itself.

    • This command is restricted to members of the organization containing the issue.
    • Restricted use on pull requests. This doesn't make sense to use on issues since there is no code to run.

    Example: @miq-bot cross_repo_tests ManageIQ/manageiq#1234 including more_core_extensions@1234abcd

    Also accepts repository groups, e.g. /providers, /core, /all

    Example: `@miq-bot cross_repo_tests ManageIQ/manageiq#1234, /providers including more_core_extensions@1234abcd

Development

Prerequisites

  • Ruby 2.2 with bundler
  • Redis ~> 2.8.10
  • Postgresql
  • pip

Setup

  1. Fork https://github.com/ManageIQ/miq_bot

  2. Clone the miq_bot repo and add the upstream remote:

    git clone [email protected]:<your github handle>/miq_bot.git
    cd miq_bot
    git remote add upstream [email protected]:ManageIQ/miq_bot.git
    git fetch —-all
    
  3. Install any dependencies:

    bundle install
    sudo pip install yamllint
    
  4. Create the database.yml file.

    cp config/database.tmpl.yml config/database.yml
    

    Edit the database.yml file, and change username and password for your PostgreSQL database.

  5. Set up the databases:

    bundle exec rake db:setup
    
  6. Create/fork a test repository and add it to the database (replace miq-test/sandbox with your test repository below). Note that the bot account you are using must have SSH keys defined correctly if you plan to use an SSH based URL, otherwise you should use an HTTPS based URL.

    bundle exec rails runner 'Repo.create_from_github!("miq-test/sandbox", "https://github.com/miq-test/sandbox.git")'
    
  7. Create a custom Procfile for development. Any changes you make to this file won't be tracked.

    cp Procfile.tmpl Procfile
    
  8. Either start redis as a daemon or have foreman start it for you by adding this to the Procfile:

    redis: redis-server /path/to/redis.conf  # change this to the redis.conf provided by your package manager.
  9. Configure the bot settings. First copy the template:

    cp config/settings.yml config/settings/development.local.yml
    

    Then set to the following values:

    # config/development.local.yml:
    
    #   Try to use a test account, as the account in question uses notifications
    #   and needs to read them and modify them.
    github_credentials:
      username: "some-test-account"
      password: # account token goes here
    
    # Optional; See the section on enabling/disabling workers
    github_notification_monitor:
      included_repos: ["miq-test/sandbox"]
  10. You should now be able to run foreman start to start the services listed in the Procfile.

  11. See log/development.log and log/sidekiq.log to make sure things are starting.

  12. You should be able to open a new PR on the miq-test/sandbox repository with any rubocop problems, such as MixedCaseConstant = 1. Wait a few minutes and see if it comments on your PR.

Enabling and Disabling workers

By default, most workers are enabled for all repos (except for the MergeTargetTitler which is disabled for all repos), however if you would like to change which workers are enabled or disabled, the following configuration settings can be changed:

worker_a:  # Will run in all repos

worker_b:  # Will only run in the specified repos
  included_repos:
  - "org1/repo1"
  - "org2/repo2"

worker_c:  # Will run in all repos except the specified repos
  excluded_repos:
  - "org1/repo1"
  - "org2/repo2"

worker_d:  # Will raise an exception, since you should not specify both
  included_repos:
  - "org1/repo1"
  excluded_repos:
  - "org2/repo2"

worker_e:  # Effectively disables the worker
  included_repos: []

miq_bot's People

Contributors

abellotti avatar agrare avatar bdunne avatar blomquisg avatar carbonin avatar cfme-bot avatar chessbyte avatar chrisarcand avatar d-m-u avatar dependabot[bot] avatar djberg96 avatar europ avatar fryguy avatar imtayadeway avatar jjlangholtz avatar jrafanie avatar kbrock avatar mend-bolt-for-github[bot] avatar nicklamuro avatar skateman avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

miq_bot's Issues

Support leading keywords on BZ URLs

At a minimum just allow the common words from GitHub like "Fixes", "Resolves" in front of a BZ URL.

Eventually "Fixes" could actually mean moving the BZ to POST automatically.

Add ability for robocop commenter to ignore certain changes

Use case: I am renaming a large old file (shows up as an add and delete in git) without changing any of the content. Rubocop comments on the PR with 400+ issues in the old file.

It would be nice to be able to add [no complaints] to the commit message and have rubocop ignore those changes in its comment.

Warn that t.timestamp(s) migration statements are changing default from null:true to null:false

We should detect migrations mentioning these statements without a null value and warn that the default is changing from true to false in rails 5.

From ManageIQ/manageiq#3145

Use existing timestamp behavior of allowing nulls (t.timestamp, t.timestamps)

Fixes warning:
`#timestamp` was called without specifying an option for `null`.
In Rails 5, this behavior will change to `null: false`.
You should manually specify `null: true` to prevent the behavior of your existing migrations from changing.

Bot should remind PR authors to add a description

When a PR is submitted without a description, the bot should remind people to add a description that describes why the PR is important to the ManageIQ codebase.

Possibly even include some rules around not just describing the changes, but describing the purpose of the changes.

Warn if a PR changes application code without tests

It would be nice if the bot pinged the author of this PR to ensure they clarify why tests aren't included in the PR. Many times the reviewer needs to ask this and either forgets or feels like the bad guy. The bot should do this automatically to keep humans out of it.

It could be as simple as checking for any changes in test or spec directories.

“Please clarify why this PR doesn't include tests, whether existing tests cover the code in the PR or some other reason.”

Restarting errored Travis builds

Problem: Sometimes Travis build error (for timeouts or other reasons than code failures). I don't have permissions to restart because I'm not a merger on manageiq. So I need to either close and re-open the PR to re-run everything or ping someone to re-run the component that errored.

Possible solutions:

  • Allow a PR comment like "@miq-bot travis_restart vmdb"
  • Let the bot automatically restart errored builds (not sure if there are potential loop conditions)

Linting HAML files

It'd be great when the bot could parse also the *.haml files.
By forcing the haml-lint gem to use rubocop and passing the original .rubocop.yml config file it's quite easy.

What do you think? #30

Warn if a PR does not have a component (purple) label

As a reviewer, I would like to be able to find all PRs that are in the Providers space easily. The only way I know how to do this is to query for all PRs that have a providers label. This relies on someone setting the providers label on provider-specific PRs.

I would like it better if the bot simply nagged the PR author to label the PR.

Scan for all PRs older than 1 day and that do not have a component (blue) label. For each PR in this category, send an email to the commiters list and to the PR author.

The Email should contain the link to the PR as well as some short instructions on how to apply a label if the PR author does not have access to label PRs.

Component (or, blue) labels include:

  • api
  • appliance
  • fleecing
  • providers

... and may contain slashes:

  • providers/containers
  • appliance/console

Check for migrations modifying tables

Check for any new migrations that create_table or rename_table as there may be side effects due to replication. In a PR, let the author know via comment.

RubocopChecker: Links to documentation are broken

It seems that the documentation links are broken because rubocop changed the casing of the module.

http://www.rubydoc.info/gems/rubocop/frames/Rubocop/Cop/Style/CaseIndentation
vs
http://www.rubydoc.info/gems/rubocop/frames/RuboCop/Cop/Style/CaseIndentation

We can should probably

Comment on a PR when it passes or fails tests, deleting any prior comments on passed/failed tests

Use case:
A reviewer will look at a PR and possibly give it a 👍 , but want to wait for the tests to pass. Said reviewer forgets to come back to it. Openshift bot does something similar where you can add a comment with [merge] and it will run the tests and merge if it passes. Additionally, it would be convenient to be notified when the tests fail.

For example:
openshift/origin#448 (failed -> doesn't merge and comments)
openshift/origin#409 (passed -> merged and comments)

Check for misnamed specs

Check the specs directory (except spec/support/* and spec_helper.rb) for new files that don't end in _spec.rb

Print the current rubocop.yml location and sha1

For newcomers, we should link to the current yml and the how to setup rubocop locally doc.

For oldies, it would be useful to easily grab the new yml if there are cop messages online but not locally (user has an old yml)

For maintainers, it would be useful to link directly to the yml the bot is using,at a commit, to verify they updated the bot to the latest code.

Summary:

  • Current yml so users can shift click and download
  • Link to current bot commit or tag (run using bot at commit xyz)
  • link to setting up rubocop locally

git diff emits invalid UTF8 byte sequence

Fix when git diff has invalid utf-8 byte sequences:
Example on cfme:
git diff --patience -U0 --no-color 35f076630075fca14ecf6b12589fe8254f4911b1\~..a74df1236223d4d0726dca368c244bcb7a184ff9

Label "Needs triage" for all new issues

When people triage them, they can remove this label. This should help to keep track of issues.

The alternative is to have a way to filter all issues without the normal set of component labels "appliance" or "UI" , etc.

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.