forked from ubccpsc/classy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.yml
274 lines (228 loc) · 9.54 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
# Javascript Node CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
build:
docker:
# specify the version you desire here
- image: circleci/node:12
- image: circleci/mongo:3.6
# Specify service dependencies here if necessary
# CircleCI maintains a library of pre-built images
# documented at https://circleci.com/docs/2.0/circleci-images/
# - image: circleci/mongo:3.4.4
working_directory: ~/project
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-
- run: yarn install --ignore-engines
- run:
command: cd packages/common && yarn install --ignore-engines
name: Preparing common
- run:
command: cd packages/autotest && yarn install --ignore-engines
name: Preparing autotest
- run:
command: cd packages/portal/backend && mkdir -p ssl/ && yarn install --ignore-engines
name: Preparing backend
- save_cache:
paths:
- node_modules
# - packages/common/node_modules
# - packages/portal-backend/node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run:
name: "Setup encrypted .env variable per Classy fork (chooses default env.enc when not set)"
command: |
echo 'export ENV_ENC_FILE="${ENCRYPT_ENV:-env}"' >> $BASH_ENV # Redirect ENCRYPT_ENV into $BASH_ENV
# openssl aes-256-cbc -e -md sha512 -in ../.env -out .config -k $KEY
- run:
command: cd .circleci && openssl aes-256-cbc -d -md sha512 -in "$ENV_ENC_FILE.enc" -out ../.env -k $ENVKEY
name: Configuring .env
when: always
- run:
command: cd .circleci && mkdir -p ../packages/portal-backend/ssl && openssl aes-256-cbc -d -md sha512 -in fullchain.enc -out ../packages/portal/backend/ssl/fullchain.pem -k $ENVKEY
name: Configuring SSL-1
when: always
- run:
command: cd .circleci && openssl aes-256-cbc -d -md sha512 -in privkey.enc -out ../packages/portal/backend/ssl/privkey.pem -k $ENVKEY
name: Configuring SSL-2
when: always
- run:
command: cd packages/common && ../../node_modules/typescript/bin/tsc
name: Building common
when: always
- run:
command: cd packages/portal/backend && ../../../node_modules/typescript/bin/tsc
name: Building backend
when: always
- run:
command: cd packages/portal/frontend && ../../../node_modules/typescript/bin/tsc && yarn webpack
name: Building frontend and bundle with Webpack
when: always
# statically validate the frontend (this is the best we can do as there are no automated UI tests yet)
# - run:
# command: cd packages/portal/frontend && ../../../node_modules/typescript/bin/tsc && ../../../node_modules/webpack/bin/webpack.js
# name: Building frontend
# when: always
- run:
command: cd packages/autotest && ../../node_modules/typescript/bin/tsc
name: Building autotest
when: always
- run:
command: yarn run lint
name: Linting project
when: always
- run:
command: git config --global user.email "[email protected]" && git config --global user.name "CI Test Name"
name: Configure local git
when: on_success
## WORKS
- run:
command: |
set -e
cd packages/portal/backend
./node_modules/.bin/nyc --reporter html --report-dir ../../../testOutput/backend/coverage --reporter=text-lcov yarn run testCI
name: Running backend tests
environment:
MOCHA_FILE: testOutput/backend/test/test-results.xml
when: on_success
- run:
command: mkdir -p testOutput/backend/test/ && ./node_modules/xunit-viewer/bin/xunit-viewer --results=packages/portal/backend/testOutput/backend/test/test-results.xml --output=testOutput/backend/test/index.html
name: Converting backend test results to HTML
when: on_success
- run:
command: |
set -e
cd packages/autotest
yarn coverCI
name: Running autotest tests
environment:
MOCHA_FILE: testOutput/autotest/test/test-results.xml
when: on_success
- run:
command: mkdir -p testOutput/autotest/test/ && ./node_modules/xunit-viewer/bin/xunit-viewer --results=packages/autotest/testOutput/autotest/test/test-results.xml --output=testOutput/autotest/test/index.html
name: Converting autotest test results to HTML
when: on_success
- run:
command: cd packages/portal/backend && yarn coveralls
name: Running backend coveralls
when: on_success
# coveralls doesn't integrate coverage
# so this overwrites the backend coverage (which we care about more)
# this is disabled and shouldn't be enabled until this is fixed
# - run:
# command: cd packages/autotest && yarn coveralls
# name: Running autotest coveralls
# when: always
- run:
command: cd packages/portal/backend && yarn codecov
name: Running backend codecov
when: on_success
- store_test_results:
path: testOutput
- store_artifacts:
path: testOutput
- run:
command: rm .env && rm packages/portal/backend/ssl/fullchain.pem && rm packages/portal/backend/ssl/privkey.pem
name: Cleaning up
when: always
build_run_stop:
machine:
image: ubuntu-1604:201903-01
working_directory: ~/project
environment:
TEST_LOGS: /home/circleci/project/test-logs
steps:
- checkout
- run:
name: "Setup encrypted .env variable per Classy fork (chooses default env.enc when not set)"
command: |
set -x
echo 'export ENV_ENC_FILE="${ENCRYPT_ENV:-env}"' >> $BASH_ENV # Redirect ENCRYPT_ENV into $BASH_ENV
# openssl aes-256-cbc -e -md sha512 -in ../.env -out .config -k $KEY
- run:
name: Configuring .env
command: cd .circleci && openssl aes-256-cbc -d -md sha512 -in "$ENV_ENC_FILE.enc" -out ../.env -k $ENVKEY
when: always
# CircleCI runs in root, which is 0 for UID & GID. Must do after file unencrypted.
- run:
name: "Export UID and GID to configuration file"
command: |
set -x
echo -e "GID=0\nUID=0\n" >> .env
# SSLs need to be set for Portal container or else "volume name is too short" Docker Portal create error
- run:
name: "Export SSL CERT and SSL KEY paths"
command: |
set -x
SSL_PATH=~/project/packages/portal/backend/ssl
echo -e "HOST_SSL_CERT_PATH=$SSL_PATH/fullchain.pem\nHOST_SSL_KEY_PATH=$SSL_PATH/privkey.pem\n" >> .env
- run:
name: Generate self-signed certs
command: |
set -x
SSL_PATH=~/project/packages/portal/backend/ssl
mkdir -p $SSL_PATH && openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 -keyout $SSL_PATH/privkey.pem -out $SSL_PATH/fullchain.pem -subj "/C=GB/ST=Vancouver/L=Vancouver/O=Global Security/OU=IT Department/CN=test.com"
when: always
- run:
name: Create mount path for MongoDB
command: sudo mkdir -p /var/opt/classy/db
- run:
name: Create paths for artifact collections
command: |
set -x
sudo mkdir -p ${TEST_LOGS}
cd ${TEST_LOGS} && sudo touch portal-front-end-test.log portal-back-end-test.log autotest-test.log docker-stdout.log
sudo chmod 777 -R ${TEST_LOGS}
- run:
name: Build and start container to verify it is working
command: |
set -x
docker-compose up -d 2>&1 | tee -a ${TEST_LOGS}/docker-stdout.log
- run:
name: Shut down containers
command: docker-compose down 2>&1 | tee -a ${TEST_LOGS}/docker-stdout.log
- run:
name: Cleaning up Docker containers and images
command: docker system prune -af 2>&1 | tee -a ${TEST_LOGS}/docker-stdout.log
when: always
- store_artifacts:
path: /home/circleci/project/test-logs
destination: raw-test-output
- run:
name: Cleaning up SSLs and Environment
command: rm .env && rm ~/project/packages/portal/backend/ssl/fullchain.pem && rm ~/project/packages/portal/backend/ssl/privkey.pem
when: always
- run:
name: Cleaning up artifacts
command: |
set -x
sudo rm -rf ${TEST_LOGS}
when: always
workflows:
version: 2
ci_tests:
jobs:
- build
# Uncomment if you want to run the Docker-compose workflow in regular pushes
# - build_run_stop
nightly:
triggers:
- schedule:
# 5am PST time in UTC
cron: "0 12 * * *"
filters:
branches:
only:
- master
jobs:
# Can add any jobs you want to run at 5am here
- build_run_stop