Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 5f7eee0

Browse files
committed
Merge branch 'develop'
# Conflicts: # README.md # TopcoderXDeploy.md # configuration.md # package-lock.json # package.json # src/app.js # src/common/constants.js # src/common/helper.js # src/config.js # src/controllers/CopilotPaymentController.js # src/controllers/IssueController.js # src/controllers/ProjectController.js # src/front/src/app/add-copilot-payment/add-copilot-payment-controller.js # src/front/src/app/add-copilot-payment/add-copilot-payment.html # src/front/src/app/copilot-payments/copilot-payment.service.js # src/front/src/app/copilot-payments/copilot-payments-controller.js # src/front/src/app/copilot-payments/copilot-payments.html # src/front/src/app/helper.js # src/front/src/app/less/custom.less # src/front/src/app/main/issue.service.js # src/front/src/app/main/main.controller.js # src/front/src/app/main/main.html # src/front/src/app/upsertproject/transfer-ownership-dialog.controller.js # src/front/src/app/upsertproject/upsertproject.controller.js # src/front/src/app/upsertproject/upsertproject.html # src/front/src/components/common/navigation.controller.js # src/models/CopilotPayment.js # src/models/Issue.js # src/models/Project.js # src/routes.js # src/services/AppHealthService.js # src/services/CopilotPaymentService.js # src/services/GithubService.js # src/services/IssueService.js # src/services/ProjectService.js
2 parents 252a736 + 5a75931 commit 5f7eee0

File tree

116 files changed

+10329
-4717
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

116 files changed

+10329
-4717
lines changed

.DS_Store

2 KB
Binary file not shown.

.circleci/config.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
version: 2
2+
defaults: &defaults
3+
docker:
4+
- image: circleci/python:2.7-stretch-browsers
5+
install_dependency: &install_dependency
6+
name: Installation of build and deployment dependencies.
7+
command: |
8+
sudo apt install jq
9+
sudo pip install awscli --upgrade
10+
sudo pip install docker-compose
11+
install_deploysuite: &install_deploysuite
12+
name: Installation of install_deploysuite.
13+
command: |
14+
git clone --branch v1.4.1 https://github.com/topcoder-platform/tc-deploy-scripts ../buildscript
15+
cp ./../buildscript/master_deploy.sh .
16+
cp ./../buildscript/buildenv.sh .
17+
cp ./../buildscript/awsconfiguration.sh .
18+
restore_cache_settings_for_build: &restore_cache_settings_for_build
19+
key: docker-node-modules-{{ checksum "package-lock.json" }}
20+
21+
save_cache_settings: &save_cache_settings
22+
key: docker-node-modules-{{ checksum "package-lock.json" }}
23+
paths:
24+
- node_modules
25+
26+
builddeploy_steps: &builddeploy_steps
27+
- checkout
28+
- setup_remote_docker
29+
- run: *install_dependency
30+
- run: *install_deploysuite
31+
- restore_cache: *restore_cache_settings_for_build
32+
- run: ./build.sh
33+
- save_cache: *save_cache_settings
34+
- deploy:
35+
name: Running MasterScript.
36+
command: |
37+
./awsconfiguration.sh $DEPLOY_ENV
38+
source awsenvconf
39+
./buildenv.sh -e $DEPLOY_ENV -b ${DEPLOY_ENV}-${APPNAME}-deployvar
40+
source buildenvvar
41+
./master_deploy.sh -d ECS -e $DEPLOY_ENV -t latest -s ${DEPLOY_ENV}-global-appvar,${DEPLOY_ENV}-${APPNAME}-appvar -i ${APPNAME}
42+
43+
44+
jobs:
45+
# Build & Deploy against development backend
46+
"build-dev":
47+
<<: *defaults
48+
environment:
49+
DEPLOY_ENV: "dev"
50+
APPNAME: "topcoder-x-ui"
51+
steps: *builddeploy_steps
52+
53+
"build-prod":
54+
<<: *defaults
55+
environment:
56+
DEPLOY_ENV: "prod"
57+
APPNAME: "topcoder-x-ui"
58+
steps: *builddeploy_steps
59+
60+
workflows:
61+
version: 2
62+
build:
63+
jobs:
64+
# Development builds are executed on "develop" branch only.
65+
- "build-dev":
66+
context : org-global
67+
filters:
68+
branches:
69+
only:
70+
- develop
71+
72+
# Production builds are exectuted only on tagged commits to the
73+
# master branch.
74+
- "build-prod":
75+
context : org-global
76+
filters:
77+
branches:
78+
only: master

