-
Notifications
You must be signed in to change notification settings - Fork 22
559 lines (490 loc) · 22.9 KB
/
ci-test.yaml
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
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
name: Build and Run Tests
on:
schedule:
- cron: '0 7 * * *' #Runs daily at 7 AM UTC
push:
branches:
- '**'
pull_request:
branches:
- develop
env:
GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
GITHUB_JOB_NAME: ${{ github.job }}
GITHUB_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
AWS_ENDPOINT: ${{ secrets.AWS_ENDPOINT }}
AWS_REGION: eu-west-1
jobs:
media-similarity-tests:
runs-on:
labels: check-web
if: >
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
contains(github.event.head_commit.message, '[full ci]') ||
contains(github.event.head_commit.message, '[media similarity tests]')
steps:
- name: Set permissions for _work directory
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
sudo chmod 755 $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Decrypt credentials for Alegre
env:
DECRYPTION_PASSWORD: ${{ secrets.DECRYPTION_PASSWORD }}
run: |
openssl enc -aes-256-cbc -d -in test/google_credentials.json.enc -out test/google_credentials.json -k $DECRYPTION_PASSWORD
- name: Setup UTF-8 Capable locale
run: |
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
- name: Ngrok
env:
NGROK_AUTH: ${{ secrets.NGROK_AUTH }}
run: |
export GITHUB_TAG=0.0.0
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt-get update && sudo apt-get install ngrok
- name: Setup Pender
run: |
export PENDER_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/pender.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $PENDER_BRANCH for Pender"
git clone --branch=$PENDER_BRANCH https://github.com/meedan/pender.git
cd pender
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cd -
- name: Setup Check API
run: |
export CHECK_API_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/check-api.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $CHECK_API_BRANCH for Check API"
git clone --branch=$CHECK_API_BRANCH https://github.com/meedan/check-api.git
cd check-api
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cd -
- name: Setup Alegre
run: |
export ALEGRE_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/alegre.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $ALEGRE_BRANCH for Alegre"
git clone --branch=$ALEGRE_BRANCH https://github.com/meedan/alegre.git
cd alegre
cp .env_file.test .env_file
cp ../test/google_credentials.json google_credentials.json
cd -
- name: Setup Presto
run: |
export PRESTO_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/presto.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'master')
echo "Using branch $PRESTO_BRANCH for Presto"
git clone --branch=$PRESTO_BRANCH https://github.com/meedan/presto.git
cd presto
cp .env_file.test .env_file
cp ../test/google_credentials.json google_credentials.json
cd -
- name: Setup Configuration Files
run: |
cp config.js.example config.js
cp config.js.example test/config.js
cp config-build.js.example config-build.js
cp config-server.js.example config-server.js
cp test/config.yml.example test/config.yml
- name: Before Script
env:
MAX_WEB_CURL: 3000
WEB_CURL_COUNT: 0
NGROK_AUTH: ${{ secrets.NGROK_AUTH }}
run: |
GITHUB_JOB_NAME=$GITHUB_JOB_NAME GITHUB_BRANCH=$GITHUB_BRANCH ./build.sh
MAX_WEB_CURL=$MAX_WEB_CURL;
WEB_CURL_COUNT=$WEB_CURL_COUNT; until curl --silent -I -f --fail http://localhost:3333 || (("$WEB_CURL_COUNT" == "$MAX_WEB_CURL")); do printf .; sleep 1; WEB_CURL_COUNT=$((++WEB_CURL_COUNT)); done; if [ "$WEB_CURL_COUNT" == "$MAX_WEB_CURL" ]; then echo "Terminating job after $WEB_CURL_COUNT curl attempts to check-web"; exit 1; fi
docker ps
- name: Run linter
run: |
docker compose exec web npm run linter
docker compose exec web npm run test:integration:lint
- name: Run media similarity test
env:
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
run: |
docker ps
docker compose exec web service nginx start
docker compose -f docker-compose.yml -f docker-test.yml exec chromedriver service nginx start
docker compose exec -T \
-e IMGUR_CLIENT_ID=$IMGUR_CLIENT_ID \
-e GITHUB_JOB_NAME=$GITHUB_JOB_NAME \
-e GITHUB_BRANCH=$GITHUB_BRANCH \
-e AWS_ENDPOINT=${{ secrets.AWS_ENDPOINT }} \
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
-e ROLE_TO_ASSUME=${{ secrets.AWS_ROLE_TO_ASSUME }} \
-e AWS_REGION=eu-west-1 \
-e TEST_RETRY_COUNT=3 \
web npm run tests
- name: After media similarity tests
run: |
docker compose exec web bash -c "[ -f test/file.json ] && python -m json.tool test/file.json || echo 'File does not exist'"
size=$(du -k build/web/js/index.bundle.js | cut -f1) && size2=$(du -k build/web/js/vendor.bundle.js | cut -f1) && totalsize=$((size+size2)) && echo "Your bundle size is $totalsize kb"
kill -9 $(pgrep ngrok)
- name: Cleanup Docker Resources
if: always()
run: |
echo "Cleaning up Docker resources..."
docker stop $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q)
text-similarity-tests:
needs: [media-similarity-tests]
runs-on:
labels: check-web
if: >
success() ||
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
contains(github.event.head_commit.message, '[text similarity tests]')
steps:
- name: Set permissions for _work directory
run: |
sudo chown -R $USER:$USER $GITHUB_WORKSPACE
sudo chmod 755 $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Decrypt credentials for Alegre
env:
DECRYPTION_PASSWORD: ${{ secrets.DECRYPTION_PASSWORD }}
run: |
openssl enc -aes-256-cbc -d -in test/google_credentials.json.enc -out test/google_credentials.json -k $DECRYPTION_PASSWORD
- name: Setup UTF-8 Capable locale
run: |
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
- name: Setup Pender
run: |
export PENDER_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/pender.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $PENDER_BRANCH for Pender"
git clone --branch=$PENDER_BRANCH https://github.com/meedan/pender.git
cd pender
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cd -
- name: Setup Check API
run: |
export CHECK_API_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/check-api.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $CHECK_API_BRANCH for Check API"
git clone --branch=$CHECK_API_BRANCH https://github.com/meedan/check-api.git
cd check-api
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cd -
- name: Setup Alegre
run: |
export ALEGRE_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/alegre.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $ALEGRE_BRANCH for Alegre"
git clone --branch=$ALEGRE_BRANCH https://github.com/meedan/alegre.git
cd alegre
cp .env_file.test .env_file
cp ../test/google_credentials.json google_credentials.json
cd -
- name: Setup Presto
run: |
export PRESTO_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/presto.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'master')
echo "Using branch $PRESTO_BRANCH for Presto"
git clone --branch=$PRESTO_BRANCH https://github.com/meedan/presto.git
cd presto
cp .env_file.test .env_file
cp ../test/google_credentials.json google_credentials.json
cd -
- name: Setup Configuration Files
run: |
cp config.js.example config.js
cp config.js.example test/config.js
cp config-build.js.example config-build.js
cp config-server.js.example config-server.js
cp test/config.yml.example test/config.yml
- name: Before Script
env:
MAX_WEB_CURL: 3000
WEB_CURL_COUNT: 0
NGROK_AUTH: ${{ secrets.NGROK_AUTH }}
run: |
GITHUB_JOB_NAME=$GITHUB_JOB_NAME GITHUB_BRANCH=$GITHUB_BRANCH ./build.sh
MAX_WEB_CURL=$MAX_WEB_CURL;
WEB_CURL_COUNT=$WEB_CURL_COUNT; until curl --silent -I -f --fail http://localhost:3333 || (("$WEB_CURL_COUNT" == "$MAX_WEB_CURL")); do printf .; sleep 1; WEB_CURL_COUNT=$((++WEB_CURL_COUNT)); done; if [ "$WEB_CURL_COUNT" == "$MAX_WEB_CURL" ]; then echo "Terminating job after $WEB_CURL_COUNT curl attempts to check-web"; exit 1; fi
docker ps
- name: Run linter
run: |
docker compose exec web npm run linter
docker compose exec web npm run test:integration:lint
- name: Run text similarity test
env:
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
run: |
docker ps
docker compose exec web service nginx start
docker compose -f docker-compose.yml -f docker-test.yml exec chromedriver service nginx start
docker compose exec -T \
-e IMGUR_CLIENT_ID=$IMGUR_CLIENT_ID \
-e GITHUB_JOB_NAME=$GITHUB_JOB_NAME \
-e GITHUB_BRANCH=$GITHUB_BRANCH \
-e AWS_ENDPOINT=${{ secrets.AWS_ENDPOINT }} \
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
-e ROLE_TO_ASSUME=${{ secrets.AWS_ROLE_TO_ASSUME }} \
-e AWS_REGION=eu-west-1 \
-e TEST_RETRY_COUNT=3 \
web npm run tests
- name: After text similarity tests
run: |
docker compose exec web bash -c "[ -f test/file.json ] && python -m json.tool test/file.json || echo 'File does not exist'"
size=$(du -k build/web/js/index.bundle.js | cut -f1) && size2=$(du -k build/web/js/vendor.bundle.js | cut -f1) && totalsize=$((size+size2)) && echo "Your bundle size is $totalsize kb"
- name: Cleanup Docker Resources
if: always()
run: |
echo "Cleaning up Docker resources..."
docker stop $(docker ps -q)
docker rm $(docker ps -aq)
docker rmi $(docker images -q)
docker volume rm $(docker volume ls -q)
integration-and-unit-tests:
runs-on: ubuntu-latest
if: >
github.ref == 'refs/heads/develop' ||
github.ref == 'refs/heads/master' ||
contains(github.event.head_commit.message, '[full ci]') ||
contains(github.event.head_commit.message, '[smoke tests]')
steps:
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Decrypt credentials for Alegre
env:
DECRYPTION_PASSWORD: ${{ secrets.DECRYPTION_PASSWORD }}
run: |
openssl enc -aes-256-cbc -d -in test/google_credentials.json.enc -out test/google_credentials.json -k $DECRYPTION_PASSWORD
- name: Setup UTF-8 Capable locale
run: |
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
- name: Setup Pender
run: |
export PENDER_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/pender.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $PENDER_BRANCH for Pender"
git clone --branch=$PENDER_BRANCH https://github.com/meedan/pender.git
cd pender
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cd -
- name: Setup Check API
run: |
export CHECK_API_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/check-api.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $CHECK_API_BRANCH for Check API"
git clone --branch=$CHECK_API_BRANCH https://github.com/meedan/check-api.git
cd check-api
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cd -
- name: Setup Alegre
run: |
export ALEGRE_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/alegre.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $ALEGRE_BRANCH for Alegre"
git clone --branch=$ALEGRE_BRANCH https://github.com/meedan/alegre.git
cd alegre
cp .env_file.test .env_file
cp ../test/google_credentials.json google_credentials.json
cd -
- name: Setup Presto
run: |
export PRESTO_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/presto.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'master')
echo "Using branch $PRESTO_BRANCH for Presto"
git clone --branch=$PRESTO_BRANCH https://github.com/meedan/presto.git
cd presto
cp .env_file.test .env_file
cp ../test/google_credentials.json google_credentials.json
cd -
- name: Setup Configuration Files
run: |
cp config.js.example config.js
cp config.js.example test/config.js
cp config-build.js.example config-build.js
cp config-server.js.example config-server.js
cp test/config.yml.example test/config.yml
- name: Before Script
env:
MAX_WEB_CURL: 3000
WEB_CURL_COUNT: 0
run: |
GITHUB_JOB_NAME=$GITHUB_JOB_NAME GITHUB_BRANCH=$GITHUB_BRANCH ./build.sh
MAX_WEB_CURL=$MAX_WEB_CURL;
WEB_CURL_COUNT=$WEB_CURL_COUNT; until curl --silent -I -f --fail http://localhost:3333 || (("$WEB_CURL_COUNT" == "$MAX_WEB_CURL")); do printf .; sleep 1; WEB_CURL_COUNT=$((++WEB_CURL_COUNT)); done; if [ "$WEB_CURL_COUNT" == "$MAX_WEB_CURL" ]; then echo "Terminating job after $WEB_CURL_COUNT curl attempts to check-web"; exit 1; fi
docker ps
- name: Run linter
run: |
docker compose exec web npm run linter
docker compose exec web npm run test:integration:lint
- name: Run Integration test
env:
IMGUR_CLIENT_ID: ${{ secrets.IMGUR_CLIENT_ID }}
run: |
docker ps
docker compose exec web service nginx start
docker compose -f docker-compose.yml -f docker-test.yml exec chromedriver service nginx start
docker compose exec -T \
-e IMGUR_CLIENT_ID=$IMGUR_CLIENT_ID \
-e GITHUB_JOB_NAME=$GITHUB_JOB_NAME \
-e GITHUB_BRANCH=$GITHUB_BRANCH \
-e AWS_ENDPOINT=${{ secrets.AWS_ENDPOINT }} \
-e AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} \
-e AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} \
-e ROLE_TO_ASSUME=${{ secrets.AWS_ROLE_TO_ASSUME }} \
-e AWS_REGION=eu-west-1 \
-e TEST_RETRY_COUNT=3 \
web npm run tests
- name: After integration tests
run: |
docker compose exec web bash -c "[ -f test/file.json ] && python -m json.tool test/file.json || echo 'File does not exist'"
size=$(du -k build/web/js/index.bundle.js | cut -f1) && size2=$(du -k build/web/js/vendor.bundle.js | cut -f1) && totalsize=$((size+size2)) && echo "Your bundle size is $totalsize kb"
unit-tests:
runs-on: ubuntu-latest
if: >
github.ref != 'refs/heads/develop' &&
github.ref != 'refs/heads/master' &&
!contains(github.event.head_commit.message, '[full ci]') &&
!contains(github.event.head_commit.message, '[smoke tests]') &&
!contains(github.event.head_commit.message, '[media similarity tests]') &&
!contains(github.event.head_commit.message, '[text similarity tests]')
steps:
- uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
aws-region: eu-west-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Decrypt credentials for Alegre
env:
DECRYPTION_PASSWORD: ${{ secrets.DECRYPTION_PASSWORD }}
run: |
openssl enc -aes-256-cbc -d -in test/google_credentials.json.enc -out test/google_credentials.json -k $DECRYPTION_PASSWORD
- name: Setup UTF-8 Capable locale
run: |
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export LANGUAGE=C.UTF-8
- name: Setup Pender
env:
GITHUB_BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
export PENDER_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/pender.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $PENDER_BRANCH for Pender"
git clone --branch=$PENDER_BRANCH https://github.com/meedan/pender.git
cd pender
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cd -
- name: Setup Check API
run: |
export CHECK_API_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/check-api.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $CHECK_API_BRANCH for Check API"
git clone --branch=$CHECK_API_BRANCH https://github.com/meedan/check-api.git
cd check-api
cp config/config.yml.example config/config.yml
cp config/database.yml.example config/database.yml
cp config/sidekiq.yml.example config/sidekiq.yml
cd -
- name: Setup Alegre
run: |
export ALEGRE_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/alegre.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'develop')
echo "Using branch $ALEGRE_BRANCH for Alegre"
git clone --branch=$ALEGRE_BRANCH https://github.com/meedan/alegre.git
cd alegre
cp .env_file.test .env_file
cp ../test/google_credentials.json google_credentials.json
cd -
- name: Setup Presto
run: |
export PRESTO_BRANCH=$((git ls-remote --exit-code --heads https://github.com/meedan/presto.git $GITHUB_BRANCH >/dev/null && echo $GITHUB_BRANCH) || echo 'master')
echo "Using branch $PRESTO_BRANCH for Presto"
git clone --branch=$PRESTO_BRANCH https://github.com/meedan/presto.git
cd presto
cp .env_file.test .env_file
cp ../test/google_credentials.json google_credentials.json
cd -
- name: Setup Configuration Files
run: |
cp config.js.example config.js
cp config.js.example test/config.js
cp config-build.js.example config-build.js
cp config-server.js.example config-server.js
cp test/config.yml.example test/config.yml
- name: Before Script
env:
MAX_WEB_CURL: 3000
WEB_CURL_COUNT: 0
run: |
gitHUB_JOB_NAME=$GITHUB_JOB_NAME GITHUB_BRANCH=$GITHUB_BRANCH ./build.sh
MAX_WEB_CURL=$MAX_WEB_CURL;
WEB_CURL_COUNT=$WEB_CURL_COUNT; until curl --silent -I -f --fail http://localhost:3333 || (("$WEB_CURL_COUNT" == "$MAX_WEB_CURL")); do printf .; sleep 1; WEB_CURL_COUNT=$((++WEB_CURL_COUNT)); done; if [ "$WEB_CURL_COUNT" == "$MAX_WEB_CURL" ]; then echo "Terminating job after $WEB_CURL_COUNT curl attempts to check-web"; exit 1; fi
docker ps
- name: Run linter
run: |
docker compose exec web npm run linter
docker compose exec web npm run test:integration:lint
- name: Run Unit Tests
run: |
docker compose exec -T -e GITHUB_JOB_NAME=$GITHUB_JOB_NAME web npm run tests