Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor to improve synchronization and testability #45

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Commits on Jul 2, 2019

  1. Test authorization code

    Pull code that creates a comment on a pull request out of the
    authorization check, and add tests around the authorization checks.
    
    After pulling out the code that creates a comment, we still need to know
    what the text of the comment will be, so change from a function that
    returns a True on success and a False on failure to a function that
    returns a True on success and raises an Exception (with the failure
    comment) on failure.
    bryanburgers committed Jul 2, 2019
    Configuration menu
    Copy the full SHA
    f1fd009 View commit details
    Browse the repository at this point in the history
  2. Replace db_query with LockingDatabase

    Remove the free function `db_query` in favor of a `LockingDatabase`
    class that wraps a database connection.
    
    This is done so that, in order for a class to use the database, it only
    needs its `db` instance, instead of needing both a `db` instance and a
    `db_query` function.
    
    This allows us to break out classes into separate files.
    bryanburgers committed Jul 2, 2019
    Configuration menu
    Copy the full SHA
    6053821 View commit details
    Browse the repository at this point in the history
  3. Pull PullReqState into its own file

    Extract PullReqState into its own file for code readability.
    
    Because PullReqState shares some constants with main and server, extract
    those constants into a `consts.py` file as well.
    bryanburgers committed Jul 2, 2019
    Configuration menu
    Copy the full SHA
    47e0117 View commit details
    Browse the repository at this point in the history
  4. Parse homu state out of comments

    For some critical comments, Homu adds extra information about its state
    in the form of a JSON blob to the comment that isn't visible to the user
    but is visible in the source for the comment. For example, Homu may
    leave a comment like the following, where the JSON blob is not visible
    because of the `<!-- .. -->` markdown/html comments.
    
        ⌛ Trying commit abcdef with merge 012345...
    
        <!-- homu: {"type":"TryBuildStarted","head_sha":"abcdef","merge_sha":"012345"} -->
    
    This change parses this extra information out of the comments and makes
    it available to the initial synchronization algorithm.
    bryanburgers committed Jul 2, 2019
    Configuration menu
    Copy the full SHA
    4c327b4 View commit details
    Browse the repository at this point in the history
  5. Structure for process_event; test approvals

    Create the general structure for `process_event` and its testing, and
    get a long way toward testing approval comments.
    bryanburgers committed Jul 2, 2019
    Configuration menu
    Copy the full SHA
    a5fe2e6 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b693b15 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    7f9443b View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    2c6d3b3 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    2526ffe View commit details
    Browse the repository at this point in the history
  10. Keep track of cursor and break up status

    Break up the "status" field into multiple orthogonal state fields:
    
    * build state (whether the primary is running or has succeeded or
      failed)
    * try state (whether the most recent try is running or has succeeded or
      failed)
    * approval state (whether the pull request is approved)
    
    Previously (and still) these were mostly possible to determine by
    looking at `state.get_status()` and `state.try_`, but storing them
    separately helps make state changes more explicit.
    
    Also, keep track of the current github synchronization cursor in the
    pull request state, so that we can use it later.
    bryanburgers committed Jul 2, 2019
    Configuration menu
    Copy the full SHA
    a024fbe View commit details
    Browse the repository at this point in the history
  11. Test that @bors retry resets the state

    Test that issuing a `@bors retry` command moves the state from 'pending'
    to '' for pending pull requests. This is frequently used as a way to
    yield the current build to a different pull request.
    bryanburgers committed Jul 2, 2019
    Configuration menu
    Copy the full SHA
    a9234c7 View commit details
    Browse the repository at this point in the history
  12. Handle build timeout comments

    Homu creates a message when a try or build timeout occurs. Handle this
    to keep the state properly updated.
    bryanburgers committed Jul 2, 2019
    Configuration menu
    Copy the full SHA
    2b83596 View commit details
    Browse the repository at this point in the history

Commits on Jul 8, 2019

  1. Configuration menu
    Copy the full SHA
    3b2562f View commit details
    Browse the repository at this point in the history

Commits on Jul 30, 2019

  1. Pass around less repository state!

    Add more of the state to the Repository class, and make each
    PullReqState reference it's Repository and get information from there.
    bryanburgers committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    c2b343a View commit details
    Browse the repository at this point in the history
  2. Switch to github_v4.py

    bryanburgers committed Jul 30, 2019
    Configuration menu
    Copy the full SHA
    678a195 View commit details
    Browse the repository at this point in the history

Commits on Aug 16, 2019

  1. Include build history when parsing history

    Include a history of all of the tries and all of the builds when parsing
    the history of a pull request.
    bryanburgers committed Aug 16, 2019
    Configuration menu
    Copy the full SHA
    68bb030 View commit details
    Browse the repository at this point in the history

Commits on Aug 21, 2019

  1. Calculate status, try_ and others from history

    Previously, we discretely set `status`, `try`, `build_state`, and
    `try_state` on each event. With the addition of the run histories, we
    can now glean all of this information from those histories instead of
    tracking them independently.
    
    The results appear to all be identical on the current Homu queue except
    for one edge case: a pull request was tried, approved, then unapproved.
    
    - Using the previous method, the status would be '', because approval
      changes the status from 'success (try)' to '', and unapproval doesn't
      change the status.
    
    - Using the current method, the status would be 'success (try)', because
      a successful try has occured for the relevant commit hash and the PR
      isn't approved.
    bryanburgers committed Aug 21, 2019
    Configuration menu
    Copy the full SHA
    a15e1da View commit details
    Browse the repository at this point in the history