Git Product home page Git Product logo

topcoder-x-receiver's Introduction

Requirements

Install dependencies

npm install

Source code lint

eslint is used to lint the javascript source code:

npm run lint

Endpoints

  • POST /webhooks/github - The webhook handler for github
  • POST /webhooks/gitlab - The webhook handler for gitlab

Configuration

See "configuration.md"

config/local.js will not tracked by git.

Local Setup

npm start

Server should be started at port 3002.

use ngrok to make your local deploy accessible by internet:

ngrok http 3002

Setup for verification

Before verifying the tool, 3 service needs be configured and run them

  • processor
  • receiver
  • Topcoder X

Go to Topcoder X UI login with above used topcoder username and

  • go to settings and make sure git hosts are correctly setup, if not click setup and authorize to setup.

  • Go to Topcoder X UI and go to project management and add a project from git account and click save, and edit the same project and click 'Add Webhooks' button, verify that webhooks are set up correctly on git host's project.

Now, receiver service can receive the webhooks from git host's project. Now you can verify this service by following the verfication steps below

GitHub Verification

  • create an issue in the repo, you can see the logs in receiver and processor, the issue.created event is generated.
  • update an issue in the repo, you can see the logs in receiver and processor, the issue.updated event is generated.
  • create a comment on an issue, you can see the logs in receiver and processor, the comment.created event is generated.
  • update a comment on an issue, you can see the logs in receiver and processor, the comment.updated event is generated.
  • assigned a user to an issue, you can see the logs in receiver and processor, the issue.assigned event is generated.
  • un-assigned a user to an issue, you can see the logs in receiver and processor, the issue.unassigned event is generated.
  • add/remove a label to an issue, you can see the logs in receiver and processor, the issue.labelUpdated event is generated.
  • create a pull request, you can see the logs in receiver and processor, the pull_request.created event is generated.
  • close a pull request without merge, you can see the logs in receiver and processor, the pull_request.closed event is generated and the merged property is false.
  • merge a pull request, you can see the logs in receiver and processor, the pull_request.closed event is generated and the merged property is true.
  • close an issue in the repo, you can see the logs in receiver and processor, the issue.closed event is generated

Gitlab Verification

  • create an issue in the repo, you can see the logs in receiver and processor, the issue.created event is generated.
  • update an issue in the repo, you can see the logs in receiver and processor, the issue.updated event is generated.
  • create a comment on an issue, you can see the logs in receiver and processor, the comment.created event is generated.
  • assigned a user to an issue, you can see the logs in receiver and processor, the issue.assigned event is generated.
  • un-assigned a user to an issue, you can see the logs in receiver and processor, the issue.unassigned event is generated.
  • add/remove a label to an issue, you can see the logs in receiver and processor, the issue.labelUpdated event is generated.
  • create a pull request, you can see the logs in receiver and processor, the pull_request.created event is generated.
  • close a pull request without merge, you can see the logs in receiver and processor, the pull_request.closed event is generated and the merged property is false.
  • merge a pull request, you can see the logs in receiver and processor, the pull_request.closed event is generated and the merged property is true.
  • close an issue in the repo, you can see the logs in receiver and processor, the issue.closed event is generated

topcoder-x-receiver's People

Contributors

52cs avatar afrisalyp avatar callmekatootie avatar cwdcwd avatar dependabot[bot] avatar dhruvit-r avatar dilipkrthapa avatar gunasekar-k avatar jmgasper avatar kinfkong avatar nkumar-topcoder avatar rootelement avatar veshu avatar

Stargazers

 avatar  avatar

Watchers

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

topcoder-x-receiver's Issues

Github ticket rules

How to work with git tickets

The basic flow for handling a ticket is as follows:

  1. Assign the ticket to yourself, change the label to "tcx_Assigned", remove the "tcx_OpenForPickup" label. Please only assign tickets to yourself when you are ready to work on it. I don't want tickets assigned to someone and then not have them work on a ticket for 24 hours. The goal here is a quick turnaround for the client. If you can't work on a ticket immediately, leave it for someone else.

  2. Complete the ticket and create a merge request within 24 hours. Please ensure your merge request can be merged automatically and that it's against the latest commit in Git when you create it.

  3. Change the label on the ticket to "tcx_ReadyForReview"

After seeing a ticket marked as "tcx_ReadyForReview", the copilot will review that ticket, usually within 24 hours.

Note that you are expected to keep your changes in-sync with Git - make sure to do a pull before you push changes to make sure there aren't any merge issues.

Accepted fix

If a fix is accepted, a payment ticket will be created on the Topcoder platform within 5-10 minutes of the issue being closed. You should see the payment in your PACTs within 24 hours.

