This repository was archived by the owner on Jun 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
250 lines (221 loc) · 7.17 KB
/
.gitlab-ci.yml
File metadata and controls
250 lines (221 loc) · 7.17 KB
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
# This file is a template, and might need editing before it works on your project.
# Official framework image. Look for the different tagged releases at:
# https://hub.docker.com/r/library/node/tags/
image: registry.incode.ca/se3352a/requirements-assignment-2:latest
# Pick zero or more services to be used on all builds.
# Only needed when using a docker container to run your tests in.
# Check out: http://docs.gitlab.com/ce/ci/docker/using_docker_images.html#what-is-service
# Ensure that the back passes its tests first since the front relies on the back
stages:
- test
- build
- deploy
# Code common to the front- and back-end tests
.test_common: &test_common
stage: test
coverage: /Lines\s*:\s*(\d*\.?\d+)%/
# This folder is cached between builds
# http://docs.gitlab.com/ce/ci/yaml/README.html#cache
variables:
NODE_ENV: 'test'
MONGO_DB_HOST: "mongo"
NODE_TLS_REJECT_UNAUTHORIZED: "0" # To support mongodb being installed by a proxy
cache:
untracked: true
paths:
- BackEnd/studentsRecords/node_modules/
- FrontEnd/studentsRecords/node_modules/
- FrontEnd/studentsRecords/bower_components/
services:
- mongo:latest
before_script:
- 'echo "{ \"allow_root\": true }" > /root/.bowerrc'
- mongorestore -h $MONGO_DB_HOST -d studentsRecords mongo-seed/studentsRecords/ # Restore the mongodb database
- npm config set proxy http://gitlab-ci.isolation.ad.murrayweb.ca:8080/ # Setup proxy to stop killing bandwidth
- npm config set https-proxy http://gitlab-ci.isolation.ad.murrayweb.ca:8080/
- npm config set strict-ssl false
except:
- temp
- tags
#################################
# #
# TESTS #
# #
#################################
# This test ensures the back end works
test_backend:
<<: *test_common
artifacts:
expire_in: 2 weeks
paths:
- BackEnd/studentsRecords/coverage/
script:
- cd BackEnd/studentsRecords
- npm install
- npm run lint || true # Prevents JSHint errors from stopping build
- npm run coverage
# This test ensures the front end works
test_frontend:
<<: *test_common
artifacts:
expire_in: 2 weeks
paths:
- FrontEnd/studentsRecords/coverage/
script:
- pushd .
- cd BackEnd/studentsRecords
- npm install
- node server.js &
- popd
- cd FrontEnd/studentsRecords
- npm install
- bower install
- npm run coverage
after_script:
- pkill node
allow_failure: true
#################################
# #
# BUILD #
# #
#################################
# Common components to build jobs
.build_common: &build_common
stage: build
dependencies: []
variables:
NODE_TLS_REJECT_UNAUTHORIZED: "0" # To support the proxy
before_script:
- 'echo "{ \"allow_root\": true }" > /root/.bowerrc'
# - npm config set proxy http://gitlab-ci.isolation.ad.murrayweb.ca:8080/ # Setup proxy to stop killing bandwidth
# - npm config set https-proxy http://gitlab-ci.isolation.ad.murrayweb.ca:8080/
# - npm config set strict-ssl false
# This job sets up the back, builds the front, copies the built front to the back, and saves it all for the review app
# This blocks to save the server from overload!
build_review:
<<: *build_common
when: manual
allow_failure: false
artifacts:
expire_in: 1 day
paths:
- BackEnd/studentsRecords/
except:
- master
- tags
script:
- pushd .
- cd BackEnd/studentsRecords
- npm install --production
- popd
- cd FrontEnd/studentsRecords
- npm install # Don't worry about production flag
- bower install
- HOST=$CI_COMMIT_REF_SLUG.digitalpanda.incode.ca ember build --environment production
- cp -r dist/ ../../BackEnd/studentsRecords/dist/
# This job sets up the back, builds the front, copies the built front to the back, and saves it all for deployment
build:
<<: *build_common
artifacts:
expire_in: 2 weeks
paths:
- BackEnd/studentsRecords/
only:
- master
script:
- pushd .
- cd BackEnd/studentsRecords
- npm install --production
- popd
- cd FrontEnd/studentsRecords
- npm install # Don't worry about production flag
- bower install
- HOST=digitalpanda.incode.ca ember build --environment production
- cp -r dist/ ../../BackEnd/studentsRecords/dist/
#################################
# #
# DEPLOY #
# #
#################################
# Common components to deploy jobs
.deploy_common: &deploy_common
stage: deploy
image: registry.incode.ca/se3352a/requirements-assignment-2:compose
# This job takes the contents from the previous job, builds them into a docker image, then deploys everything
production:
<<: *deploy_common
variables:
DOCKER_HOST: tcp://pandadocker.isolation.ad.murrayweb.ca:2375
VIRTUAL_HOST: digitalpanda.incode.ca
dependencies:
- build
before_script:
- mkdir ~/.docker
- echo $PANDADOCKER_AUTH > ~/.docker/config.json
script:
- docker-compose -H $DOCKER_HOST down --volumes # Destroy the old image
- docker-compose -H $DOCKER_HOST up -d --build --force-recreate
after_script:
- rm -f ~/.docker/config.json
environment:
name: production
url: http://digitalpanda.incode.ca/
on_stop: shutdown
only:
- master
# This job stops the deployment containers
shutdown:
<<: *deploy_common
dependencies: []
variables:
DOCKER_HOST: tcp://pandadocker.isolation.ad.murrayweb.ca:2375
GIT_STRATEGY: None
when: manual
script:
- docker-compose -H $DOCKER_HOST down --volumes # Destroy the old image
environment:
name: production
url: http://digitalpanda.incode.ca/
action: stop
only:
- master
# This job takes the contents from the previous job, builds them into a docker image, then deploys everything
deploy_review:
<<: *deploy_common
variables:
DOCKER_HOST: tcp://pandadocker.isolation.ad.murrayweb.ca:2375
VIRTUAL_HOST: $CI_COMMIT_REF_SLUG.digitalpanda.incode.ca
dependencies:
- build_review
before_script:
- mkdir ~/.docker
- echo $PANDADOCKER_AUTH > ~/.docker/config.json
script:
- docker-compose -p $CI_COMMIT_REF_SLUG -H $DOCKER_HOST down --volumes # Destroy the old image
- docker-compose -p $CI_COMMIT_REF_SLUG -H $DOCKER_HOST up -d --build --force-recreate
after_script:
- rm -f ~/.docker/config.json
environment:
name: review/$CI_COMMIT_REF_NAME
url: http://$CI_COMMIT_REF_SLUG.digitalpanda.incode.ca/
on_stop: shutdown_review
except:
- master
- tags
# This job stops the deployment containers
shutdown_review:
<<: *deploy_common
dependencies: []
variables:
DOCKER_HOST: tcp://pandadocker.isolation.ad.murrayweb.ca:2375
GIT_STRATEGY: None
when: manual
script:
- docker-compose -p $CI_COMMIT_REF_SLUG -H $DOCKER_HOST down --volumes # Destroy the old image
environment:
name: review/$CI_COMMIT_REF_NAME
url: http://$CI_COMMIT_REF_SLUG.digitalpanda.incode.ca/
action: stop
except:
- master
- tags