forked from DSpace/dspace-angular
-
Notifications
You must be signed in to change notification settings - Fork 1
337 lines (285 loc) · 12.8 KB
/
deploy.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
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
# DSpace Docker deploy on dataquest servers
name: Deploy DSpace
on:
workflow_call:
inputs:
INSTANCE:
required: false
type: string
default: '6'
IMPORT:
required: false
default: true
type: boolean
ERASE_DB:
required: false
default: false
type: boolean
workflow_dispatch:
inputs:
INSTANCE:
required: true
default: '6'
type: choice
options:
- '*'
- '6'
IMPORT:
required: true
default: true
type: boolean
ERASE_DB:
required: false
default: false
type: boolean
jobs:
deploy-6:
if: inputs.INSTANCE == '*' || inputs.INSTANCE == '6'
runs-on: dspace-dep-1
timeout-minutes: 10
env:
INSTANCE: '6'
ENVFILE: /opt/dspace-envs/.env.dspace.dev-5.tul
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/erase-db
if: inputs.ERASE_DB
with:
INSTANCE: ${{ env.INSTANCE }}
NAME: dspace-${{ env.INSTANCE }}
- name: deploy to dev-5
working-directory: build-scripts/run/
run: |
./start.sh dspace-$INSTANCE
deploy-8:
if: inputs.INSTANCE == '*' || inputs.INSTANCE == '8'
runs-on: dspace-dep-1
timeout-minutes: 180
env:
INSTANCE: '8'
# 2024/02: this .env replaces ENTRYPOINT to angular
# !!!!WARNING!!!!
# disable TSL checks = allowing to cooperate with https backend with invalid
# certificate
ENVFILE: /opt/dspace-envs/.env.dspace.imported.dev-5
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/erase-db
if: inputs.ERASE_DB
with:
INSTANCE: ${{ env.INSTANCE }}
NAME: dspace-${{ env.INSTANCE }}
- name: deploy dspace-import on dev-5
working-directory: build-scripts/run/
run: |
./start.sh dspace-$INSTANCE
cd ../..
# this is not necessary, since extra.yml doesn't contain any new images that weren't pulled within script above
# docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f /opt/dspace-envs/8/extra.yml pull
docker compose --env-file $ENVFILE -p dspace-$INSTANCE -f docker/docker-compose.yml -f docker/docker-compose-rest.yml -f /opt/dspace-envs/8/extra.yml up -d --no-build
# this seems to be the easiest solution for now
docker restart dockerized-nginx-with-shibboleth-nginx-1
/bin/bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' http://dev-5.pc:8$INSTANCE/server/api)" != "200" ]]; do sleep 5; done'
import-8:
runs-on: dspace-dep-1
if: inputs.IMPORT
needs: deploy-8
env:
INSTANCE: '8'
ENVFILE: /opt/dspace-envs/.env.dspace.imported.dev-5
steps:
- uses: ./.github/actions/import-db
with:
INSTANCE: ${{ env.INSTANCE }}
DATADIR: /opt/dspace-data/clarin-dspace/
ASSETSTORE: /opt/dspace-data/clarin-dspace/assetstore/
- name: dspace basic command
run: |
export DNAME=dspace$INSTANCE
docker logs -n 50 $DNAME
echo "dspace version:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace version"
echo "dspace cleanup:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace cleanup -v"
echo "dspace reindex solr:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace index-discovery -b"
echo "dspace reindex OAI-PMH:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace oai import -c"
echo "dspace checker:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace checker -v -l"
- name: dspace healthcheck
run: |
export DNAME=dspace$INSTANCE
echo "dspace healthcheck:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace healthcheck -v"
playwright-after-deploy8:
runs-on: ubuntu-latest
needs: deploy-8
timeout-minutes: 15
if: '!inputs.IMPORT'
steps:
- name: run playwright
run: |
# wait until FE stabilizes a bit
sleep 3m
curl -H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
--request POST \
https://api.github.com/repos/dataquest-dev/\
dspace-ui-tests/actions/workflows/cron-test.yml/dispatches \
--data "{\"ref\":\"refs/heads/master\"}" 2> /dev/null
# wait for it to start
sleep 30s
# get result of last job
RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-ui-tests/actions/workflows/cron-test.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
# while job did not finish, sleep
while [[ $RES == 'null' ]]; do
sleep 10s
RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-ui-tests/actions/workflows/cron-test.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
done;
echo $RES
# if last result is not success, return -1 and fail
if [[ $RES != \"success\" ]]; then
echo "playwright tests have failed! check appropriate action run"
exit 1
fi;
rest-tests-after-deploy8:
runs-on: ubuntu-latest
needs: playwright-after-deploy8
timeout-minutes: 15
steps:
- name: run rest-tests
run: |
curl -H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
--request POST \
https://api.github.com/repos/dataquest-dev/\
dspace-rest-test/actions/workflows/run_unittests.yml/dispatches \
--data "{\"ref\":\"refs/heads/master\"}" 2> /dev/null
# wait for it to start
sleep 30s
# get result of last job
RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-rest-test/actions/workflows/run_unittests.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
# while job did not finish, sleep
while [[ $RES == 'null' ]]; do
sleep 10s
RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-rest-test/actions/workflows/run_unittests.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
done;
echo $RES
# if last result is not success, return -1 and fail
if [[ $RES != \"success\" ]]; then
echo "rest-tests have failed! check appropriate action run"
exit 1
fi;
playwright-after-import8:
runs-on: ubuntu-latest
needs: import-8
if: inputs.IMPORT
timeout-minutes: 15
steps:
- name: run playwright
run: |
# wait until FE stabilizes a bit
sleep 3m
curl -H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
--request POST \
https://api.github.com/repos/dataquest-dev/\
dspace-ui-tests/actions/workflows/cron-test.yml/dispatches \
--data "{\"ref\":\"refs/heads/master\"}" 2> /dev/null
# wait for it to start
sleep 30s
# get result of last job
RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-ui-tests/actions/workflows/cron-test.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
# while job did not finish, sleep
while [[ $RES == 'null' ]]; do
sleep 10s
RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-ui-tests/actions/workflows/cron-test.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
done;
echo $RES
# if last result is not success, return -1 and fail
if [[ $RES != \"success\" ]]; then
echo "playwright tests have failed! check appropriate action run"
exit 1
fi;
rest-tests-after-import8:
runs-on: ubuntu-latest
needs: playwright-after-import8
timeout-minutes: 15
steps:
- name: run rest-tests
run: |
curl -H "Accept: application/vnd.github.everest-preview+json" \
-H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" \
--request POST \
https://api.github.com/repos/dataquest-dev/\
dspace-rest-test/actions/workflows/run_unittests.yml/dispatches \
--data "{\"ref\":\"refs/heads/master\"}" 2> /dev/null
# wait for it to start
sleep 30s
# get result of last job
RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-rest-test/actions/workflows/run_unittests.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
# while job did not finish, sleep
while [[ $RES == 'null' ]]; do
sleep 10s
RES=$(curl -H "Accept: application/vnd.github.everest-preview+json" -H "Authorization: token ${{ secrets.DEPLOY_DEV5_GH_ACTION_DISPATCH }}" https://api.github.com/repos/dataquest-dev/dspace-rest-test/actions/workflows/run_unittests.yml/runs?per_page=1 2> /dev/null | jq .workflow_runs[0].conclusion)
done;
echo $RES
# if last result is not success, return -1 and fail
if [[ $RES != \"success\" ]]; then
echo "rest-tests have failed! check appropriate action run"
exit 1
fi;
import-6:
runs-on: dspace-dep-1
if: inputs.IMPORT && inputs.INSTANCE == '6'
timeout-minutes: 120
needs: deploy-6
env:
INSTANCE: '6'
steps:
- name: vanilla import
env:
FNAME: dspace_tul_dump_2024.10.08.sql
run: |
export DATADIR=/opt/dspace-data/tul-dump/$FNAME
export DNAME=dspace$INSTANCE
export DDBNAME=dspacedb$INSTANCE
echo "====="
docker stop $DNAME || true
echo "====="
# echo Starting vanilla import DB
docker cp $DATADIR $DDBNAME:/tmp/
# drop + create + import + cleanup
docker exec $DDBNAME /bin/bash -c "dropdb -U dspace -p 543$INSTANCE dspace && createdb -U dspace -p 543$INSTANCE --owner=dspace --encoding=UNICODE dspace && psql -p 543$INSTANCE -U dspace -d dspace -f /tmp/$FNAME && rm /tmp/$FNAME"
echo "====="
docker start $DNAME
sleep 60
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace database migrate ignored && ./dspace create-administrator -e [email protected] -f admin -l user -p admin -c en -o dataquest"
echo "====="
# new user will not be accepted unless restarted
docker restart $DNAME
sleep 60
echo "====="
- name: dspace basic command
run: |
export DNAME=dspace$INSTANCE
docker logs -n 50 $DNAME
echo "dspace version:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace version"
echo "dspace cleanup:"
# very likely - https://groups.google.com/g/dspace-tech/c/tsoctFfNUsI/m/IIeYofYADAAJ
# docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace cleanup -v"
echo "dspace reindex solr:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace index-discovery -b"
echo "dspace reindex OAI-PMH:"
docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace oai import -c"
- name: dspace healthcheck
run: |
export DNAME=dspace$INSTANCE
echo "dspace healthcheck:"
# docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace healthcheck -v"
- name: dspace basic command
run: |
echo "dspace checker:"
# docker exec $DNAME /bin/bash -c "cd /dspace/bin && ./dspace checker -v -l"