Coder Social home page Coder Social logo

alvarocavalcanti / pierre-decheck Goto Github PK

View Code? Open in Web Editor NEW
24.0 6.0 13.0 699 KB

Dependent Pull Requests Checker

License: MIT License

Makefile 1.43% Python 98.03% Shell 0.17% Dockerfile 0.33% Procfile 0.04%
up-for-grabs python3 python python-3 pull-requests dependency-analysis dependency-checker

pierre-decheck's Introduction

Pierre DeCheck - A Dependent Pull-Request Checker

DISCLAIMER: THIS REPO IS NOW ARCHIVED

CircleCI

Key Features

It checks for dependent pull requests, both same-repo and external, which should be defined by keywords on either pull request's body or comments:

  • Same repo: Depends on #1
  • External:
    • Depends on alvarocavalcanti/pierre-decheck#1
    • Depends on https://github.com/alvarocavalcanti/pierre-decheck/pull/1

Pierre will perform checks only upon PR creation and Comment Activity (added/removed). In every case it will fetch all the PR's bodies (the PR body itself and from all its comments), extract the dependencies and perform the checks. Thus, it does not observe the dependencies themselves and re-run the checks if their status change.

For now, the best way of re-checking the dependencies statuses is to add a new comment. I suggest pierre re-check. ๐Ÿ˜ƒ

Installation

  1. Checkout/download this repo
  2. Publish the app wherever suits you the best (it has both Heroku and AWS Lambda configuration in place) and take note of the app's URL
  3. Go to the repository you want to set it up, then go to Settings > Webhooks > Add Webhook
  4. Under "Payload URL" enter <YOUR_APP_URL>/webhook
  5. Under "Content type" select "application/json"
  6. Under "Which events would you like to trigger this webhook?" select "Let me select individual events." and then: "Commit comments", "Issue comments", "Issues", "Pull requests" and "Pull request review comments"
  7. Finally, make sure "Active" is selected and then create the webhook
  8. Create an access token for your repo and grant it with either repo:status for Public repos or repo (Full control of private repositories) for Private repos.
  9. Add the token as an environment variable for you app, labeled GITHUB_TOKEN

Usage

  1. Create a pull request on the repository that has pierre set up
  2. Add the keywords Depends on # (for same-repo) or "Depends on owner/repo#" (for external) followed by an issue/pull request number, Depends on #2 or Depends on owner/repo#2, to the pull request description, or later, as a comment. (Alternatively, Depends on <GITHUB_URL_OF_ISSUE_OR_PR> style can be used) Pull Request Checks Example
  3. Every time a comment is added or deleted, pierre will check the dependencies and update the "Checks" section: Pull Request Checks Example

Optional feature: Depending on a Released PR

Usually when one has external dependencies (other repos) these dependencies requires not only a PR to be merged, but also released. To that extent, Pierre offers an optional configuration: by setting the environment variable RELEASE_LABEL to any given value, Pierre will then consider any dependency as met only if its state is closed and if it also has the proper label. On the screenshot below it's possible to see how it looks like when the dependency is closed but does not have the release label:

Pull Request Checks Exemple

Contributing

Contributing document.

Code Style

Code style document.

Recommended IDEs

  1. PyCharm - Community edition is free and decent, Professional edition is awesome
  2. VisualStudio Code - Completely free, large amount of extensions and great community support

References

  1. Github Repo Statuses
  2. Github Webhooks
  3. Github Events
  4. Github Event Types & Payloads
  5. Building a CI Server (Github Guide)

pierre-decheck's People

Contributors

alvarocavalcanti avatar dependabot[bot] avatar kenshoo-build avatar mosheeshel avatar pomu0325 avatar robotboyfriend 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pierre-decheck's Issues

Create a docker environment

We should have a docker-composer.yml that creates not only a container for the web app, but that also creates a sidecar container to be used as a remote interpreter by the IDE.

Make a UI for the details endpoint

Currently, the details endpoint displays raw JSON data. It should display that data in a more user-friendly manner.

There is no current requirement for technology to be used here, and for the data itself, it only needs to be the same that is currently provided.

Ability to optionally use a given label to determine if dependency is met

Context

In some projects, their dependency to other projects requires not only for a given issue to be closed, but also to be released (or deployed, etc). In these cases, Pierre should take a given label into consideration.

Approach

There should be an optional environment variable named RELEASE_LABEL. If set, its value should be used as the released label and taken into consideration when checking a dependency.

