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

Commit ba019f0

Browse files
committed
Github unit tests
1 parent dee8c60 commit ba019f0

15 files changed

+1800
-897
lines changed

.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: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,19 @@ For using with SSL, the options should be as
6060
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.
6161

6262
| Name | Description | Default |
63-
| :----------------------------- | :----------------------------------------: | :------------------------------: |
64-
| GITLAB_REPO_URL | the url of the gitlab repo to run tests in | |
63+
| :----------------------------- | :----------------------------------------: | :------------------------------: | |
6564
| TC_URL | the topcoder development url | https://www.topcoder-dev.com |
6665
| 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-
66+
| MAX_RETRY_COUNT | the maximum number of times to re-test before concluding that test failed | https://api.topcoder-dev.com/v3|
67+
| WAIT_TIME | the amount of time in milliseconds to wait before running a re-test | 30000 |
68+
| TC_DIRECT_ID | the topcoder direct id of the repository which is set up with a valid billing account | 7377 |
69+
| TOPCODER_USER_NAME | a valid username for topcoder dev platform | mess |
70+
| HOOK_BASE_URL | the webhook url of topcoder-x-receiver | |
71+
| GITHUB_ACCESS_TOKEN | github personal access token | |
72+
| GITHUB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
73+
| GITLAB_USERNAME | gitlab username | |
74+
| GITLAB_PASSWORD | gitlab password | |
75+
| GITLAB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
6976

7077
## Local Deployment
7178

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

8794
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
8895

89-
## Run tests
96+
## Run all tests
97+
Configure the Github access tokens, Gitlab username and password in `config/test.js`.
98+
99+
To create a Github personal access token, click on Settings -> Developer settings -> Personal access tokens -> Generate new token -> Provide all permissions.
100+
101+
Configure gitlab username and password.
102+
103+
Now provide repository names which do not already exist.
104+
105+
You can then run both github and gitlab tests by using
90106
```
91107
npm test
92108
```
109+
110+
### Run only github tests
111+
```
112+
npm run test:github
113+
```
114+
### Run only gitlab tests
115+
```
116+
npm run test:gitlab
117+
```
93118
## Verification
94119

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

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: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,19 @@ For using with SSL, the options should be as
4545
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.
4646

4747
| Name | Description | Default |
48-
| :----------------------------- | :----------------------------------------: | :------------------------------: |
49-
| GITLAB_REPO_URL | the url of the gitlab repo to run tests in | |
48+
| :----------------------------- | :----------------------------------------: | :------------------------------: | |
5049
| TC_URL | the topcoder development url | https://www.topcoder-dev.com |
5150
| 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 |
51+
| MAX_RETRY_COUNT | the maximum number of times to re-test before concluding that test failed | https://api.topcoder-dev.com/v3|
52+
| WAIT_TIME | the amount of time in milliseconds to wait before running a re-test | 30000 |
53+
| TC_DIRECT_ID | the topcoder direct id of the repository which is set up with a valid billing account | 7377 |
54+
| TOPCODER_USER_NAME | a valid username for topcoder dev platform | mess |
55+
| HOOK_BASE_URL | the webhook url of topcoder-x-receiver | |
56+
| GITHUB_ACCESS_TOKEN | github personal access token | |
57+
| GITHUB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
58+
| GITLAB_USERNAME | gitlab username | |
59+
| GITLAB_PASSWORD | gitlab password | |
60+
| GITLAB_REPOSITORY_NAME | the name of the repository to create for testing (should not already exist) | |
5361

5462
## Github Verification
5563

0 commit comments

Comments
 (0)