Code Monkey home page Code Monkey logo

xdev-bot's People

Contributors

andersy005 avatar jukent avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

jukent

xdev-bot's Issues

Payload Examples

@kmpaul, @jukent

I've added a couple of payload examples here for anyone who is interested in playing with those in order to come with ideas for the Github App. Let me know if you have any questions.

New XDev Bot (Main Issue)

After looking at the details required to complete #96, I've encountered some complications that might require a different approach to the bot.

We do not need a database file

I would like to remove the database CSV file stored on S3 because (and probably for no reason related to S3) it gets out of sync with the actual project board. However, the database is required for any Issue/PR events triggering card movement (i.e., to Backlog or Done). You need a mapping from Issue/PR ID to Project Card ID, which is currently what the database provides.

I believe the solution to this is for the Bot/App to query GitHub when it is first launched to construct the actual Project Board contents and build the Issue/PR ID --> Card ID mapping. There will be no need to save it to a file.

We need easier access & authentication

I encountered a problem trying to log in as the XDev-Bot GitHub user, because the authorized email address for the account is Anderson's. Essentially, I could not verify that I was Anderson. That is a complication that I think should be removed. Everyone on the team should be able to access the XDev-Bot.

I think that the XDev-Bot should not be a "user" but a registered GitHub App. An App has its own identity and doesn't need a user as a proxy for authentication purposes. Also, with a registered App, as far as I know, it provides its own webhook. That means we do not need to complete 2 separate steps every time a new repo is created that we want to watch as a team (i.e., add the XDev-Bot user as a collaborators and create the webhook). We will only need to enable the App on the repo we want to watch (1 step).

Use a more basic tool for GitHub API

This one is less important, I suppose, but it seems to me that the GitHub API documentation is written assuming a general tool that can be used for RESTful GET/PUT commands. I don't like that the Gidgethub documentation is pretty sparse, so I am left guessing how to pass certain headers or how the payload is converted into a Gigdethub event. I would prefer that what we use with the Bot/App should clearly match the GitHub API documentation. So, something like aiohttp should suffice. I don't think we need Gidgethub.

Events and their corresponding actions

@jukent, @kmpaul
Over the weekend, I added functionality to persist project cards info into a file using an xdev-bot S3 bucket hosted here. You may need to talk with Kevin to get your AWS credentials in order to access cisl-iowa account.

Here's what the dataframe constructed from the persisted database looks like:

screen shot 2019-02-25 at 8 22 19 am

@jukent, I wanted to let you know that I did some work on When a card is moved event in #19, #20, #21, and #22. However, there's still work to be done for this event, see project board section below.

Below is my attempt at jotting bot's workflow ideas down that we discussed last week. My objective is to compile ideas in to a list of tasks that can be implemented independently. Feel free to extend and improve this list ( I couldn't remember everything we talked about last Thursday). As always, let me know if you have any questions

Issues

  • When an issue is opened in repo x

    • Create card in xdev project board's backlog column
  • When an issue is reopened in repo x,

    • Move corresponding card in xdev PB back to backlog column. If the card doesn't exist, create one
    • Update updated_at column entry in database.csv
  • When an issue is closed in repo x,

    • Move corresponding card to Done column in xdev PB
    • Apply the following changes in database.csv
  df.loc[df["card_id"] == card_id, "column_name"] = column_name
  df.loc[df["card_id"] == card_id, "column_url"] = column_url
  df.loc[df["card_id"] == card_id, "column_id"] = column_id
  df.loc[df["card_id"] == card_id, "updated_at"] = updated_at
  df.loc[df["card_id"] == card_id, "assignees"] = card_mover

Pull requests

  • When a PR is opened in repo x,
    • Create a card in xdev PB' in progress column
    • Assign PR's author to the PR, and update assignees column entry in database.csv
    • Add Needs Review label
    • Add PR to open milestone/sprint
  • When a PR is closed in repo x
    • Move card in xdev PB to Done column
    • Apply the following changes in database.csv
  df.loc[df["card_id"] == card_id, "column_name"] = column_name
  df.loc[df["card_id"] == card_id, "column_url"] = column_url
  df.loc[df["card_id"] == card_id, "column_id"] = column_id
  df.loc[df["card_id"] == card_id, "updated_at"] = updated_at
  df.loc[df["card_id"] == card_id, "assignees"] = card_mover

Project Board

  • When a card is created in xdev PB
    • Add card entry info to database.csv in xdev-bot S3 bucket
  • When a card is moved and its note corresponds to an issue or PR
    • Assign card mover to the issue or PR
    • If the card is moved to Done Column
      • if the card's note is an open issue, close the issue in upstream repo x
      • if card's note is an open PR ( TBD)
    • Apply the following changes in database.csv
  df.loc[df["card_id"] == card_id, "column_name"] = column_name
  df.loc[df["card_id"] == card_id, "column_url"] = column_url
  df.loc[df["card_id"] == card_id, "column_id"] = column_id
  df.loc[df["card_id"] == card_id, "updated_at"] = updated_at
  df.loc[df["card_id"] == card_id, "assignees"] = card_mover
  • When a card is moved and its note doesn't correspond to an issue or PR
    • Assign card mover to the card by updating assignees column entry in database.csv
    • Apply the following changes in database.csv
  df.loc[df["card_id"] == card_id, "column_name"] = column_name
  df.loc[df["card_id"] == card_id, "column_url"] = column_url
  df.loc[df["card_id"] == card_id, "column_id"] = column_id
  df.loc[df["card_id"] == card_id, "updated_at"] = updated_at
  df.loc[df["card_id"] == card_id, "assignees"] = card_mover

Simplify Bot Operations

Need to make the project board easier to use for sprints:

  • Need to prevent forced moving of cards (except when "done")
  • Need to remove board database

Pull Request Assignees

I have tried assigning the user who submits a pull request for review as the assignee, but have not been successful yet. I am wondering if this is a feature we even want? It already says who submitted the pull request on the card - but is it useful to have it included if we filter by assignee?

Add label 'needs review' to pull request

I am trying to add labels to pull requests through xdev-bot. I would like the label 'needs review' when a pull request is created, remove that label when the pull request is closed, and add the label 'discarded' when a pull request is closed without merging. Currently only focusing on the 'needs review' label.

I am looking to this site for guidance: https://gidgethub.readthedocs.io/en/latest/
but the method is not identical.

Key lines in the pull_request.py code are:
labels_url = event.data["pull_request"]["base"]["repo"]["labels_url"]
await gh.post(labels_url, data=["test label"])

The error that comes up complains that ['test label'] is not an object.

I manually added a label (had to create it first and then add it) to a pull request to see what it looks like in the webhooks. There are some lines of note:

"labels": [
{
"id": 1251423450,
"node_id": "MDU6TGFiZWwxMjUxNDIzNDUw",
"url": "https://api.github.com/repos/NCAR/xdev-bot-testing/labels/test%20label",
"name": "test label",
"color": "b2721e",
"default": false
}

and
"labels_url": "https://api.github.com/repos/NCAR/xdev-bot-testing/labels{/name}",

I did not preserve their nesting because that is hard to see by visual inspection.

Also it might be important that the url of the label can be found at:
https://github.com/NCAR/xdev-bot-testing/labels

In the code, we will want to have the label action check if the label exists and then apply it, and we need to make sure we do not overwrite labels.

I have a few ideas to try, but I need to step away from this for a second.

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.