Update development docs

This commit is contained in:
Brandon Keepers 2017-03-19 22:20:30 -05:00
parent 57d5ef5862
commit 7316dae28a
No known key found for this signature in database
GPG Key ID: F9533396D5FACBF6
2 changed files with 27 additions and 37 deletions

View File

@ -1,37 +0,0 @@
# Contributing
## Running Locally
0. Clone the repository with `git clone https://github.com/bkeepers/PRobot.git`
0. Make sure you have a recent version of [Node.js](https://nodejs.org/) installed
0. Run `$ script/bootstrap` to install all the project dependencies
0. Install [ngrok](https://ngrok.com/download) (`$ brew cask install ngrok` on a mac), which will expose the local server to the internet so GitHub can send webhooks
0. Run `$ script/tunnel` to start ngrok, which should output something like `Forwarding https://4397efc6.ngrok.io -> localhost:3000`
0. [Register an integration](https://developer.github.com/early-access/integrations/creating-an-integration/) on GitHub with:
- **Callback URL** and **Webhook URL**: The full ngrok url above. For example: `https://4397efc6.ngrok.io/`
- **Secret:** `development`
- **Permissions & events** needed will depend on how you use the bot, but for development it may be easiest to enable everything.
0. Download the private key and move it to `private-key.pem` in the project directory
0. Edit `.env` and fill in all the environment variables
0. With `ngrok` still running, open another terminal and run `$ script/server` to start the server on http://localhost:3000
Whenever you com back to work on the app after you've already had it running once, then you need to:
0. Run `$ script/server`
0. Run `$ script/tunnel` in another window
0. `ngrok` will use a different URL every time it is restarted, so you will have to go into the [settings for your Integration](https://github.com/settings/installations) and update all the URLs.
## Testing
To test with a real GitHub repository, you'll need to create a test repository and install the integration you created above:
0. Open up the settings for your installation and click "Install"
0. Create a `.probot.js` in your repository with:
on("issues.opened").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. Always run `$ script/bootstrap` and restart the server if package.json has changed.
0. To turn on verbose logging, start server by running: `$ LOG_LEVEL=debug script/server`
0. To see what requests are going out, start the server by running: `$ LOG_LEVEL=trace script/server`

27
docs/development.md Normal file
View File

@ -0,0 +1,27 @@
# Development
To run a plugin locally, you'll need to create a GitHub Integration and configure it to deliver webhooks to your local machine.
1. Make sure you have a recent version of [Node.js](https://nodejs.org/) installed
1. Install [ngrok](https://ngrok.com/download) (`$ brew cask install ngrok` on a mac), which will expose the local server to the internet so GitHub can send webhooks
1. Run `$ ngrok http 3000` to start ngrok, which should output something like `Forwarding https://4397efc6.ngrok.io -> localhost:3000`
1. [Create a new GitHub Integration](https://github.com/settings/integrations/new) with:
- **Callback URL** and **Webhook URL**: The full ngrok url above. For example: `https://4397efc6.ngrok.io/`
- **Secret:** `development`
- **Permissions & events** needed will depend on how you use the bot, but for development it may be easiest to enable everything.
1. Download the private key and move it to `private-key.pem` in the project directory
1. Edit `.env` and set `INTEGRATION_ID` to the ID of the integration you just created.
1. With `ngrok` still running, open another terminal and run `$ npm start` to start the server on http://localhost:3000
You'll need to create a test repository and install your Integration by clicking the "Install" button on the settings page.
Whenever you com back to work on the app after you've already had it running once, then you need to:
1. Run `$ npm start`
1. Run `$ ngrok http 3000` in another terminal window
1. `ngrok` will use a different URL every time it is restarted, so you will have to go into the [settings for your Integration](https://github.com/settings/integrations) and update all the URLs.
## Debugging
1. Always run `$ npm install` and restart the server if package.json has changed.
1. To turn on verbose logging, start server by running: `$ LOG_LEVEL=trace npm start`