forked from mirrors/probot
Merge remote-tracking branch 'origin/master' into seemakamath-verbose-logging
* origin/master: Update CONTRIBUTING.md Address @bkeepers feedback Tweak formatting Add testing section header Actually fix formatting Fix code block formatting Add note on enabling debug mode for github client Change title to Setup Update contributing.md Add Gitter.im badge Fix tests and use helper Update to work with new api client Update docs Add unassign action
This commit is contained in:
commit
0d537cd275
|
@ -1,25 +1,35 @@
|
|||
# Contributing
|
||||
|
||||
## Developing locally
|
||||
|
||||
To develop locally, you will need the latest version of [Node.js](https://nodejs.org/). After cloning the repo:
|
||||
## Setup
|
||||
|
||||
0. Clone the repo
|
||||
0. Make sure you have the latest version of [Node.js](https://nodejs.org/) to develop locally.
|
||||
0. Run `$ script/bootstrap` to install all the project dependencies
|
||||
0. Run `$ script/server` to run the server on http://localhost:3000
|
||||
|
||||
To test with a real GitHub repository, you'll need to create a test repository and configure a new webhook:
|
||||
|
||||
0. Until this gets built into a proper [Integration](https://developer.github.com/early-access/integrations/), the bot will need a valid GitHub API token to be able to do anything useful. Create a new [Personal access token](https://github.com/settings/tokens/new) and select the `repo` scope.
|
||||
0. Re-start the local server with the token by running: `$ GITHUB_TOKEN=xxx script/server` to run the server on http://localhost:3000
|
||||
0. Download [ngrok](https://ngrok.com/download) (`$ brew cask install ngrok` on a mac), which will expose a local server to the internet.
|
||||
0. With the server still running, open a new terminal tab and run `ngrok http 3000`, which should output something like `Forwarding http://4397efc6.ngrok.io -> localhost:3000`.
|
||||
|
||||
## Testing
|
||||
To test with a real GitHub repository, you'll need to create a test repository and configure a new webhook:
|
||||
|
||||
0. Head over to the **Settings** page of your repository, and click on **Webhooks & services**. Then, click on **Add webhook**. Configure it with:
|
||||
- **Payload URL:** Use the full `*.ngrok.io`
|
||||
- **Secret:** `development`
|
||||
- **Which events would you like to trigger this webhook?:** Choose **Send me everything**.
|
||||
0. Until this gets built into a proper [Integration](https://developer.github.com/early-access/integrations/), the bot will need a valid GitHub API token to be able to do anything useful. Create a new [Personal access token](https://github.com/settings/tokens/new) and select the `repo` scope.
|
||||
0. Re-start the local server with the token by running: `$ GITHUB_TOKEN=xxx script/server`
|
||||
0. Create a `.probot.yml` in your repo with:
|
||||
|
||||
behaviors:
|
||||
- on: issues.opened
|
||||
then:
|
||||
comment: "Hello World! Your bot is working!"
|
||||
- on: issues.opened
|
||||
then:
|
||||
comment: "Hello World! Your bot is working!"
|
||||
|
||||
0. Open a new issue. Your bot should post a comment (you may need to refresh to see it).
|
||||
|
||||
## Debugging
|
||||
0. To see what requests are going out, enable debugging mode for GitHub client in `/server.js`:
|
||||
|
||||
const github = new GitHubApi({
|
||||
debug: true
|
||||
});
|
||||
0. Always run `$ script/bootstrap` and restart the server if package.json has changed.
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# PRobot
|
||||
|
||||
[](https://gitter.im/bkeepers/PRobot?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
|
||||
_NOTE: this REAME is aspirational, and the project name is guaranteed to change._
|
||||
|
||||
PRobot is a trainable robot that responds to activity on GitHub. It's like [Hubot](https://hubot.github.com/), but for GitHub events instead of chat messages.
|
||||
|
|
|
@ -5,6 +5,7 @@ module.exports = {
|
|||
label: require('./actions/label'),
|
||||
lock: require('./actions/lock'),
|
||||
open: require('./actions/open'),
|
||||
unassign: require('./actions/unassign'),
|
||||
unlabel: require('./actions/unlabel'),
|
||||
unlock: require('./actions/unlock'),
|
||||
react: require('./actions/react'),
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
// Unassign one or more users from an issue or pull request.
|
||||
//
|
||||
// ```yml
|
||||
// - then:
|
||||
// # Unassign a single user
|
||||
// unassign: bkeeepers
|
||||
//
|
||||
// # Unassign multiple users
|
||||
// unassign: [bkeeepers, benbalter]
|
||||
// ```
|
||||
//
|
||||
|
||||
module.exports = function (github, payload, logins) {
|
||||
return github.issues.removeAssigneesFromIssue(
|
||||
payload.toIssue({body: {assignees: [].concat(logins)}})
|
||||
);
|
||||
};
|
|
@ -10,12 +10,13 @@
|
|||
"author": "Brandon Keepers",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"debug": "2.2.0",
|
||||
"expect": "^1.20.2",
|
||||
"github": "^5.2.0",
|
||||
"github-webhook-handler": "^0.6.0",
|
||||
"github": "^5.2.0",
|
||||
"handlebars": "^4.0.5",
|
||||
"js-yaml": "^3.6.1",
|
||||
"debug": "2.2.0"
|
||||
"jsdoc": "^3.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"mocha": "^3.0.2",
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
const expect = require('expect');
|
||||
const action = require('../../lib/actions/unassign');
|
||||
const Payload = require('../../lib/payload');
|
||||
const payload = new Payload(require('../fixtures/webhook/comment.created.json'));
|
||||
|
||||
const createSpy = expect.createSpy;
|
||||
|
||||
const github = {
|
||||
issues: {
|
||||
removeAssigneesFromIssue: createSpy()
|
||||
}
|
||||
};
|
||||
|
||||
describe('action.unassign', () => {
|
||||
it('unassigns a user', () => {
|
||||
action(github, payload, 'bkeepers');
|
||||
expect(github.issues.removeAssigneesFromIssue).toHaveBeenCalledWith({
|
||||
owner: 'bkeepers-inc',
|
||||
repo: 'test',
|
||||
number: 6,
|
||||
body: {assignees: ['bkeepers']}
|
||||
});
|
||||
});
|
||||
|
||||
it('unassigns multiple users', () => {
|
||||
action(github, payload, ['hello', 'world']);
|
||||
expect(github.issues.removeAssigneesFromIssue).toHaveBeenCalledWith({
|
||||
owner: 'bkeepers-inc',
|
||||
repo: 'test',
|
||||
number: 6,
|
||||
body: {assignees: ['hello', 'world']}
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue