Skip to content

Commit e408d62

Browse files
committed
Merge remote-tracking branch 'github/develop'
2 parents 29f4532 + a12f7a5 commit e408d62

28 files changed

+1820
-131
lines changed

.eslintrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@
4343
}
4444
],
4545
"max-lines": 0,
46+
"max-statements": 0
4647
}
4748
}

.github-ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
image: starefossen/ruby-node:latest
2+
3+
variables:
4+
PORT: 3000
5+
APP_TITLE: "Unternehmen Lüttich: Processor"
6+
NODE_ENV: development
7+
8+
cache:
9+
paths:
10+
- node_modules/
11+
12+
stages:
13+
- build
14+
- test
15+
- deploy
16+
17+
building:
18+
script:
19+
- echo "Building the app"
20+
- npm i
21+
stage: build
22+
23+
testing:
24+
script:
25+
- echo "Running github tests"
26+
- npm i
27+
- npm run test:github
28+
stage: test
29+
30+
deploy_dev:
31+
stage: deploy
32+
script:
33+
- echo "Deploying the app"
34+
- apt-get update -qy
35+
- apt-get install -y rubygems ruby-dev
36+
- gem install dpl
37+
- dpl --provider=heroku --app=$HEROKU_DEV_APP --api-key=$HEROKU_DEV_API_KEY
38+
only:
39+
- develop
40+
environment:
41+
name: dev
42+
url: $HEROKU_DEV_URL
43+
44+
deploy_stage:
45+
stage: deploy
46+
script:
47+
- echo "Deploying the app"
48+
- apt-get update -qy
49+
- apt-get install -y rubygems ruby-dev
50+
- gem install dpl
51+
- dpl --provider=heroku --app=$HEROKU_STAGING_APP --api-key=$HEROKU_STAGING_API_KEY
52+
only:
53+
- master
54+
environment:
55+
name: stage
56+
url: $HEROKU_STAGING_URL
57+
variables:
58+
GIT_STRATEGY: fetch
59+
GIT_SUBMODULE_STRATEGY: recursive

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ building:
2222

2323
testing:
2424
script:
25-
- echo "Running tests"
25+
- echo "Running gitlab tests"
2626
- npm i
27-
- npm test
27+
- npm run test:gitlab
2828
stage: test
2929

3030
deploy_dev:

.test-ci.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
image: starefossen/ruby-node:latest
2+
3+
variables:
4+
PORT: 3000
5+
APP_TITLE: "Unternehmen Lüttich: Processor"
6+
NODE_ENV: development
7+
8+
cache:
9+
paths:
10+
- node_modules/
11+
12+
stages:
13+
- build
14+
- test
15+
- deploy
16+
17+
building:
18+
script:
19+
- echo "Building the app"
20+
- npm i
21+
stage: build
22+
23+
testing:
24+
script:
25+
- echo "Running all tests"
26+
- npm i
27+
- npm test
28+
stage: test
29+
30+
deploy_dev:
31+
stage: deploy
32+
script:
33+
- echo "Deploying the app"
34+
- apt-get update -qy
35+
- apt-get install -y rubygems ruby-dev
36+
- gem install dpl
37+
- dpl --provider=heroku --app=$HEROKU_DEV_APP --api-key=$HEROKU_DEV_API_KEY
38+
only:
39+
- develop
40+
environment:
41+
name: dev
42+
url: $HEROKU_DEV_URL
43+
44+
deploy_stage:
45+
stage: deploy
46+
script:
47+
- echo "Deploying the app"
48+
- apt-get update -qy
49+
- apt-get install -y rubygems ruby-dev
50+
- gem install dpl
51+
- dpl --provider=heroku --app=$HEROKU_STAGING_APP --api-key=$HEROKU_STAGING_API_KEY
52+
only:
53+
- master
54+
environment:
55+
name: stage
56+
url: $HEROKU_STAGING_URL
57+
variables:
58+
GIT_STRATEGY: fetch
59+
GIT_SUBMODULE_STRATEGY: recursive

