Oppiabot is a GitHub app built with probot. It acts as a helper for the Oppia code repository to maintain the development workflow. It is hosted on Heroku.
Please refer to the following instructions to setup Oppiabot for the first time on your machine:
-
Create a new folder called
opensource/
within your home folder (or use one that you already have). Navigate to it (cd opensource
), then fork and clone the Oppiabot repo. This will create a new folder namedopensource/oppiabot
. Navigate toopensource/oppiabot/
. -
Install Node.Js and NPM on your machine using the following commands:
First check if you already have Node.js and NPM using:
node -v npm -v
If these commands show some versions, then you can jump to Point No. 3, else proceed in this point:
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash - sudo apt install -y nodejs
sudo brew install node
Use WSL with Ubuntu and then follow the Ubuntu instructions.
-
Setup probot and other dependencies by running the following command:
npm install
- The Oppiabot uses environment variables. These are configured in the server settings. To deploy the bot locally, create a
.env
file and copy the contents of.env.example
to it. You will need to adjust these variables accordingly following the instructions in the subsequent steps. Run following command to copy.env.example
to.env
If you have Linux terminal type:
cp .env.example .env
-
Go to smee.io and click Start a new channel. Set
WEBHOOK_PROXY_URL
in.env
to the URL that you are redirected to. -
Create a new GitHub App with:
- GitHub App name: Use something like "My Oppiabot testing App"
- Homepage URL: Use any random URL
- Webhook URL: Use your
WEBHOOK_PROXY_URL
from the previous step. - Webhook Secret:
development
- Permissions & events The following permissions and events must be subscribed. If, for example, you only enable issue events, you will not be able to listen on pull request webhooks with the bot.
- Download the private key. It will be a
.pem
file. Move it to the root directory of the project. As long as it's in the root directory, it will be automatically detected regardless of the filename.
Make sure you remove
PRIVATE_KEY=example_private_key
from .env file, Otherwise app will not work locally.
- Edit
.env
and setAPP_ID
to the ID of the app you just created and alsoWEBHOOK_SECRET
todevelopment
. The App ID can be found in your app settings page here.
-
Identify a target repository and install the bot by clicking the Install button on the settings page of your app, e.g.,
https://github.com/settings/apps/my-oppiabot-testing-app/installations
-
Update the
.env
file:- Add your GitHub account name to
WHITELISTED_ACCOUNTS
.
- Add your GitHub account name to
-
Add the repository name in the
constants.js
file:- Open the
constants.js
file in the bot's source code. - Navigate to the
checksWhitelist
object. - Add a new entry with your repository name (in lowercase) as the key. The value should define the checks and events specific to your repository.
Example: If your repository name is
my-repo
, thechecksWhitelist
object will look like this:const checksWhitelist = { // Existing entries... 'my-repo': { [openEvent]: [claCheck], [reopenEvent]: [], [openEventGithubActions]: [claCheckGithubAction], [reopenEventGithubActions]: [claCheckGithubAction], [synchronizeEvent]: [mergeConflictCheck], [closeEvent]: [allMergeConflictCheck], [editEvent]: [], [issuesLabelEvent]: [], [issuesAssignedEvent]: [], [pushEvent]: [], [pullRequestReviewEvent]: [pullRequestReviewCheck], [issueCommentCreatedEvent]: [respondToReviewCheck], }, };
- Open the
-
Save the changes to
constants.js
.
You are now ready to run the bot on your local machine. Run npm run dev
to start the server.
The dev
script will start the bot using nodemon, which will watch for any files changes in your local development environment and automatically restart the server.
npm start
to start the bot without watching files.
Always run npm install
and restart the server if package.json
has changed.
To turn on verbose logging, start server by running: LOG_LEVEL=trace npm start
.
Run npm test
to run all the tests locally.
If you have any feature requests or bug reports, please log them on our issue tracker.
Please report security issues directly to admin@oppia.org.
The Oppiabot code is released under the Apache v2 license.