Git Product home page Git Product logo

oppiabot's Introduction

Oppiabot

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.

Getting started

Please refer to the following instructions to setup Oppiabot for the first time on your machine:

  1. 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 named opensource/oppiabot. Navigate to opensource/oppiabot/.

  2. 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:

    Using Ubuntu

    curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
    sudo apt install -y nodejs

    Using MacOS

    sudo brew install node

    Using Windows

    Use WSL with Ubuntu and then follow the Ubuntu instructions.

  3. Setup probot and other dependencies by running the following command:

  npm install
  1. 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
  1. Go to smee.io and click Start a new channel. Set WEBHOOK_PROXY_URL in .env to the URL that you are redirected to.

  2. 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.

  1. 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.

  1. Edit .env and set APP_ID to the ID of the app you just created and also WEBHOOK_SECRET to development. The App ID can be found in your app settings page here.

Installing the bot on a repository

You'll need to 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. In the .env file put your github account name in WHITELISTED_ACCOUNTS and also add your repository (name in small caps) in the constants.js file locally.

Running the bot locally

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.

Other available scripts

npm start to start the bot without watching files.

Debugging

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.

Support

If you have any feature requests or bug reports, please log them on our issue tracker.

Please report security issues directly to [email protected].

License

The Oppiabot code is released under the Apache v2 license.

oppiabot's People

Contributors

462702985 avatar anandwana001 avatar ankita240796 avatar apb7 avatar gp201 avatar harshkhilawala avatar jameesjohn avatar kevinlee12 avatar krishnarao22 avatar mridul-netizen avatar naman-1234 avatar nlok5923 avatar riyasingh1004 avatar saeb-ai avatar seanlip avatar vojtechjelinek avatar winnie368c avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

oppiabot's Issues

For every PR open > 72 hours, go through all review comments

For every PR open > 72 hours, go through all review comments; if there’s no comment by a listed reviewer yet, assign oppia-dev as an assignee of the task. This is recorded in metrics and the reviewer is pinged. This needs to be checked on a daily basis

Oppiabot should tag PRs with builds passing but last commit > 2 days ago

Oppiabot should tag PRs with builds passing but last commit > 2 days ago, with a warning message / label saying “build might be stale, please update from develop”. Then reviewers/authors can take a closer look, and if someone introduces a new check, they can look at PRs with this label and restart the checks if it makes sense.

Modify CLA check to verify whether the author of each commit in a PR has signed the CLA

At the moment, the CLA check is triggered when a PR is opened. It then checks whether the author of the PR has signed the CLA. This check needs to be extended so that whenever a commit is pushed to a PR, the bot checks whether the author of that commit has signed the CLA. This is to prevent cases like: oppia/oppia#5490 (review)
We also need to take care of the number of API calls the bot makes for this extended functionality.

Remove usage of probot-stale

Replace probot stale with probot scheduler since we are currently using a fork of probot/stale which isn't updated and is using old dependencies of probot, probot-config which have deprecated functions.

New Feature: Reminders for PRs Changing E2E Tests

Context and Motivation

The E2E team has been introducing new expectations for PRs that modify the E2E tests, for example rerunning the changed tests 5 times to make sure they aren't flaky. Using Oppiabot to leave reminders on these PRs would help contributors remember these new processes.

Desired Behavior

Oppiabot leaves a comment on every PR that affects the E2E tests. These are all the files owned by U8NWXD in the CODEOWNERS file. This comment should include a list of reminders of the codeowner checks documented in the wiki. For example:

  • You will need to provide screenshots showing that the tests aren't flaky after your changes.
  • All constants should be in all-caps.
  • All element selectors need to be at the top of the file except for certain cases in utility files and with chained selectors.
  • Everything that requires a globally unique name should be given a reliably unique name.
  • All it blocks should be independent from each other.
  • Use waitFor functions before interacting with any element, or use a utility from the actions.js file.
  • No await keywords for .first(), .last() or .get(i) calls.
  • Put reused or generally useful code in functions.
  • Variables should be named as nouns, and functions should be named as verbs.
  • All HTML classes you reference in root selectors in the tests should begin with protractor-test-.

For more details, see the E2E test wiki page

Investigate response time errors