README.md

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ The following config parameters are supported, they are defined in `config/defau
4141
|ISSUE_BID_EMAIL_RECEIVER| the email receiver about bid email||
4242
|TC_URL| the base URL of topcoder to get the challenge URL| defaults to `https://www.topcoder-dev.com`|
4343
|GITLAB_API_BASE_URL| the URL for gitlab host| defaults to `https://gitlab.com`|
44-
|PAID_ISSUE_LABEL|the label name for paid, should be one of the label configured in topcoder x ui|'Paid'|
45-
|FIX_ACCEPTED_ISSUE_LABEL|the label name for fix accepted, should be one of the label configured in topcoder x ui|'Fix Accepted'|
44+
|PAID_ISSUE_LABEL|the label name for paid, should be one of the label configured in topcoder x ui|'tcx_Paid'|
45+
|FIX_ACCEPTED_ISSUE_LABEL|the label name for fix accepted, should be one of the label configured in topcoder x ui|'tcx_FixAccepted'|
46+
|ASSIGNED_ISSUE_LABEL| the label name for assigned, should be one of the label configured in topcoder x ui| 'tcx_Assigned'|
47+
|OPEN_FOR_PICKUP_ISSUE_LABEL| the label name for open for pickup, should be one of the label configured in topcoder x ui| 'tcx_OpenForPickup'|
4648
|TC_OR_DETAIL_LINK|the link to online review detail of challenge| see `default.js`, OR link for dev environment|
49+
|RETRY_COUNT| the number of times an event should be retried to process| 3|
50+
|RETRY_INTERVAL| the interval at which the event should be retried to process in milliseconds | 120000|
51+
|READY_FOR_REVIEW_ISSUE_LABEL| the label name for ready for review, should be one of the label configured in topcoder x ui|'tcx_ReadyForReview'|
4752

4853
KAFKA_OPTIONS should be object as described in https://github.com/oleksiyk/kafka#ssl
4954
For using with SSL, the options should be as
@@ -60,12 +65,19 @@ For using with SSL, the options should be as
6065
The following config paramaters are supported in the test environment defined in `config/test.js` and can be configured in the system environment. Note that the test config inherits all config options present in the default config and adds/overrides some config options.
6166

6267
| Name | Description | Default |
63-
| :----------------------------- | :----------------------------------------: | :------------------------------: |
64-
| GITLAB_REPO_URL | the url of the gitlab repo to run tests in | |
68+
| :----------------------------- | :----------------------------------------: | :------------------------------: | |
6569
| TC_URL | the topcoder development url | https://www.topcoder-dev.com |
6670
| TC_DEV_API_URL | the topcoder development api url | https://api.topcoder-dev.com/v3|
67-
| WAIT_TIME | the amount of time in milliseconds to wait for updates on gitlab to propagate to topcoder challenges. Some tests use multipliers of this value | 60000 |
68-
71+
| MAX_RETRY_COUNT | the maximum number of times to re-test before concluding that test failed | https://api.topcoder-dev.com/v3|
72+
| WAIT_TIME | the amount of time in milliseconds to wait before running a re-test | 30000 |
73+
| TC_DIRECT_ID | the topcoder direct id of the repository which is set up with a valid billing account | 7377 |
74+
| TOPCODER_USER_NAME | a valid username for topcoder dev platform | mess |
75+
| HOOK_BASE_URL | the webhook url of topcoder-x-receiver | |
76+
| GITHUB_ACCESS_TOKEN | github personal access token | |
77+
| GITHUB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
78+
| GITLAB_USERNAME | gitlab username | |
79+
| GITLAB_PASSWORD | gitlab password | |
80+
| GITLAB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
6981

7082
## Local Deployment
7183

@@ -86,10 +98,28 @@ Go to Topcoder X UI login with above used topcoder username and
8698

8799
Now, receiver service can receive the webhooks from git host's project and processor can processes the requests. Now you can verify this service by following the verification steps below
88100

89-
## Run tests
101+
## Run all tests
102+
Configure the Github access tokens, Gitlab username and password in `config/test.js`.
103+
104+
To create a Github personal access token, click on Settings -> Developer settings -> Personal access tokens -> Generate new token -> Provide all permissions.
105+
106+
Configure gitlab username and password.
107+
108+
Now provide repository names which do not already exist.
109+
110+
You can then run both github and gitlab tests by using
90111
```
91112
npm test
92113
```
114+
115+
### Run only github tests
116+
```
117+
npm run test:github
118+
```
119+
### Run only gitlab tests
120+
```
121+
npm run test:gitlab
122+
```
93123
## Verification
94124

95125
- create an issue in the repo, you can see the logs in `receiver` and `processor`, the `issue.created` event is generated.