DynamoDBMigration.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
## Migrate the data to Dynamo
2+
3+
Prerequisite is to turn off any throttling on the DynamoDB, temporarily
4+
5+
1. Download the migration-tools.zip from here: https://github.com/topcoder-platform/topcoder-x-ui/issues/140#issuecomment-497663806
6+
2. Unzip
7+
3. Modify `migration-tools/config/default.js` to match prod
8+
* MONGODB_URL: Will provide in Slack
9+
* AWS_ACCESS_KEY_ID
10+
* AWS_SECRET_ACCESS_KEY
11+
* AWS_REGION
12+
* IS_LOCAL = 'false'
13+
4. `npm i`
14+
5. `npm run migrate-data`
15+
16+
#### Tables created
17+
18+
* `Topcoder_X.CopilotPayment`
19+
* `Topcoder_X.Issue`
20+
* `Topcoder_X.OwnerUserGroup`
21+
* `Topcoder_X.OwnerUserTeam`
22+
* `Topcoder_X.Project`
23+
* `Topcoder_X.User`
24+
* `Topcoder_X.UserMapping`
25+
26+
27+
## Deploy latest code
28+
29+
* Deploy the latest code from `master` to Heroku:
30+
* topcoder-x-receiver
31+
* topcoder-x-processor
32+
* topcoder-x-ui
33+
34+
Update the AWS Dynamo config values in Heroku:
35+
36+
* AWS_ACCESS_KEY_ID
37+
* AWS_SECRET_ACCESS_KEY
38+
* IS_LOCAL='false'
39+
* AWS_DYNAMODB_REGION
40+
* AWS_REGION

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ npm run lint
4747
- post /projects/hook - create webhooks in the project repository
4848
- GET /users/settings - gets the current user's setup
4949
- GET /users/accessToken - gets the user's access token
50-
50+
51+
- POST /issues - create an issue to Gitlab/Github
52+
- POST /issues/recreate - recreate an issue DB and its challenge
53+
5154
- GET /health - gets the app health
5255

5356
## Configuration
@@ -65,11 +68,11 @@ Server should be started at port 80.
6568
## Heroku Deployment
6669
Follow the below steps to deploy the app to heroku
6770
1. `heroku login`
68-
1. `heroku create`
69-
1. `heroku addons:create mongolab`
70-
1. `heroku config:set NPM_CONFIG_PRODUCTION=false` so that heroku will install dev dependencies
71-
1. `git push heroku master` or `git push heroku develop:master` to deploy develop branch
72-
1. `heroku open` to load the app on browser
71+
2. `heroku create`
72+
3. `heroku addons:create mongolab`
73+
4. `heroku config:set NPM_CONFIG_PRODUCTION=false` so that heroku will install dev dependencies
74+
5. `git push heroku master` or `git push heroku develop:master` to deploy develop branch
75+
6. `heroku open` to load the app on browser
7376

7477
Note: heroku domain should match subdomain of topcoder-dev or topcoder depending upon target topcoder environment
7578

TopcoderXDeploy.md

Lines changed: 59 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Topcoder X overview
22