Dependency created through review comment is ignored by later comments

Steps to reproduce

  • Write review comments with dependency description like depends on #xx
    • Then check fails:

  • Write PR comments without dependency description.
    • ๐Ÿ’ฅ Then dependency is cleared unexpectedly:

Cause

Dependencies are checked only through event payload and comments here:

def get_all_bodies(data):
bodies_from_event = get_bodies(data)
bodies_from_comments = get_bodies_from_pr_comments(data)

Setup CI

  1. Setup a CI environment for the project
  2. Add a CI button to the README.md

Provide an asynchronous mode

We should have two modes: synchronous and asynchronous. Which should be activated based on a boolean environment variable: SYNCHRONOUS_MODE

The implementation itself is still open for debate. I have a good experience with Celery and RabbitMQ but maybe Python's asyncio might do the job?

Handle new payload for issue_comment

{
  "action": "created",
  "issue": {
    "url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues/28",
    "repository_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck",
    "labels_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues/28/labels{/name}",
    "comments_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues/28/comments",
    "events_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues/28/events",
    "html_url": "https://github.com/alvarocavalcanti/pierre-decheck/issues/28",
    "id": 303094723,
    "number": 28,
    "title": "Properly handle unknown dependencies",
    "user": {
      "login": "alvarocavalcanti",
      "id": 512234,
      "avatar_url": "https://avatars2.githubusercontent.com/u/512234?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/alvarocavalcanti",
      "html_url": "https://github.com/alvarocavalcanti",
      "followers_url": "https://api.github.com/users/alvarocavalcanti/followers",
      "following_url": "https://api.github.com/users/alvarocavalcanti/following{/other_user}",
      "gists_url": "https://api.github.com/users/alvarocavalcanti/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/alvarocavalcanti/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/alvarocavalcanti/subscriptions",
      "organizations_url": "https://api.github.com/users/alvarocavalcanti/orgs",
      "repos_url": "https://api.github.com/users/alvarocavalcanti/repos",
      "events_url": "https://api.github.com/users/alvarocavalcanti/events{/privacy}",
      "received_events_url": "https://api.github.com/users/alvarocavalcanti/received_events",
      "type": "User",
      "site_admin": false
    },
    "labels": [
      {
        "id": 802967090,
        "url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/labels/bug",
        "name": "bug",
        "color": "ee0701",
        "default": true
      },
      {
        "id": 845427172,
        "url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/labels/up-for-grabs",
        "name": "up-for-grabs",
        "color": "e5cd14",
        "default": false
      }
    ],
    "state": "open",
    "locked": false,
    "assignee": null,
    "assignees": [

    ],
    "milestone": null,
    "comments": 1,
    "created_at": "2018-03-07T13:18:38Z",
    "updated_at": "2018-03-07T13:20:57Z",
    "closed_at": null,
    "author_association": "OWNER",
    "body": "Currently, Pierre does not handle unknown dependencies."
  },
  "comment": {
    "url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues/comments/371136088",
    "html_url": "https://github.com/alvarocavalcanti/pierre-decheck/issues/28#issuecomment-371136088",
    "issue_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues/28",
    "id": 371136088,
    "user": {
      "login": "alvarocavalcanti",
      "id": 512234,
      "avatar_url": "https://avatars2.githubusercontent.com/u/512234?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/alvarocavalcanti",
      "html_url": "https://github.com/alvarocavalcanti",
      "followers_url": "https://api.github.com/users/alvarocavalcanti/followers",
      "following_url": "https://api.github.com/users/alvarocavalcanti/following{/other_user}",
      "gists_url": "https://api.github.com/users/alvarocavalcanti/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/alvarocavalcanti/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/alvarocavalcanti/subscriptions",
      "organizations_url": "https://api.github.com/users/alvarocavalcanti/orgs",
      "repos_url": "https://api.github.com/users/alvarocavalcanti/repos",
      "events_url": "https://api.github.com/users/alvarocavalcanti/events{/privacy}",
      "received_events_url": "https://api.github.com/users/alvarocavalcanti/received_events",
      "type": "User",
      "site_admin": false
    },
    "created_at": "2018-03-07T13:20:56Z",
    "updated_at": "2018-03-07T13:20:56Z",
    "author_association": "OWNER",
    "body": "As can be seen here https://github.com/alvarocavalcanti/pierre-decheck/pull/24 it does not display any dependency check at all."
  },
  "repository": {
    "id": 117260108,
    "name": "pierre-decheck",
    "full_name": "alvarocavalcanti/pierre-decheck",
    "owner": {
      "login": "alvarocavalcanti",
      "id": 512234,
      "avatar_url": "https://avatars2.githubusercontent.com/u/512234?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/alvarocavalcanti",
      "html_url": "https://github.com/alvarocavalcanti",
      "followers_url": "https://api.github.com/users/alvarocavalcanti/followers",
      "following_url": "https://api.github.com/users/alvarocavalcanti/following{/other_user}",
      "gists_url": "https://api.github.com/users/alvarocavalcanti/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/alvarocavalcanti/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/alvarocavalcanti/subscriptions",
      "organizations_url": "https://api.github.com/users/alvarocavalcanti/orgs",
      "repos_url": "https://api.github.com/users/alvarocavalcanti/repos",
      "events_url": "https://api.github.com/users/alvarocavalcanti/events{/privacy}",
      "received_events_url": "https://api.github.com/users/alvarocavalcanti/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/alvarocavalcanti/pierre-decheck",
    "description": "Checks the Dependencies of Pull Requests",
    "fork": false,
    "url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck",
    "forks_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/forks",
    "keys_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/teams",
    "hooks_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/hooks",
    "issue_events_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues/events{/number}",
    "events_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/events",
    "assignees_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/assignees{/user}",
    "branches_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/branches{/branch}",
    "tags_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/tags",
    "blobs_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/languages",
    "stargazers_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/stargazers",
    "contributors_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/contributors",
    "subscribers_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/subscribers",
    "subscription_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/subscription",
    "commits_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/contents/{+path}",
    "compare_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/merges",
    "archive_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/downloads",
    "issues_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/issues{/number}",
    "pulls_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/labels{/name}",
    "releases_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/releases{/id}",
    "deployments_url": "https://api.github.com/repos/alvarocavalcanti/pierre-decheck/deployments",
    "created_at": "2018-01-12T15:56:48Z",
    "updated_at": "2018-03-07T12:11:49Z",
    "pushed_at": "2018-03-07T13:17:09Z",
    "git_url": "git://github.com/alvarocavalcanti/pierre-decheck.git",
    "ssh_url": "[email protected]:alvarocavalcanti/pierre-decheck.git",
    "clone_url": "https://github.com/alvarocavalcanti/pierre-decheck.git",
    "svn_url": "https://github.com/alvarocavalcanti/pierre-decheck",
    "homepage": "",
    "size": 502,
    "stargazers_count": 2,
    "watchers_count": 2,
    "language": "Python",
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "forks_count": 0,
    "mirror_url": null,
    "archived": false,
    "open_issues_count": 6,
    "license": {
      "key": "mit",
      "name": "MIT License",
      "spdx_id": "MIT",
      "url": "https://api.github.com/licenses/mit"
    },
    "forks": 0,
    "open_issues": 6,
    "watchers": 2,
    "default_branch": "master"
  },
  "sender": {
    "login": "alvarocavalcanti",
    "id": 512234,
    "avatar_url": "https://avatars2.githubusercontent.com/u/512234?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/alvarocavalcanti",
    "html_url": "https://github.com/alvarocavalcanti",
    "followers_url": "https://api.github.com/users/alvarocavalcanti/followers",
    "following_url": "https://api.github.com/users/alvarocavalcanti/following{/other_user}",
    "gists_url": "https://api.github.com/users/alvarocavalcanti/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/alvarocavalcanti/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/alvarocavalcanti/subscriptions",
    "organizations_url": "https://api.github.com/users/alvarocavalcanti/orgs",
    "repos_url": "https://api.github.com/users/alvarocavalcanti/repos",
    "events_url": "https://api.github.com/users/alvarocavalcanti/events{/privacy}",
    "received_events_url": "https://api.github.com/users/alvarocavalcanti/received_events",
    "type": "User",
    "site_admin": false
  }
}

Add the ability to observe the the dependencies and update the dependent PR

Summary

Pierre should be able to check the dependencies for any given PR without the need of an event.

Once that dependency is added to a PR, Pierre should keep track of both for status changes.

To Keep In Mind

Even thought this feels like a standard behavior, tools like Jenkins still rely on events from the PR (Jenkins please in order to re-run the tests).

Also, this is important, Pierre should remain as small-projects-friendly as possible. Meaning that if this feature should be implemented, it should be behind of a feature flag (in the form of a environment variable), so that if it requires more resources (database, task queue, automated jobs, etc) people that cannot afford them will still able to use Pierre.

Thanks

To @supernova32 for suggesting this feature ๐Ÿ˜ƒ

Convert pierre-decheck into a GitHub Action

Is there any plan to provide this as a GitHub Action?
The question is somehow related to #62
It shouldn't be too much effort since a Dockerfile already exists

Benefits:

  • No self hosting required
  • Easy to setup/configure
  • No Auth troubles (github provides a specific token for GitHub actions)
  • Fully managed in the GitHub context

Accept installation events

When people install Pierre the webhook endpoint receives an installation event, but such event is not supported.

This is the request header:

INFO:flask.app:Received request with headers
Host: pierre-de-check.herokuapp.com
Connection: close
Accept: */*
User-Agent: GitHub-Hookshot/f1003bc
X-Github-Event: installation
X-Github-Delivery: bcafbd80-ffdd-11e9-8e8d-0fab26a6ebde
Content-Type: application/json
X-Request-Id: 271d6379-97cf-46bb-adc1-91f64d716d94
X-Forwarded-For: 140.82.115.251
X-Forwarded-Proto: https
X-Forwarded-Port: 443
Via: 1.1 vegur
Connect-Time: 1
X-Request-Start: 1572966400529
Total-Route-Time: 0
Content-Length: 2903

This is the request body:

{
  "action": "created",
  "installation": {
    "id": 5008055,
    "account": {
      "login": "markobrien-wpengine",
      "id": 52954168,
      "node_id": "MDQ6VXNlcjUyOTU0MTY4",
      "avatar_url": "https://avatars2.githubusercontent.com/u/52954168?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/markobrien-wpengine",
      "html_url": "https://github.com/markobrien-wpengine",
      "followers_url": "https://api.github.com/users/markobrien-wpengine/followers",
      "following_url": "https://api.github.com/users/markobrien-wpengine/following{/other_user}",
      "gists_url": "https://api.github.com/users/markobrien-wpengine/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/markobrien-wpengine/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/markobrien-wpengine/subscriptions",
      "organizations_url": "https://api.github.com/users/markobrien-wpengine/orgs",
      "repos_url": "https://api.github.com/users/markobrien-wpengine/repos",
      "events_url": "https://api.github.com/users/markobrien-wpengine/events{/privacy}",
      "received_events_url": "https://api.github.com/users/markobrien-wpengine/received_events",
      "type": "User",
      "site_admin": False
    },
    "repository_selection": "selected",
    "access_tokens_url": "https://api.github.com/app/installations/5008055/access_tokens",
    "repositories_url": "https://api.github.com/installation/repositories",
    "html_url": "https://github.com/settings/installations/5008055",
    "app_id": 8953,
    "target_id": 52954168,
    "target_type": "User",
    "permissions": {
      "issues": "read",
      "metadata": "read",
      "pull_requests": "read",
      "statuses": "write"
    },
    "events": [
      "issue_comment",
      "pull_request",
      "pull_request_review",
      "pull_request_review_comment"
    ],
    "created_at": 1572966343,
    "updated_at": 1572966343,
    "single_file_name": None
  },
  "repositories": [
    {
      "id": 216002907,
      "node_id": "MDEwOlJlcG9zaXRvcnkyMTYwMDI5MDc=",
      "name": "churn-predictor",
      "full_name": "markobrien-wpengine/churn-predictor",
      "private": True
    }
  ],
  "requester": None,
  "sender": {
    "login": "markobrien-wpengine",
    "id": 52954168,
    "node_id": "MDQ6VXNlcjUyOTU0MTY4",
    "avatar_url": "https://avatars2.githubusercontent.com/u/52954168?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/markobrien-wpengine",
    "html_url": "https://github.com/markobrien-wpengine",
    "followers_url": "https://api.github.com/users/markobrien-wpengine/followers",
    "following_url": "https://api.github.com/users/markobrien-wpengine/following{/other_user}",
    "gists_url": "https://api.github.com/users/markobrien-wpengine/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/markobrien-wpengine/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/markobrien-wpengine/subscriptions",
    "organizations_url": "https://api.github.com/users/markobrien-wpengine/orgs",
    "repos_url": "https://api.github.com/users/markobrien-wpengine/repos",
    "events_url": "https://api.github.com/users/markobrien-wpengine/events{/privacy}",
    "received_events_url": "https://api.github.com/users/markobrien-wpengine/received_events",
    "type": "User",
    "site_admin": False
  }
}

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.