Giter Site home page Giter Site logo

swegner / merge-bot Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jasonkuster/merge-bot

0.0 2.0 0.0 140 KB

An automatic merge robot for the ASF.

Home Page: http://mergebot-vm.apache.org:8080

License: Apache License 2.0

Python 93.84% CSS 0.11% HTML 6.05%

merge-bot's Introduction

merge-bot

MergeBot is a bot for automatically merging pull requests with a mainline repository. It was written for the Apache Infrastructure team by Jason Kuster.

Usage

Authorized committers can comment on a pull request @asfgit merge. MergeBot polls repositories every fifteen seconds and upon seeing a request to merge will queue it and begin the merge process.

Implementation Info

MergeBot is written in Python and implemented in two parts: a frontend and a backend. These two pieces share information via a SQLite database; the backend writes info, and the frontend formats the information for viewing by users.

Frontend

The frontend is written using the Flask Python web framework. It is laid out as follows

  • /: Top-level view listing all of the currently-active mergebot pollers.
  • /{poller-name}/: Shows the active PR plus any queued PRs ready for merge.
  • /{poller-name}/{item-id}/: Shows MergeBot status updates for the work item in question.

The database is laid out as follows:

Poller

  • project_name: Project for which this poller is configured.
  • status: Status of this poller.
  • timestamp: Time at which we received the last poller heartbeat.
  • merger_started: Shows whether the merger is active.

QueuedItem

  • project_name: Project to which this item belongs.
  • item_id: Unique identifier for this work item.
  • timestamp: Time at which this item was added to the queue.

WorkItemStatus

  • project_name: Name of project which owns this work item.
  • item_id: Unique identifier for the work item in this project.
  • timestamp: Time at which this event occurred.
  • status: Status of the work item for this update.
  • info: String with more information about the status update.

Backend

The backend is implemented via three complementary components.

mergebot.py

mergebot.py owns the overall mergebot process -- it is responsible for reading in configs and spinning up subprocesses for each of the projects for which MergeBot is configured.

mergebot_poller.py

mergebot_poller.py is in charge of polling an SCM for changes. Currently GitHub is the only SCM available, but MergeBot has been designed to allow for triggering from other SCM systems.

Currently the GitHub poller reads from GitHub every 15 seconds, looking for either new PRs, or PRs which have been updated since the last time it checked. When it notices a PR, it checks the PR for any of the commands available (currently only merge) and that the comments have been made by an authorized user. Once this is validated, it takes the appropriate step -- in the case of merge, adding the PR to the merge queue.

merge.py

merge.py owns the process of actually merging a pull request. It reads the merge queue from mergebot_poller.py and performs the merges in the order in which they were received. Merges proceed in a few phases.

  • SETUP: The setup phase runs the appropriate Git commands to check out the PR and get it ready for verification.
  • VERIFY: The verify step pushes the changes under test to the mergebot branch on the project, at which point they are picked up by some CI system (currently Jenkins) for test. merge.py polls the CI system for the test results until results are available.
  • PREPARE: merge.py runs any commands necessary to prepare the PR for being merged with the mainline repository. For example, beam-site has MergeBot generate the appropriate HTML from the markdown pages checked in as part of the PR.
  • MERGE: MergeBot pushes the changes to the upstream repository.

All of these phases are communicated via WorkItemStatus updates.

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.