Rejected fix

If a fix is rejected, a comment, and possibly a screenshot, will be added to the ticket explaining why the fix was rejected. The status will be changed to "tcx_Feedback".

If a fix is rejected, that ticket is your priority. You should not assign yourself any more tickets until you complete the required additional fixes!

Payment amounts

Each ticket in GitLab has a dollar value. That is the amount you will be paid when the ticket is completed, merged, and verified by the copilot. Note that there is still a 30 day waiting period as the payment will be treated as a regular TopCoder challenge payment.

Important Rules:

  • You can assign any unassigned issue to yourself with an "Open for pick up" label (first come first serve)

  • You can only assign ONE AT A TIME. The nature of it being assigned will indicate it is not available to anyone else.

  • You will fix the ticket by committing changes to the master branch.

  • After marking a ticket "tcx_ReadyForReview" you are eligible to accept another. You do NOT need to wait for the copilot to validate your fix.

  • You can do as many tickets as you want, as long as you follow the rules above.

  • If an assigned task is not done in 24 hours, you will need to explain why it is not completed as a comment on the ticket.

  • You can ask questions directly on the GitLab ticket.

ANYONE NOT FOLLOWING THE RULES ABOVE WILL BE WARNED AND POTENTIALLY LOSE THEIR GITLAB ACCESS!

Multiple entries for the same project

This line:
https://github.com/topcoder-platform/topcoder-x-receiver/blob/develop/routes/middlewares/SecurityChecker.js#L22

For https://github.com/topcoder-platform/challenge-api i had to create a new project. In the security lookup, i think it's finding the archived project instead of the active one, and failing. I tested this by changing the archived project's url in the db and then the webhook worked. I think we need to add: active: true as a filter on this lookup, and probably gitlab/azure too.

Receiver Repo Lookup doesn't handle multiple repos

const projectDetail = await dbHelper.scanOne(Project, {

For topcoder-platform/community-app, there were 3 entries in the TCX dynamo DB for the same git repo. The linked line above was pulling the first it found, checking the secret, and saying it's an invalid request.

Two things should happen:

  1. That line should pull all repos that match the URL and check the secret against each one
  2. We should consider not allowing multiple additions of the same repo? Maybe owner should be an array of people? Not sure what's best here.

Github ticket rules

How to work with git tickets

The basic flow for handling a ticket is as follows:

  1. Assign the ticket to yourself, change the label to "tcx_Assigned", remove the "tcx_OpenForPickup" label. Please only assign tickets to yourself when you are ready to work on it. I don't want tickets assigned to someone and then not have them work on a ticket for 24 hours. The goal here is a quick turnaround for the client. If you can't work on a ticket immediately, leave it for someone else.

  2. Complete the ticket and create a merge request within 24 hours. Please ensure your merge request can be merged automatically and that it's against the latest commit in Git when you create it.

  3. Change the label on the ticket to "tcx_ReadyForReview"

After seeing a ticket marked as "tcx_ReadyForReview", the copilot will review that ticket, usually within 24 hours.

Note that you are expected to keep your changes in-sync with Git - make sure to do a pull before you push changes to make sure there aren't any merge issues.

Accepted fix

If a fix is accepted, a payment ticket will be created on the Topcoder platform within 5-10 minutes of the issue being closed. You should see the payment in your PACTs within 24 hours.

Rejected fix

If a fix is rejected, a comment, and possibly a screenshot, will be added to the ticket explaining why the fix was rejected. The status will be changed to "tcx_Feedback".

If a fix is rejected, that ticket is your priority. You should not assign yourself any more tickets until you complete the required additional fixes!

Payment amounts

Each ticket in GitLab has a dollar value. That is the amount you will be paid when the ticket is completed, merged, and verified by the copilot. Note that there is still a 30 day waiting period as the payment will be treated as a regular TopCoder challenge payment.

Important Rules:

  • You can assign any unassigned issue to yourself with an "Open for pick up" label (first come first serve)

  • You can only assign ONE AT A TIME. The nature of it being assigned will indicate it is not available to anyone else.

  • You will fix the ticket by committing changes to the master branch.

  • After marking a ticket "tcx_ReadyForReview" you are eligible to accept another. You do NOT need to wait for the copilot to validate your fix.

  • You can do as many tickets as you want, as long as you follow the rules above.

  • If an assigned task is not done in 24 hours, you will need to explain why it is not completed as a comment on the ticket.

  • You can ask questions directly on the GitLab ticket.

ANYONE NOT FOLLOWING THE RULES ABOVE WILL BE WARNED AND POTENTIALLY LOSE THEIR GITLAB ACCESS!

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.