|
| 1 | +## Prerequisite |
| 2 | + |
| 3 | +Git |
| 4 | + |
| 5 | +Docker & Docker-compose |
| 6 | + |
| 7 | +JDK 1.8 & OpenSSL: used to generate certificates. The OpenSSL most likely already exists in Linux/Mac system, if you don't have it get it here https://wiki.openssl.org/index.php/Binaries |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## Clone Repo |
| 12 | + |
| 13 | +Within submission root dir, clone git repos, e.g clone the master branch to deploy: |
| 14 | + |
| 15 | +```bash |
| 16 | +# Within submission root dir |
| 17 | + |
| 18 | +# The submission works on commit 96988f9ce80d968fe6be0a0fd31632b73442cbc0 |
| 19 | +git clone -b master https://github.com/topcoder-platform/topcoder-x-ui |
| 20 | +cd topcoder-x-ui && git checkout 96988f9ce80d968fe6be0a0fd31632b73442cbc0 && cd .. |
| 21 | + |
| 22 | +# The submission works on commit 3c5d798d133adc5440ff61e56345a03fca9167cf |
| 23 | +git clone -b master https://github.com/topcoder-platform/topcoder-x-receiver |
| 24 | +cd topcoder-x-receiver && git checkout 3c5d798d133adc5440ff61e56345a03fca9167cf && cd .. |
| 25 | + |
| 26 | +# The submission works on commit e408d62fd190e9b2412e02004c916a6afa5e70db |
| 27 | +git clone -b master https://github.com/topcoder-platform/topcoder-x-processor |
| 28 | +cd topcoder-x-processor && git checkout e408d62fd190e9b2412e02004c916a6afa5e70db && cd .. |
| 29 | +``` |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +## Apply Patch |
| 34 | + |
| 35 | +```bash |
| 36 | +cd topcoder-x-ui |
| 37 | +git am --ignore-space-change ../patches/topcoder-x-ui.patch |
| 38 | +cd .. |
| 39 | + |
| 40 | +cd topcoder-x-receiver |
| 41 | +git am --ignore-space-change ../patches/topcoder-x-receiver.patch |
| 42 | +cd .. |
| 43 | + |
| 44 | +cd topcoder-x-processor |
| 45 | +git am --ignore-space-change ../patches/topcoder-x-processor.patch |
| 46 | +cd .. |
| 47 | +``` |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | +## Config Docker IP |
| 52 | + |
| 53 | +Normally you can use `127.0.0.1` as the docker ip. If you use docker machine, use `docker-machine ip` to get the docker machine ip. |
| 54 | + |
| 55 | +Then in your hosts file config `x.topcoder-dev.com` to resolve to docker ip: |
| 56 | + |
| 57 | +``` |
| 58 | +127.0.0.1 x.topcoder-dev.com |
| 59 | +``` |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | +## Setup GitHub OAuth App |
| 64 | + |
| 65 | +Follow this section to generate your own `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` in [local-deploy/env/topcoder-x-ui.env.local](local-deploy/env/topcoder-x-ui.env.local) configuration: |
| 66 | + |
| 67 | +1. Login into github.com |
| 68 | +2. Navigate to https://github.com/settings/developers |
| 69 | +3. Click `New OAuth App` button |
| 70 | +4. Fill in the fields with following values (See http://take.ms/ajdgy): |
| 71 | + - Application name: Topcoder-X |
| 72 | + - Homepage URL: http://x.topcoder-dev.com |
| 73 | + - Authorization callback URL: http://x.topcoder-dev.com |
| 74 | +5. After creating the OAuth app, you can see its client id and client secret, set them as `GITHUB_CLIENT_ID` and `GITHUB_CLIENT_SECRET` values in [local-deploy/env/topcoder-x-ui.env.default](local-deploy/env/topcoder-x-ui.env.default) configuration |
| 75 | + |
| 76 | + |
| 77 | + |
| 78 | +Also config your own `GITHUB_ACCESS_TOKEN` in [local-deploy/env/topcoder-x-processor.env.test](local-deploy/env/topcoder-x-processor.env.test) , you can create access token from https://github.com/settings/tokens |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +## Setup GitLab OAuth App |
| 83 | + |
| 84 | +Follow this section to generate your own `GITLAB_CLIENT_ID` and `GITLAB_CLIENT_SECRET` in [local-deploy/env/topcoder-x-ui.env.local](local-deploy/env/topcoder-x-ui.env.local) configuration: |
| 85 | + |
| 86 | +- Login into gitlab.com |
| 87 | +- Navigate to https://gitlab.com/profile/applications |
| 88 | +- Fill in the fields with following values (See http://take.ms/ERoDs): |
| 89 | + - Name: Topcoder-X |
| 90 | + - Redirect URI: enter two callback URLs, one callback URL per line, so there are two lines: |
| 91 | + http://topcoderx.topcoder-dev.com/api/v1/gitlab/owneruser/callback |
| 92 | + http://topcoderx.topcoder-dev.com/api/v1/gitlab/normaluser/callback |
| 93 | + - Scopes: check `api` and `read_user`, `api` is for owner user, `read_user` is for normal user |
| 94 | +- After creating the OAuth app, you can see its generated Application Id and Secret, set them as `GITLAB_CLIENT_ID` and `GITLAB_CLIENT_SECRET` values in [local-deploy/env/topcoder-x-ui.env.default](local-deploy/env/topcoder-x-ui.env.default) configuration |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | +Also config your own `GITLAB_USERNAME` and `GITLAB_PASSWORD` in [local-deploy/env/topcoder-x-processor.env.test](local-deploy/env/topcoder-x-processor.env.test) |
| 99 | + |
| 100 | + |
| 101 | + |
| 102 | +## Setup Ngrok |
| 103 | + |
| 104 | +Download Ngrok from https://ngrok.com/download and install it. Then signup and go to https://dashboard.ngrok.com/auth to find your auth token. run: |
| 105 | + |
| 106 | +```bash |
| 107 | +./ngrok authtoken <your-own-ngrok-token> |
| 108 | +./ngrok http 3002 |
| 109 | +# You will see something like following: |
| 110 | + |
| 111 | +# Session Status online |
| 112 | +# Session Expired Restart ngrok or upgrade: ngrok.com/upgrade |
| 113 | +# Version 2.2.8 |
| 114 | +# Region United States (us) |
| 115 | +# Web Interface http://127.0.0.1:4040 |
| 116 | +# Forwarding http://a9ee41f3.ngrok.io -> localhost:3002 |
| 117 | +# Forwarding https://a9ee41f3.ngrok.io -> localhost:3002 |
| 118 | +``` |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | +Set your own forwarding http URL (like `http://a9ee41f3.ngrok.io`) to `HOOK_BASE_URL` value in [local-deploy/env/topcoder-x-ui.env.default](local-deploy/env/topcoder-x-ui.env.default) and [local-deploy/env/topcoder-x-processor.env.test](local-deploy/env/topcoder-x-processor.env.test) |
| 123 | + |
| 124 | + |
| 125 | + |
| 126 | +At this point the configuration are all setup. |
| 127 | + |
| 128 | + |
| 129 | + |
| 130 | +## Deploy locally |
| 131 | + |
| 132 | +```bash |
| 133 | +cd local-deploy |
| 134 | +./local-deploy.sh local |
| 135 | + |
| 136 | +# The first time it takes several minutes to build and deploy, be patient |
| 137 | +``` |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | +When you see something like following, the docker services are all started: |
| 142 | + |
| 143 | +```verilog |
| 144 | +Creating network "topcoder-x-docker_default" with the default driver |
| 145 | +Creating maildev.local ... done |
| 146 | +Creating mongo.local ... done |
| 147 | +Creating zookeeper.local ... done |
| 148 | +Creating kafka.local ... done |
| 149 | +maildev.local is up-to-date |
| 150 | +mongo.local is up-to-date |
| 151 | +zookeeper.local is up-to-date |
| 152 | +kafka.local is up-to-date |
| 153 | +Creating topcoder-x-ui.local ... done |
| 154 | +Creating topcoder-x-processor.local ... done |
| 155 | +Creating topcoder-x-receiver.local ... done |
| 156 | +``` |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | +## Github Verification |
| 161 | + |
| 162 | +Goto http://x.topcoder-dev.com , login with `mess/appirio123` : http://take.ms/Erprt |
| 163 | + |
| 164 | +Goto http://x.topcoder-dev.com/#/app/settings , setup the OAuth authentication of Github and Gitlab: http://take.ms/d2RqT |
| 165 | + |
| 166 | + |
| 167 | + |
| 168 | +Goto http://x.topcoder-dev.com/#/app/projects , add a project with github repo (you can create a public repo to test), enter 7377 for Direct ID: http://take.ms/hn4p0 |
| 169 | + |
| 170 | + |
| 171 | + |
| 172 | +After project created, click `Edit` button: http://take.ms/hn4p0 |
| 173 | + |
| 174 | +Then click `Add Labels` button, then in github labels page (https://github.com/you-user-name/your-repo-name/labels) you should see "tax_XXX" labels created: http://take.ms/4naCe |
| 175 | + |
| 176 | +Then click `Add Webhook` button, then in github webhooks page (https://github.com/your-user-name/your-repo-name/settings/hooks) you should see webhooks created: http://take.ms/Xgexa |
| 177 | + |
| 178 | +Then click `Add Wiki Rules` button, then in github issues page you should see a ticket rules issue created: http://take.ms/sIx0T |
| 179 | + |
| 180 | + |
| 181 | + |
| 182 | +Now in Github, create an issue with name `[$100] Some test issue` (the issue name format is important), then wait about one minute, refresh the issue page you should see a challenge is auto created: http://take.ms/zlibK . Then click the challenge url: http://take.ms/bDU5w |
| 183 | + |
| 184 | + |
| 185 | + |
| 186 | +At this point we have verified the Github OAuth authentication, the communication between Github/Topcoder-x/Kafka and TC-API works. |
| 187 | + |
| 188 | + |
| 189 | + |
| 190 | +## Gitlab Verification |
| 191 | + |
| 192 | +Goto http://x.topcoder-dev.com , login with `mess/appirio123` : http://take.ms/Erprt |
| 193 | + |
| 194 | +Goto http://x.topcoder-dev.com/#/app/settings , setup the OAuth authentication of Github and Gitlab: http://take.ms/d2RqT |
| 195 | + |
| 196 | + |
| 197 | + |
| 198 | +Goto http://x.topcoder-dev.com/#/app/projects , add a project with gitlab repo (you can create a public repo to test), enter 7377 for Direct ID: http://take.ms/XDvPB |
| 199 | + |
| 200 | + |
| 201 | + |
| 202 | +After project created, click `Edit` button: http://take.ms/mLtlq |
| 203 | + |
| 204 | +Then click `Add Labels` button, then in gitlab labels page (https://gitlab.com/your-user-name/your-repo-name/labels) you should see "tax_XXX" labels created: http://take.ms/gOMMX |
| 205 | + |
| 206 | +Then click `Add Webhook` button, then in gitlab webhooks page (https://gitlab.com/your-user-name/your-repo-name/settings/integrations) you should see webhooks created: http://take.ms/EjHLy |
| 207 | + |
| 208 | +Then click `Add Wiki Rules` button, then in gitlab wiki page (https://gitlab.com/your-user-name/your-repo-name/wikis/Gitlab-ticket-rules) you should see the ticket rules wiki page created: http://take.ms/yrzF3 |
| 209 | + |
| 210 | + |
| 211 | + |
| 212 | +Now in Gitlab, create an issue with name `[$100] Some test issue` (the issue name format is important), then wait about one minute, refresh the issue page you should see a challenge is auto created: http://take.ms/K8UHS. Then click the challenge url: http://take.ms/U5afZ |
| 213 | + |
| 214 | + |
| 215 | + |
| 216 | +At this point we have verified the Gitlab OAuth authentication, the communication between Gitlab/Topcoder-x/Kafka and TC-API works. |
| 217 | + |
| 218 | + |
| 219 | + |
| 220 | +## Unit Tests |
| 221 | + |
| 222 | +At first deploy test environment: |
| 223 | + |
| 224 | +```bash |
| 225 | +cd local-deploy |
| 226 | +./local-deploy.sh test |
| 227 | +``` |
| 228 | + |
| 229 | + |
| 230 | + |
| 231 | +Then: |
| 232 | + |
| 233 | +```bash |
| 234 | +# Unit tests for gitlab |
| 235 | +docker exec -it topcoder-x-processor.test npm run test:gitlab |
| 236 | + |
| 237 | +# It has code bug and immediately fails |
| 238 | +``` |
| 239 | + |
| 240 | + |
| 241 | + |
| 242 | +```bash |
| 243 | +# Unit tests for github |
| 244 | +docker exec -it topcoder-x-processor.test npm run test:github |
| 245 | + |
| 246 | +# It runs more than 30 minutes and still not finish |
| 247 | +``` |
| 248 | + |
0 commit comments