3-
Topcoder-X is a set of applications and services that allow a copilot or Topcoder customer to manage work directly through Gitlab or Github. When an issue is created in a Gitlab or Github project set up in Topcoder-X, Topcoder-X will create a Topcoder challenge to mirror the Gitlab or Github issue, and it will ensure that the challenge has the correct prize, copilot, assignee, description, and title. As the Gitlab or Github issue is updated, Topcoder-X will ensure that the Topcoder challenge associated with the issue is updated appropriately. When the Gitlab or Github issue is closed, Topcoder-X will activate and close the Topcoder challenge, ensuring that the members get paid as expected.
3+
Topcoder-X is a set of applications and services that allow a copilot or Topcoder customer to manage work directly through Gitlab or Github. When an issue is created in a Gitlab or Github project set up in Topcoder-X, Topcoder-X will create a Topcoder challenge to mirror the Gitlab or Github issue, and it will ensure that the challenge has the correct prize, copilot, assignee, description, and title. As the Gitlab or Github issue is updated, Topcoder-X will ensure that the Topcoder challenge associated with the issue is updated appropriately. When the Gitlab or Github issue is closed, Topcoder-X will activate and close the Topcoder challenge, ensuring that the members get paid as expected.
44

55
At each step of the process, Topcoder-X will add comments to the Gitlab or Github project, ensuring that the members know where the Topcoder challenge is and what the status of the challenge is.
66

@@ -10,7 +10,7 @@ The information is updated in real time based on webhook integrations with Gitla
1010

1111
## Dependencies
1212
* NodeJS 8+
13-
* MongoDB 3.2
13+
* DynamoDB
1414
* Kafka
1515
* nodemon (for local development)
1616

@@ -25,18 +25,21 @@ Topcoder-X comprises 3 pieces:
2525
All 3 pieces will be configured to use the same MongoDB and Kafka installations.
2626

2727

28-
## MongoDB
28+
## DynamoDB
2929

30-
The MongoDB can be created using default options. Just make sure that it is configured properly as `MONGODB_URI` in all 3 pieces:
30+
The DynamoDB can be created using default options. Just make sure that it is configured properly as `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`, `IS_LOCAL` in all 3 pieces:
3131

3232
* Topcoder-X processor
3333
* Topcoder-X receiver
3434
* Topcoder-X UI
3535

36-
Sample from our development environment:
37-
38-
`MONGODB_URI: mongodb://heroku_k366sw2n:<password>@ds135552.mlab.com:35552/heroku_k366sw2n`
39-
36+
Sample from our local development environment:
37+
```
38+
AWS_ACCESS_KEY_ID: 'FAKE_ACCESS_KEY_ID'
39+
AWS_SECRET_ACCESS_KEY: 'FAKE_SECRET_ACCESS_KEY'
40+
AWS_REGION: 'FAKE_REGION'
41+
IS_LOCAL: true
42+
```
4043
## Kafka
4144