We are seeing a lot of response time errors on Heroku: https://dashboard.heroku.com/apps/murmuring-castle-33250.
These errors are resulting in checks being flaky even though the implementation is correct. One of the occurrences was with a CLA check where it did not work on a PR but when investigated later, worked fine.

  • One of the possible reasons for this is the large number of new checks which were added during GSoC.

  • We need to dig deeper into this and find out why these errors are occurring.

    • The way to do this would be to add support for custom logging for oppiabot since Heroku logs are only preserved for 24 hours and we are not able to investigate what is going wrong.
  • Once we are sure, we can look into increasing the number of dynos if required.

Ensure that each PR has a changelog label at time-of-merge

As a fix for #19, we've decided to take incremental steps to ensure that each PR has a changelog label. Therefore, if a PR does not have a changelog label, the bot will ping the author to fix it but will not close the PR.
A repo check, similar to TravisCI should be implemented as a next step, if the former does not work, to ensure that each PR has a changelog label at time-of-merge. Oppiabot should be more of a helper rather than an enforcer, in this case.

Bug with new code owner check

A bug was noticed on the code owner check oppia/oppia#10534.
After investigating, the issue is that when checking for new code owners, we don't ignore comments. And the above pull request added comments in the code owner file that included user names.

Close PRs on force push