config/default.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ module.exports = {
2121
ssl: {
2222
cert: process.env.KAFKA_CLIENT_CERT || fs.readFileSync('./kafka_client.cer'), // eslint-disable-line no-sync
2323
key: process.env.KAFKA_CLIENT_CERT_KEY || fs.readFileSync('./kafka_client.key'), // eslint-disable-line no-sync
24+
passphrase: 'secret', // NOTE:* This configuration specifies the private key passphrase used while creating it.
2425
}
2526
},
2627
MONGODB_URL: process.env.MONGODB_URI || 'mongodb://127.0.0.1:27017/topcoderx',
@@ -80,9 +81,11 @@ module.exports = {
8081
ISSUE_BID_EMAIL_RECEIVER: process.env.ISSUE_BID_EMAIL_RECEIVER || '',
8182
TC_URL: process.env.TC_URL || 'https://www.topcoder-dev.com',
8283
GITLAB_API_BASE_URL: process.env.GITLAB_API_BASE_URL || 'https://gitlab.com',
83-
PAID_ISSUE_LABEL: process.env.PAID_ISSUE_LABEL || 'Paid',
84-
FIX_ACCEPTED_ISSUE_LABEL: process.env.FIX_ACCEPTED_ISSUE_LABEL || 'Fix accepted',
85-
READY_FOR_REVIEW_ISSUE_LABEL: process.env.READY_FOR_REVIEW_ISSUE_LABEL || 'Ready for review',
84+
PAID_ISSUE_LABEL: process.env.PAID_ISSUE_LABEL || 'tcx_Paid',
85+
FIX_ACCEPTED_ISSUE_LABEL: process.env.FIX_ACCEPTED_ISSUE_LABEL || 'tcx_FixAccepted',
86+
READY_FOR_REVIEW_ISSUE_LABEL: process.env.READY_FOR_REVIEW_ISSUE_LABEL || 'tcx_ReadyForReview',
87+
ASSIGNED_ISSUE_LABEL: process.env.READY_FOR_REVIEW_ISSUE_LABEL || 'tcx_Assigned',
88+
OPEN_FOR_PICKUP_ISSUE_LABEL: process.env.READY_FOR_REVIEW_ISSUE_LABEL || 'tcx_OpenForPickup',
8689
TC_OR_DETAIL_LINK: process.env.TC_OR_DETAIL_LINK || 'https://software.topcoder-dev.com/review/actions/ViewProjectDetails?pid=',
8790
RETRY_COUNT: process.env.RETRY_COUNT || 3,
8891
RETRY_INTERVAL: process.env.RETRY_INTERVAL || 120000, // 2 minutes

config/test.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017 TopCoder, Inc. All rights reserved.
2+
* Copyright (c) 2018 TopCoder, Inc. All rights reserved.
33
*/
44
'use strict';
55
/**
@@ -11,10 +11,18 @@
1111
const defaultConfig = require('./default');
1212

1313
const testConfig = {
14-
GITLAB_REPO_URL: process.env.GITLAB_REPO_URL || '',
1514
TC_URL: process.env.TC_URL || 'https://www.topcoder-dev.com',
1615
TC_DEV_API_URL: process.env.TC_DEV_API_URL || 'https://api.topcoder-dev.com/v3',
17-
WAIT_TIME: process.env.WAIT_TIME || 60000
16+
MAX_RETRY_COUNT: process.env.MAX_RETRY_COUNT || 25,
17+
WAIT_TIME: process.env.WAIT_TIME || 30000,
18+
TC_DIRECT_ID: process.env.TC_DIRECT_ID || 7377,
19+
TOPCODER_USER_NAME: process.env.TOPCODER_USER_NAME || 'mess',
20+
HOOK_BASE_URL: process.env.HOOK_BASE_URL || '',
21+
GITHUB_ACCESS_TOKEN: process.env.GITHUB_ACCESS_TOKEN || '',
22+
GITHUB_REPOSITORY_NAME: process.env.GITHUB_REPOSITORY_NAME || '',
23+
GITLAB_USERNAME: process.env.GITLAB_USERNAME || '',
24+
GITLAB_PASSWORD: process.env.GITLAB_PASSWORD || '',
25+
GITLAB_REPOSITORY_NAME: process.env.GITLAB_REPOSITORY_NAME || '',
1826
};
1927

2028
module.exports = Object.assign(defaultConfig, testConfig);

configuration.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,14 @@ The following config parameters are supported, they are defined in `config/defau
2323
|ISSUE_BID_EMAIL_RECEIVER| the email receiver about bid email||
2424
|TC_URL| the base URL of topcoder to get the challenge URL| defaults to `https://www.topcoder-dev.com`|
2525
|GITLAB_API_BASE_URL| the URL for gitlab host| defaults to `https://gitlab.com`|
26-
|PAID_ISSUE_LABEL|the label name for paid, should be one of the label configured in topcoder x ui|'Paid'|
27-
|FIX_ACCEPTED_ISSUE_LABEL|the label name for fix accepted, should be one of the label configured in topcoder x ui|'Fix Accepted'|
26+
|PAID_ISSUE_LABEL|the label name for paid, should be one of the label configured in topcoder x ui|'tcx_Paid'|
27+
|FIX_ACCEPTED_ISSUE_LABEL|the label name for fix accepted, should be one of the label configured in topcoder x ui|'tcx_FixAccepted'|
28+
|ASSIGNED_ISSUE_LABEL| the label name for assigned, should be one of the label configured in topcoder x ui| 'tcx_Assigned'|
29+
|OPEN_FOR_PICKUP_ISSUE_LABEL| the label name for open for pickup, should be one of the label configured in topcoder x ui| 'tcx_OpenForPickup'|
2830
|TC_OR_DETAIL_LINK|the link to online review detail of challenge| see `default.js`, OR link for dev environment|
2931
|RETRY_COUNT| the number of times an event should be retried to process| 3|
3032
|RETRY_INTERVAL| the interval at which the event should be retried to process in milliseconds | 120000|
31-
|READY_FOR_REVIEW_ISSUE_LABEL| the label name for ready for review, should be one of the label configured in topcoder x ui|'Ready for review'|
33+
|READY_FOR_REVIEW_ISSUE_LABEL| the label name for ready for review, should be one of the label configured in topcoder x ui|'tcx_ReadyForReview'|
3234

3335
KAFKA_OPTIONS should be object as described in https://github.com/oleksiyk/kafka#ssl
3436
For using with SSL, the options should be as
@@ -45,11 +47,19 @@ For using with SSL, the options should be as
4547
The following config paramaters are supported in the test environment defined in `config/test.js` and can be configured in the system environment. Note that the test config inherits all config options present in the default config and adds/overrides some config options.
4648

4749
| Name | Description | Default |
48-
| :----------------------------- | :----------------------------------------: | :------------------------------: |
49-
| GITLAB_REPO_URL | the url of the gitlab repo to run tests in | |
50+
| :----------------------------- | :----------------------------------------: | :------------------------------: | |
5051
| TC_URL | the topcoder development url | https://www.topcoder-dev.com |
5152
| TC_DEV_API_URL | the topcoder development api url | https://api.topcoder-dev.com/v3|
52-
| WAIT_TIME | the amount of time in milliseconds to wait for updates on gitlab to propagate to topcoder challenges. Some tests use multipliers of this value | 60000 |
53+
| MAX_RETRY_COUNT | the maximum number of times to re-test before concluding that test failed | https://api.topcoder-dev.com/v3|
54+
| WAIT_TIME | the amount of time in milliseconds to wait before running a re-test | 30000 |
55+
| TC_DIRECT_ID | the topcoder direct id of the repository which is set up with a valid billing account | 7377 |
56+
| TOPCODER_USER_NAME | a valid username for topcoder dev platform | mess |
57+
| HOOK_BASE_URL | the webhook url of topcoder-x-receiver | |
58+
| GITHUB_ACCESS_TOKEN | github personal access token | |
59+
| GITHUB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
60+
| GITLAB_USERNAME | gitlab username | |
61+
| GITLAB_PASSWORD | gitlab password | |
62+
| GITLAB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
5363

5464
## Github Verification
5565

models/CopilotPayment.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2018 TopCoder, Inc. All rights reserved.
3+
*/
4+
5+
/**
6+
* Schema for copilot Payment.
7+
* @author TCSCODER
8+
* @version 1.0
9+
*/
10+
11+
'use strict';
12+
13+
const mongoose = require('mongoose');
14+
15+
const schema = new mongoose.Schema({
16+
project: {type: mongoose.Schema.Types.ObjectId, ref: 'Project'},
17+
amount: {type: Number, required: true},
18+
description: {type: String, required: true},
19+
challengeId: {type: Number, required: false},
20+
closed: {type: Boolean, required: true, default: false},
21+
username: {type: String, required: true},
22+
status: {type: String}
23+
});
24+
25+
schema.index({project: 1});
26+
schema.index({username: 1});
27+
schema.index({challengeId: 1});
28+
schema.index({closed: 1});
29+
30+
module.exports = schema;

models/Issue.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@ const schema = new mongoose.Schema({
2525
default: Date.now
2626
},
2727
// From topcoder api
28-
challengeId: {type: Number, required: true, unique: true},
29-
projectId: {type: mongoose.Schema.Types.ObjectId, ref: 'Project'}
28+
challengeId: {type: Number, required: false, unique: true},
29+
projectId: {type: mongoose.Schema.Types.ObjectId, ref: 'Project'},
30+
status: {type: String}
3031
});
3132

3233
// Issue number, provider, repositoryId must be unique

models/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ const models = {
2121
Issue: connection.model('Issue', require('./Issue')),
2222
Project: connection.model('Project', require('./Project')),
2323
User: connection.model('User', require('./User')),
24-
UserMapping: connection.model('UserMapping', require('./UserMapping'))
24+
UserMapping: connection.model('UserMapping', require('./UserMapping')),
25+
CopilotPayment: connection.model('CopilotPayment', require('./CopilotPayment'))
2526
};
2627
/* eslint-enable global-require */
2728

0 commit comments

Comments
 (0)