Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

prevent/reduce noise caused by PRs whose branches fail checks #1006

Open

Description

@aspiers

In order to reduce the burden on code reviewers and CI systems within a project, it would be useful to be able to prevent pull requests being submitted (i.e. created) until they meet certain checks, so that humans and CI systems don't waste cycles reviewing flawed submissions. In other words, a mechanism similar to the existing status checks mechanism could be created which would catch issues with a branch even before a PR is created from that branch.

Motivation

To understand this better, let's consider different types of checks:

  • Some tests, such as integration tests and end-to-end system tests, can be too complex or resource-intensive to be run locally, so they need to be implemented centrally on shared resources and 3rd-party services which integrate with GitHub.
  • In contrast other tests, such as unit tests, lightweight functional tests, code coverage metrics, and code/style linters, can often be run both locally on a developer's machine and centrally in a shared CI system.

In some projects it may not be deemed worthwhile spending effort setting up certain tests so that they can run both locally and centrally, especially when centralized CI systems such as Travis CI make it so convenient to run tests in clean, isolated VMs or containers, and also provide UIs presenting the test results in helpful ways. Nevertheless, there still may be some cases where it is not only possible but also advantageous for checks to be run both locally and centrally: locally as a pre-emptive measure in order to reduce the burden on the centralized review processes, but then also centrally - once the local tests pass and the changes have been submitted for review - in order to guarantee that the quality required by the centralized checks is being upheld.

Real world use case

One simple example might be a local check preventing submission of a PR which contains merge commits. Most projects expect PR submissions to contain a linear sequence of single-parent commits. Any PR containing merge commits submitted to such a project is likely to have been made through a misunderstanding of how PRs work, or as a result of forgetting to squash parts of the history before submitting. In this case it would be more efficient if the person trying to submit the PR was notified of their mistake and how to fix it, so that no reviewer or CI system spends cycles reviewing a PR which is obviously flawed.

Implementation possibilities

One difficulty posed by the requirement to introduce local checks as part of the PR submission process is determining the best time and place to run those checks.

Running them via a pre-push client-side hook has at least one big problem: there is no way for the hook code to distinguish between a push to a temporary, semi-private WIP branch in a developer's fork, vs. a push to public branch which is the head of a pull request.

Running the checks instead via a pre-receive server-side hook (which GitHub does not currently allow) would not solve this problem, and it would also prevent the checks running locally.

It is worth noting that Gerrit has the ability to reject review pushes, but the recommendation to avoid that hook blocking suggests that it is not intended to be used in order to run anything other than simple checks.

I'm not sure if there's any obviously clean way to implement this. However, there is a simple workaround ...

Workaround

Reviewers can build custom PR searches which include status:success. That way they only see PRs which have already passed all the status checks. This helps reduce the amount of time reviewers waste, although some CI resource cycles still get wasted.

Activity

  1. added
    parity
    on Mar 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    paritypull-requests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions