-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
229 lines (209 loc) · 7.73 KB
/
.gitlab-ci.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
variables:
FF_NETWORK_PER_BUILD: 1
CI_DEBUG_SERVICES: 1
.job_template:
&job_configuration # Hidden yaml configuration that defines an anchor named 'job_configuration'
services:
- name: ${CI_REGISTRY_IMAGE}/saml
alias: saml idp.localhost.edu
variables:
SIMPLESAMLPHP_SP_ENTITY_ID: saml-poc
SIMPLESAMLPHP_SP_ASSERTION_CONSUMER_SERVICE: https://api.localhost.edu/login
SIMPLESAMLPHP_SP_SINGLE_LOGOUT_SERVICE: https://api.localhost.edu/logout
- name: ${CI_REGISTRY_IMAGE}/frontend
alias: frontend
- name: ${CI_REGISTRY_IMAGE}/websocket
alias: socket
entrypoint:
- '/bin/bash'
- '-c'
- |
sleep 80;
node main.js;
- name: ${CI_REGISTRY_IMAGE}/database
alias: mongo
- name: ${CI_REGISTRY_IMAGE}/database
alias: mongo-jr
- name: ${CI_REGISTRY_IMAGE}/database
alias: mongo-the-third
- name: mongo:latest
entrypoint:
- '/bin/bash'
- '-c'
- |
mongosh --host mongo:27017 --eval 'rs.initiate({"_id" : "rs0","members" : [{"_id" : 0,"host" : "mongo:27017","priority": 5},{"_id" : 1,"host" : "mongo-jr:27017","priority": 1},{"_id" : 2,"host" : "mongo-the-third:27017","priority": 1}]});';
while [ $? -ne 0 ]; do sleep 2 && mongosh --host mongo:27017 --eval 'rs.initiate({"_id" : "rs0","members" : [{"_id" : 0,"host" : "mongo:27017","priority": 5},{"_id" : 1,"host" : "mongo-jr:27017","priority": 1},{"_id" : 2,"host" : "mongo-the-third:27017","priority": 1}]});'; done;
- name: ${CI_REGISTRY_IMAGE}/backend
alias: backend
command:
- '/bin/bash'
- '-c'
- |
sleep 80;
node main.js;
- name: bitnami/openldap:2
alias: openldap
variables:
LDAP_ADMIN_USERNAME: admin
LDAP_ADMIN_PASSWORD: adminpassword
LDAP_USERS: netid1,netid2,netid3,netid4,netid5,netid6
LDAP_PASSWORDS: rutgers1,rutgers2,rutgers3,rutgers4,rutgers5,rutgers6
- name: ${CI_REGISTRY_IMAGE}/proxy
alias: nginx localhost.edu api.localhost.edu ldap.localhost.edu
stages:
- build
- pre-test
- test
backend-api:
<<: *job_configuration
stage: test
image:
name: ${CI_REGISTRY_IMAGE}/test-suite
entrypoint: ['']
before_script:
- |
mongosh --host mongo:27017 --eval 'rs.initiate({"_id" : "rs0","members" : [{"_id" : 0,"host" : "mongo:27017","priority": 5},{"_id" : 1,"host" : "mongo-jr:27017","priority": 1},{"_id" : 2,"host" : "mongo-the-third:27017","priority": 1}]});'
- echo "past"
- bash -c 'curl backend:8000; while [ $? -ne 0 ]; do sleep 1 && echo "waiting for backend to start" && curl -s http://backend:8000; done;'
script:
- apt-get install bc -y
- cd
- ls
- /bin/bash /root/docker-entrypoint.sh --formatter junit
- cp -r /root/test_output ${CI_PROJECT_DIR}/test_output
- touch ${CI_PROJECT_DIR}/merged.xml
- for i in $(ls ${CI_PROJECT_DIR}/test_output); do cat ${CI_PROJECT_DIR}/test_output/$i >> ${CI_PROJECT_DIR}/merged.xml; done;
- TOTAL_TIME=$(cat ${CI_PROJECT_DIR}/merged.xml | grep -E '<testsuites time="[0-9]+\.[0-9]+">' | grep -Eo '[0-9]+\.[0-9]+' | paste -sd+ | bc )
- sed -i 's/^<?xml version="1.0" encoding="UTF-8"?>$//g;s/<testsuites time="[0-9]\+\.[0-9]\+">//g;s/<\/testsuites>//g;/^$/d' ${CI_PROJECT_DIR}/merged.xml
- sed -i "1s/^/<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testsuites time=\"$TOTAL_TIME\">\n/" ${CI_PROJECT_DIR}/merged.xml
- echo "</testsuites>" >> ${CI_PROJECT_DIR}/merged.xml
artifacts:
when: always
paths:
- ${CI_PROJECT_DIR}/test_output/*.xml
- ${CI_PROJECT_DIR}/merged.xml
reports:
junit: ${CI_PROJECT_DIR}/merged.xml
frontend-lint:
image:
name: ${CI_REGISTRY_IMAGE}/frontend-lint
entrypoint: ['']
script:
- npm install eslint eslint-plugin-react @babel/core @babel/eslint-parser
- npx eslint -c "${CI_PROJECT_DIR}/testing/frontend/linter/eslint.config.cjs" --color --format junit "${CI_PROJECT_DIR}/frontend/**/*.{jsx,js}" > ${CI_PROJECT_DIR}/linter_results.xml
artifacts:
when: always
paths:
- ${CI_PROJECT_DIR}/linter_results.xml
reports:
junit: ${CI_PROJECT_DIR}/linter_results.xml
dependencies:
- build-frontend
- build-eslint
build-backend:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
stage: build
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/backend"
--dockerfile "${CI_PROJECT_DIR}/backend/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/backend:${CI_COMMIT_TAG}"
--build-arg=GIT_BRANCH="${CI_COMMIT_BRANCH}"
--build-arg=GIT_HASH="${CI_COMMIT_SHA}"
--build-arg=DEV="true"
--build-arg=LOGIN_URL="https://idp.localhost.edu/idp/profile/SAML2/Redirect/SSO"
build-frontend:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
stage: build
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/frontend"
--dockerfile "${CI_PROJECT_DIR}/frontend/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/frontend:${CI_COMMIT_TAG}"
--build-arg=BUILD="dev"
build-nginx:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
stage: build
script:
- rm ${CI_PROJECT_DIR}/proxy/nginx/conf.d/graphana.conf
- rm ${CI_PROJECT_DIR}/proxy/nginx/conf.d/prom.conf
- /kaniko/executor
--context "${CI_PROJECT_DIR}/proxy"
--dockerfile "${CI_PROJECT_DIR}/proxy/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/proxy:${CI_COMMIT_TAG}"
build-mongo:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
stage: build
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/database"
--dockerfile "${CI_PROJECT_DIR}/database/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/database:${CI_COMMIT_TAG}"
build-docker-proxy:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
stage: build
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/proxy-docker"
--dockerfile "${CI_PROJECT_DIR}/proxy-docker/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/proxy-docker:${CI_COMMIT_TAG}"
build-websocket:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
stage: build
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/websocket"
--dockerfile "${CI_PROJECT_DIR}/websocket/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/websocket:${CI_COMMIT_TAG}"
build-saml:
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
stage: build
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/shib-idp"
--dockerfile "${CI_PROJECT_DIR}/shib-idp/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/saml:${CI_COMMIT_TAG}"
build-test:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/testing/backend-testing"
--dockerfile "${CI_PROJECT_DIR}/testing/backend-testing/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/test-suite:${CI_COMMIT_TAG}"
build-eslint:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/testing/frontend/linter"
--dockerfile "${CI_PROJECT_DIR}/testing/frontend/linter/Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/frontend-lint:${CI_COMMIT_TAG}"
build-puppeteer:
stage: build
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: ['']
script:
- /kaniko/executor
--context "dir://${CI_PROJECT_DIR}/testing/puppeteer"
--dockerfile "Dockerfile"
--destination "${CI_REGISTRY_IMAGE}/puppeteer:${CI_COMMIT_TAG}"