Coder Social home page Coder Social logo

pvscbot's Introduction

CI

Purpose

This bot exists to automate the development process/workflow for https://github.com/microsoft/vscode-python. It also acts as a simple demo of a GitHub bot running on Azure.

This bot is what is known as an OAuth app and is not a GitHub app. The differences come down to simplicity in authentication and how widely can the bot be deployed. Since this bot is only deployed for a single repository and the original author was intimately familiar with OAuth apps that was the route taken.

This bot also predates GitHub Actions being released. As such some things this bot does may be easier to do as an action.

Currently the bot will do the following things for you:

  1. Add/remove the classify label based on whether any other status label is set.
  2. When an issue is closed, remove any status-related labels, e.g. needs PR (with the idea that if an issue is re-opened then it needs to be re-evaluated as to why the issue is still open).

Deployment

Generically

On the deployment/hosting side

You must set two environment variables for the bot to function:

  1. GH_SECRET: secret between GitHub and your bot.
  2. GH_AUTH: Auth token for the bot to make changes in your repo.

The shared secret between GitHub and your bot is used to verify that the webhook payload actually originated from GitHub for your repository and isn't malicious. This is important as a malicious user could send fake webhook payloads to your bot and cause it to make changes on the malicious user's behalf.

The personal access token is to empower your bot to make changes to your repo on your behalf. You can use a token from your personal GitHub account or create a fake bot account. Make sure the token has the following scopes/permissions:

1.repo:public_repo (if your repo is public; adjust accordingly for your needs)

On the GitHub side

When creating the webhook you need to specify what events to send to your endpoint. This bot supports the following events:

  1. Issues

Azure

The bot is currently written to support Azure Functions running on Python 3.7.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

pvscbot's People

Contributors

brettcannon avatar microsoftopensource avatar msftgits 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  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pvscbot's Issues

When an issue is labeled as 'needs upstream fix', copy issue to appropriate project

This would require pvscbot being added to Microsoft/ptvsd and Microsoft/python-language-server. But it would let us control how we copy things.

We can lock the issue once copied and leave a comment that future details should go to the issue on the other repo.

If the other repos are monitored then we could check if the first line of the issue is Microsoft/vscode-pyon# and if so then close the corresponding issue on vscode-python.

Ignore errors when removing a label fails

2019-01-03T00:53:13.357665628Z Traceback (most recent call last):
2019-01-03T00:53:13.357682028Z   File "/home/site/wwwroot/pvscbot/__main__.py", line 35, in main
2019-01-03T00:53:13.357687228Z     gh, router, request.headers, body, secret=secret, logger=logging
2019-01-03T00:53:13.357691528Z   File "/home/site/wwwroot/pvscbot/ghutils/server.py", line 13, in serve
2019-01-03T00:53:13.357695728Z     await router.dispatch(event, gh, logger=logger)
2019-01-03T00:53:13.357699928Z   File "/home/site/wwwroot/antenv/lib/python3.7/site-packages/gidgethub/routing.py", line 80, in dispatch
2019-01-03T00:53:13.357704228Z     await callback(event, *args, **kwargs)
2019-01-03T00:53:13.357707928Z   File "/home/site/wwwroot/pvscbot/github/classify.py", line 55, in added_label
2019-01-03T00:53:13.357712028Z     event.data["issue"]["labels_url"], {"name": labels.Status.classify.value}
2019-01-03T00:53:13.357716128Z   File "/home/site/wwwroot/antenv/lib/python3.7/site-packages/gidgethub/abc.py", line 155, in delete
2019-01-03T00:53:13.357720128Z     jwt=jwt, oauth_token=oauth_token)
2019-01-03T00:53:13.357723928Z   File "/home/site/wwwroot/antenv/lib/python3.7/site-packages/gidgethub/abc.py", line 82, in _make_request
2019-01-03T00:53:13.357727928Z     data, self.rate_limit, more = sansio.decipher_response(*response)
2019-01-03T00:53:13.357731728Z   File "/home/site/wwwroot/antenv/lib/python3.7/site-packages/gidgethub/sansio.py", line 326, in decipher_response
2019-01-03T00:53:13.357735728Z     raise exc_type(*args)
2019-01-03T00:53:13.357739528Z gidgethub.BadRequest: Label does not exist

Traceback makes no sense for classify; just pay attention to the fact that it called into delete for gidgethub.abc.

If a label type is missing, add an 'incomplete' label

  • needs -> type
  • type -> feature
  • type-bug -> reason
  • needs upstream fix -> upstream

If any of these relationships are missing then an incomplete label should be added. (Technically there's also one for all issue requiring a status label, but "classify" takes care of that.)

Automate "needs decision"

If an issue has the "needs decision" label added, then:

  1. Add a canned response about how to upvote the issue
  2. Have that canned comment link directly to the opening comment to help make clear that people should ๐Ÿ‘ on that issue and not the canned response
  3. Add a seeding ๐Ÿ‘ on the opening comment

When a new status label is added, remove the old one

This is a generalization of #4 . The potential issue with this is needs upstream fix is to needs PR like info needed is to triage on occasion. That would mean changing needs upstream fix to act more as a modifier rather than a stand-alone status label.

Using logging.exception() incorrectly

2019-01-03T00:53:13.357754428Z Traceback (most recent call last):
2019-01-03T00:53:13.357758128Z   File "/home/site/wwwroot/antenv/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 390, in start
2019-01-03T00:53:13.357762128Z     resp = await self._request_handler(request)
2019-01-03T00:53:13.357765828Z   File "/home/site/wwwroot/antenv/lib/python3.7/site-packages/aiohttp/web_app.py", line 366, in _handle
2019-01-03T00:53:13.357769728Z     resp = await handler(request)
2019-01-03T00:53:13.357773428Z   File "/home/site/wwwroot/pvscbot/__main__.py", line 39, in main
2019-01-03T00:53:13.357785827Z     logging.exception()
2019-01-03T00:53:13.357790027Z TypeError: exception() missing 1 required positional argument: 'msg'

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.