We take force-pushing a PR under review quite seriously -- it makes it hard for reviewers to go through the changes made in the PR.
The aim of this issue is to add a double-confirmation message in the pre-push checks before a developer is able to force-push commits onto a PR.
We can have two confirmation messages with a YES or NO something along the following lines:

  • You are trying to force-push commits onto a feature branch. If there is a pull request using this branch, which is under review, this will overwrite history on GitHub and make the incremental changes harder to review. Are you sure that you want to force-push?
  • If the answer for the above question is YES, then ask: Are you really sure that you want to force-push?
  • Only if the answer to the above question is YES, allow force-push.
    (Please note that we're open for ideas here!)

See the following on how to detect force-pushes: SO Post and Sample script

Add checks to ensure that a "changelog" label is applied on every PR

We would like any PR that is merged into develop to have a "changelog: -type-" label. This is to help organize the changelog easily during releases.

PRs must contain exactly one changelog label, and the bot auto-close the PR if no label is found. It will leave a top-level comment asking the PR author to add a changelog label before reopening the PR.

Close stale branches

The Oppia Android project has a lot of branches that are stale. They could either be because a PR was already merged for that branch (although now Github should automatically delete those), or if a branch is not being used for a while.
It would be a good idea for oppia bot to flag those branches (maybe branches that are x days old), notify the owner of the branch that the branch will be deleted in a few days if the branch is not actively used, and then delete the branch after those many days if the branch remains inactive.

Issue with running tests.

I investigate the test failures and I was able to fix some of them. Others are failing for legitimate reasons, which is why I created this issue.

  1. The scheduler gets created at
    scheduler = createScheduler(robot, {
    , but in the tests, the app (oppiabot) is initialized
    oppiaBotPlugin(robot);
    before robot.auth gets mocked
    robot.auth = () => Promise.resolve(github);
    and the scheduler calls robot.auth https://github.com/probot/scheduler/blob/8ad237c69116894a5579d360e544f2586191fa7a/index.js#L77 before it is mocked so it calls the actual robot.auth and not the mocked implementation.

A possible fix for this would be to mock robot.auth before initializing oppiabot. I did that and it fixed the initial problem but provided another problem: the mock github data which is being resolved misses some data required by the scheduler.
2. Before every event gets dispatched, we check if the repo owner is allowed to run the bot

if (whitelistedAccounts.includes(context.repo().owner.toLowerCase())) {
. Going through the mock payload, the repo owner is set to oppia, so adding oppia to the whitelisted account in the .env will make this work.

After fixing the above issues, 8 tests pass and 6 fail.
3. This test

it('should be called with three arguments for the given payload', () => {
checks that the function is called with 3 arguments, but the function is only called with one (context) which is expected since probot calls the handlers with just one argument.
4.
it('should be called with the correct username for the given payload',
tests that the first argument passed is the username of the user, but it is instead the context , and again this is the expected behaviour.
Other tests fail for similar reason. maybe this is from an earlier implementation?

Reuse sheet functions

The following functions in the checkIssueAssignee module are performing the same functionality as in the apiForSheets module: hasSignedCla, checkAssignees, and need to be refactored to use the functions in the apiForSheets module.

Note that the functions in apiForSheets might need to be refactored support usage in both modules.

Close PRs when CLA isn't signed

Oppiabot should close the PRs if CLA isn't signed instead of just leaving a comment and adding label. This will ensure that such PRs aren't merged even accidentally. This is required since it would be messy if such a PR is merged and we have to revert it back.

Upgrade googleapis

Upgrade googleapis version to the latest issues. This requires to be tested well since the upgrade can be a breaking change.

Update npm packages

Our npm packages are quite out date, this issue is to log the upgrade of the npm packages.

Feature Request: Auto submit PRs with a particular label

A lot of times we have PRs where all the reviewers have LGTM'ed but the continuous integration tests are still running. On oppia-web, we label those PRs with a 'PR: LGTM' label and the author is expected to merge the PR once the tests pass.
It may be useful to have oppia bot scan PRs with this label, and check if the tests are complete and have passed. If the tests have passed, it can automatically submit that PR.
I am not sure if Github allows bots to submit PRs, and also we need to think about the final commit that is dependent on who merges the PR.

Android Feature: Update contributors about pending PRs

Currently in Oppia-Android, we follow up with the inactive contributors by following these steps:

  1. Follow up with student after 7 days of no-activity by commenting on issue and sending an email.
  2. If they reply within next 7 days, great, else after 7 days (2 weeks at this point from start), close the PR and mark student as lapsed.

Instead this follow-up process should be automated via oppia-bot.

Add support for oppia-android

This is a feature request to update & set up the bot to work on https://github.com/oppia/oppia-android. I think right now all we need is the CLA tracking support, but we may request/add additional, Android-specific functionality in the future.

I'm happy to make the changes if folks point me in the right direction. :)

Modify the CLA check to auto-close PRs

The CLA check should auto-close PRs if the contributor has not signed the CLA with a proper message on the following lines:

Hi! @{author}. Welcome to Oppia! Can you please could you follow the instructions [here](https://github.com/oppia/oppia/wiki/Contributing-code-to-Oppia#setting-things-up) to get started? You'll need to do this before we can accept your PR. I am closing this PR for now. Feel free to re-open it once you are done with the above instructions. Thanks!

Error in oppiabot logs for obtaining repo

I see the following error in oppiabot logs. This looks unrelated to our code-setup and is coming up from the probot-config instead.

Here are the logs:

ERROR event: context.github.repos.getContent is not a function
TypeError: context.github.repos.getContent is not a function
at loadYaml (/app/node_modules/probot-config/index.js:28:49)
at getConfig (/app/node_modules/probot-config/index.js:91:24)
at forRepository (/app/node_modules/probot-stale/index.js:52:24)
at unmark (/app/node_modules/probot-stale/index.js:23:27)
at Application.<anonymous> (/app/node_modules/probot/lib/application.js:156:50)
at step (/app/node_modules/probot/lib/application.js:44:23)
at Object.next (/app/node_modules/probot/lib/application.js:25:53)
at fulfilled (/app/node_modules/probot/lib/application.js:16:58)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:97:5)

Add checks to ensure the PR checklist is followed by contributors

The bot should make sure that the points in the PR checklist are followed. (Things like title must have an issue number, and the description must say "Fix #bug_no").

This should not be a blocking check, as there may be instances where this doesn't apply, like the routine update of translations PR, or the update AUTHORS PR every release.

I think a one time notification on the PR thread, if the PR fails this check, should be good.

Tidy up pull requests

Have Oppiabot notify contributors whenever their title does not follow one of the following patterns:

  • Fix #123: ...
  • Fix part of #123: ...

Check for PTAL

For every PR which has been open for > 72 hours, work from the most recent comment backwards to identify the last “streak” of review comments by the author of the PR. (If the last comment isn’t by the author of the PR, skip this PR. Also ignore any comments by codecov or oppiabot.) Then, see if this last streak of comments includes the string “PTAL”. If more than 72 hours has elapsed from the “PTAL” comment, then assign oppia-dev to the task. This is recorded in metrics and the reviewer is pinged. This needs to be checked on a daily basis

Bug in owners message

Oppiabot's "new owners" message is confusing, see: oppia/oppia#11084 (comment). Specifically:

  1. It's copying unrelated things from the owners file (comments)
  2. Why does Vinita care about this? Just because she's the initial reviewer? Sandeep actually has to approve the change, so it seems more relevant to him as the codeowner of the changed file.

Move periodic checks to github actions

Since probot scheduler is being archived, we need to move the periodic checks to Github actions.
Github actions allow us to set up a cron job as part of the jobs needed for the action. But to enable the action to be able to comment on pull requests, we need to authenticate as oppiabot.

See probot/probot#1370 (comment) for more information.

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.