4245
Installing Kafka can be done either locally or using a cloud service. You'll need to note how the service is configured and will have to update the configuration appropriately for the receiver, processor, and site.
@@ -56,7 +59,7 @@ KAFKA_CLIENT_CERT: <cert string>
5659
5760
KAFKA_CLIENT_CERT_KEY: <cert string>
5861
59-
KAFKA_HOST: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
62+
KAFKA_URL: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
6063
6164
TOPIC: topcoder-x
6265
```
@@ -67,7 +70,7 @@ So it would be updated from this:
6770

6871
```
6972
KAFKA_OPTIONS: {
70-
connectionString: process.env.KAFKA_HOST || 'localhost:9092',
73+
connectionString: process.env.KAFKA_URL || 'localhost:9092',
7174
ssl: {
7275
cert: process.env.KAFKA_CLIENT_CERT || fs.readFileSync('./kafka_client.cer'), // eslint-disable-line no-sync
7376
key: process.env.KAFKA_CLIENT_CERT_KEY || fs.readFileSync('./kafka_client.key'), // eslint-disable-line no-sync
@@ -79,15 +82,34 @@ To this:
7982

8083
```
8184
KAFKA_OPTIONS: {
82-
connectionString: process.env.KAFKA_HOST || 'localhost:9092'
85+
connectionString: process.env.KAFKA_URL || 'localhost:9092'
8386
},
8487
```
8588

89+
## Machine-to-machine (M2M) Token generation
90+
The `topcoder-x-processor` uses the Topcoder m2m token to interact with others Topcoder service.
91+
It needs to be configured properly. Please make sure the following items is configured:
92+
93+
- `AUTH0_URL` The Auth0 URL for generating Machine-to-machine token
94+
- `AUTH0_AUDIENCE` The audience of Auth0 to generate M2M Token
95+
- `AUTH0_CLIENT_ID` The Auth0 ClientID for generating Machine-to-machine token
96+
- `AUTH0_CLIENT_SECRET` The Auth0 Client Secret for generating Machine-to-machine token
97+
98+
99+
For local deployment, configuring M2M token generation can use this provided account:
100+
```
101+
export AUTH0_URL=https://topcoder-dev.auth0.com/oauth/token
102+
export AUTH0_AUDIENCE=https://m2m.topcoder-dev.com/
103+
export AUTH0_CLIENT_ID=LU2Nt7YPHQ3lxrFNKitJ82syB4wIMR7G
104+
export AUTH0_CLIENT_SECRET=O8S2YOb-0lI4NS3smR4d4uf0VM9BN0y1Ra4ABRktGUPOXc34mUO25uJrCpU-TBAT
105+
```
106+
107+
86108
## Local DNS setup
87109

88110
For login to work, your local Topcoder-X-UI deployment needs to have a `*.topcoder-dev.com` DNS name. Our development environment uses `x.topcoder-dev.com`
89111

90-
You can make this change in your local `/etc/hosts` file.
112+
You can make this change in your local `/etc/hosts` file.
91113

92114
```
93115
127.0.0.1 x.topcoder-dev.com
@@ -100,7 +122,7 @@ You can login with one of these sample accounts:
100122

101123
## Local webhook setup
102124

103-
The hardest part of the setup may be ensuring that Gitlab and Github can make callbacks to your local environment. You will have to ensure that your Topcoder-X receiver is publicly accessible on the public internet.
125+
The hardest part of the setup may be ensuring that Gitlab and Github can make callbacks to your local environment. You will have to ensure that your Topcoder-X receiver is publicly accessible on the public internet.
104126

105127
If your ISP dynamically configures your IP address, you can use a dyndns service:
106128

@@ -118,7 +140,7 @@ http://<publicly accessible domain name>:<port>/webhooks/gitlab
118140
#### Github
119141

120142
```
121-
https://<publicly accessible domain name>:<port>/webhooks/github
143+
https://<publicly accessible domain name>:<port>/webhooks/github
122144
```
123145

124146
## Account setup
@@ -153,7 +175,7 @@ Contest https://www.topcoder-dev.com/challenges/30052039 has been updated - it h
153175

154176
## Sample development configs
155177

156-
For reference, this is what the sample configs look like in our development environment, which should closely match your local deployment environment.
178+
For reference, this is what the sample configs look like in our development environment, which should closely match your local deployment environment.
157179

158180
You can use the Gitlab and Github keys and secrets below, but you are also welcome to create your own.
159181

@@ -165,7 +187,7 @@ EMAIL_SENDER_ADDRESS: [email protected]
165187
ISSUE_BID_EMAIL_RECEIVER: [email protected]
166188
KAFKA_CLIENT_CERT: <cert>
167189
KAFKA_CLIENT_CERT_KEY: <key>
168-
KAFKA_HOST: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
190+
KAFKA_URL: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
169191
LOG_LEVEL: debug
170192
MAILGUN_API_KEY: key-5ebe7a0fae37a9008721ec0bfe5bdd95
171193
MAILGUN_DOMAIN: sandbox3fcf4920781449f2a5293f8ef18e4bb6.mailgun.org
@@ -174,12 +196,19 @@ MAILGUN_SMTP_LOGIN: [email protected]
174196
MAILGUN_SMTP_PASSWORD: c8aefb446e76febdbc31d57ef30b9c10
175197
MAILGUN_SMTP_PORT: 587
176198
MAILGUN_SMTP_SERVER: smtp.mailgun.org
177-
MONGODB_URI: mongodb://heroku_k366sw2n:<password>@ds135552.mlab.com:35552/heroku_k366sw2n
178199
NODE_DEBUG: app
179200
NODE_ENV: development
180201
NODE_MODULES_CACHE: false
181202
NODE_TLS_REJECT_UNAUTHORIZED: 0
182203
TOPIC: topcoder-x
204+
AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID
205+
AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY
206+
AWS_REGION: FAKE_REGION
207+
IS_LOCAL: true
208+
AUTH0_URL: https://topcoder-dev.auth0.com/oauth/token
209+
AUTH0_AUDIENCE: https://m2m.topcoder-dev.com/
210+
AUTH0_CLIENT_ID: LU2Nt7YPHQ3lxrFNKitJ82syB4wIMR7G
211+
AUTH0_CLIENT_SECRET: O8S2YOb-0lI4NS3smR4d4uf0VM9BN0y1Ra4ABRktGUPOXc34mUO25uJrCpU-TBAT
183212
```
184213

185214
#### Topcoder-X receiver
@@ -189,12 +218,15 @@ Justins-Mac-Pro:~ justingasper$ heroku config --app topcoder-x-receiver-dev
189218
=== topcoder-x-receiver-dev Config Vars
190219
KAFKA_CLIENT_CERT: <cert>
191220
KAFKA_CLIENT_CERT_KEY: <key>
192-
KAFKA_HOST: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
221+
KAFKA_URL: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
193222
LOG_LEVEL: debug
194-
MONGODB_URI: mongodb://heroku_k366sw2n:<password>@ds135552.mlab.com:35552/heroku_k366sw2n
195223
NODE_ENV: development
196224
NODE_TLS_REJECT_UNAUTHORIZED: 0
197225
TOPIC: topcoder-x
226+
AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID
227+
AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY
228+
AWS_REGION: FAKE_REGION
229+
IS_LOCAL: true
198230
```
199231

200232
#### Topcoder-X UI
@@ -210,12 +242,17 @@ GITLAB_CLIENT_SECRET: 70367d8255e160828ae47f35ff71723202afc7be1f29a4c7319bc82c4
210242
HOOK_BASE_URL: https://topcoder-x-receiver-dev.herokuapp.com
211243
KAFKA_CLIENT_CERT: <cert>
212244
KAFKA_CLIENT_CERT_KEY: <key>
213-
KAFKA_HOST: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
214-
MONGODB_URI: mongodb://heroku_k366sw2n:<password>@ds135552.mlab.com:35552/heroku_k366sw2n
245+
KAFKA_URL: silver-craft-01.srvs.cloudkafka.com:9093,silver-craft-01.srvs.cloudkafka.com:9094
215246
NPM_CONFIG_PRODUCTION: false
216247
SESSION_SECRET: kjsdfkj34857
217248
TC_LOGIN_URL: https://accounts.topcoder-dev.com/member
218249
TC_USER_PROFILE_URL: http://api.topcoder-dev.com/v2/user/profile
219250
TOPIC: topcoder-x
220251
WEBSITE: https://x.topcoder-dev.com
221-
```
252+
AWS_ACCESS_KEY_ID: FAKE_ACCESS_KEY_ID
253+
AWS_SECRET_ACCESS_KEY: FAKE_SECRET_ACCESS_KEY
254+
AWS_REGION: FAKE_REGION
255+
IS_LOCAL: true
256+
TC_LOGIN_URL: https://accounts.topcoder-dev.com/member
257+
TC_USER_PROFILE_URL: https://api.topcoder-dev.com/v2/user/profile
258+
```

build.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
set -eo pipefail
3+
APP_NAME="topcoder-x-ui"
4+
UPDATE_CACHE=""
5+
docker-compose -f docker/docker-compose.yml build $APP_NAME
6+
docker create --name app $APP_NAME:latest
7+
8+
if [ -d node_modules ]
9+
then
10+
mv package-lock.json old-package-lock.json
11+
docker cp app:/$APP_NAME/package-lock.json package-lock.json
12+
set +eo pipefail
13+
UPDATE_CACHE=$(cmp package-lock.json old-package-lock.json)
14+
set -eo pipefail
15+
else
16+
UPDATE_CACHE=1
17+
fi
18+
19+
if [ "$UPDATE_CACHE" == 1 ]
20+
then
21+
docker cp app:/$APP_NAME/node_modules .
22+
fi

0 commit comments

Comments
 (0)