-
-
Notifications
You must be signed in to change notification settings - Fork 151
573 lines (496 loc) · 17.2 KB
/
main.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
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
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
paths-ignore:
- '.circleci'
branches-ignore:
# Run only renovate PR
- 'renovate/*'
pull_request:
branches:
- '*'
paths-ignore:
- '.circleci'
types: [opened, reopened, synchronize]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
env:
PGDB: lsmb_test
PGHOST: localhost
PGPASSWORD: test
PGPORT: 5432
PGUSER: postgres
JOB_COUNT: 5
TEST2_UUID_NO_WARN: 1
DEVEL_COVER_OPTIONS: -silent,1,+ignore,^/home/,+ignore,^x?t,+ignore,UI/tests,+ignore,^utils,+ignore,local/,+ignore,^/usr/,+ignore,^/opt/,+ignore,\\.lttc,+ignore,starman\\b,-summary,1
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
cancel-prior:
if: github.repository != 'ledgersmb/LedgerSMB' || startsWith(github.ref, 'refs/pull')
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
webpack:
if: github.event.action != 'closed' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
# Dump environment variables & event
- uses: hmarr/debug-action@v3
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
# Keep aligned with what's in the dev image...
node-version: '20'
- name: Cache Dojo
id: cache-dojo
uses: actions/cache@v4
with:
path: UI/js
key: dojo-${{ hashFiles('UI/js-src/**',
'UI/src/**',
'UI/css/**',
'UI/*.html',
'UI/**/*.html',
'doc/sources/**') }}
- name: Cache node_module
id: cache-node_modules
uses: actions/cache@v4
with:
path: |
UI/node_modules
key: |
modules-${{ hashFiles('UI/yarn.lock') }}
- name: Build Dojo
run: |
make js_deps_install
make lint
make js
make readme
if: steps.cache-dojo.outputs.cache-hit != 'true' ||
steps.cache-node_modules.outputs.cache-hit != 'true'
# Prep-up the cache
build-perl-env:
runs-on: ubuntu-latest
strategy:
matrix:
perl: [ "5.40", "5.34", "5.32" ]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Perl environment & start starman
uses: ./.github/workflows/Install TEX & Perl
with:
perl-version: ${{ matrix.perl }}
test-pure-perl:
runs-on: ubuntu-latest
needs: build-perl-env
strategy:
matrix:
include:
- perl: "5.34"
JOB_COUNT: 5
COVERAGE: 1
- perl: "5.32"
JOB_COUNT: 5
- perl: "5.40"
JOB_COUNT: 5
env:
RELEASE_TESTING: 1
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Perl environment & start starman
uses: ./.github/workflows/Install TEX & Perl
with:
perl-version: ${{ matrix.perl }}
DEVEL_COVER_OPTIONS: ${{ env.DEVEL_COVER_OPTIONS }}
coverage: ${{ matrix.COVERAGE }}
# Do perl tests
- name: Run Pure Perl tests
run: |
make test TESTS="--no-progress --job-count $JOB_COUNT $YATH_DEVEL_COVER_OPTIONS t/ xt/[0-3]*"
env:
COVERAGE: ${{ matrix.COVERAGE }}
LSMB_TEST_DB: 1
DB_TESTING: 1
JOB_COUNT: ${{ matrix.JOB_COUNT }}
# Upload coverage data if needed
- name: Upload coverage data
run: |
unset PERL5OPT
cover -report coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: pure-perl
COVERALLS_PARALLEL: true
if: ${{ matrix.COVERAGE }}
test-database:
runs-on: ubuntu-latest
needs: build-perl-env
strategy:
matrix:
include:
- postgres: "15"
perl: "5.34"
JOB_COUNT: 5
services:
# Label used to access the service container
postgres:
# Docker database image
image: ghcr.io/ledgersmb/dev-postgres:${{ matrix.postgres }}
# Maps tcp port 5432 on service container to the host
ports:
- 5432:5432
# Provide the password for postgres
env:
POSTGRES_PASSWORD: test
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Perl environment
uses: ./.github/workflows/Install TEX & Perl
with:
perl-version: ${{ matrix.perl }}
# Do database tests
- name: Run pgTAP database tests
run: |
make devtest TESTS="--no-progress --job-count $JOB_COUNT xt/42-*.pg"
env:
LSMB_TEST_DB: 1
DB_TESTING: 1
JOB_COUNT: ${{ matrix.JOB_COUNT }}
test-webservices:
runs-on: ubuntu-latest
# needs webpack because of collectively managed node modules cache
needs: [ build-perl-env, webpack ]
strategy:
matrix:
include:
- postgres: "15"
perl: "5.34"
JOB_COUNT: 5
COVERAGE: 1
env:
LSMB_BASE_URL: http://lsmb:5000
PSGI_BASE_URL: http://lsmb:5762
REMOTE_SERVER_ADDRESS: 127.0.0.1
services:
# Label used to access the service container
postgres:
# Docker database image
image: ghcr.io/ledgersmb/dev-postgres:${{ matrix.postgres }}
# Maps tcp port 5432 on service container to the host
ports:
- 5432:5432
# Provide the password for postgres
env:
POSTGRES_PASSWORD: test
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pre-run installation steps
run: |
# Set host alias
hostname -i | awk '{printf("%s lsmb\n",$1)}' | sudo tee -a /etc/hosts
# Set the correct LedgerSMB Server configuration
cp doc/conf/ledgersmb.conf.default ledgersmb.conf
sed -i -e 's/db_namespace = public/db_namespace = xyz/ ; s/#suppress_tooltips/suppress_tooltips/' ledgersmb.conf
# Start 'nginx' reverse proxy
mkdir logs
nginx -c $GITHUB_WORKSPACE/doc/conf/webserver/nginx-github.conf \
-p $GITHUB_WORKSPACE &
- name: Cache node_modules
id: cache-npm
uses: actions/cache@v4
with:
path: |
UI/node_modules
key: |
modules-${{ hashFiles('UI/yarn.lock') }}
- name: Setup Perl environment & start starman
uses: ./.github/workflows/Install TEX & Perl
with:
perl-version: ${{ matrix.perl }}
DEVEL_COVER_OPTIONS: ${{ env.DEVEL_COVER_OPTIONS }}
coverage: ${{ matrix.COVERAGE }}
- name: Run API tests
run: |
PERL5LIB="lib:old/lib:$PERL5LIB" make jstest TESTS="$JSCOVERAGE"
- name: Stop 'starman'
run: |
if [[ ! -e starman.pid ]]
then
echo "ERROR: Can't terminate Starman without PID file"
else
pid=$(cat starman.pid)
kill -quit $pid
echo "Waiting for Starman to terminate "
while kill -0 $pid >/dev/null 2>&1
do
echo -n "."
sleep 1
done
echo " "
fi
# Make Coverage appear from root instead of UI to integrate in Coveralls
- name: Fix UI Coverage report
run: |
if [[ -e UI/coverage/lcov.info ]]
then
sed -i -E "s~^SF:(js-src|src)/~SF:UI/\1/~g" UI/coverage/lcov.info
fi
if: ${{ matrix.COVERAGE }}
# Send UI coverage before Perl
- name: Upload UI coverage data
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: webservices-ui
parallel: true
file: ${{ github.workspace }}/UI/coverage/lcov.info
if: ${{ matrix.COVERAGE }}
# Upload coverage data if needed
- name: Upload coverage data
run: |
unset PERL5OPT
cover -report coveralls
cover -report text > logs/coverage.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: webservices-perl
COVERALLS_PARALLEL: true
if: ${{ matrix.COVERAGE }}
test-remainder:
if: (github.event.action != 'closed' || github.event.pull_request.merged == true)
runs-on: ubuntu-latest
needs: [ webpack, build-perl-env ]
timeout-minutes: 60
# Service containers to run
strategy:
fail-fast: false
matrix:
include:
- perl: "5.34"
postgres: "14"
BROWSER: "chrome"
COVERAGE: 1
JOB_COUNT: 3
- perl: "5.32"
postgres: "15"
BROWSER: "firefox"
COA_TESTING: 1
JOB_COUNT: 7
- perl: "5.40"
postgres: "13"
BROWSER: "operablink"
DB_TESTING: 1
JOB_COUNT: 7
services:
# Label used to access the service container
postgres:
# Docker database image
image: ghcr.io/ledgersmb/dev-postgres:${{ matrix.postgres }}
# Maps tcp port 5432 on service container to the host
ports:
- 5432:5432
# Provide the password for postgres
env:
POSTGRES_PASSWORD: test
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
mailhog:
image: mailhog/mailhog:latest
ports:
- 1025:1025
- 8025:8025
env:
BROWSER: ${{ matrix.BROWSER }}
COA_TESTING: ${{ matrix.COA_TESTING }}
DB_TESTING: ${{ matrix.DB_TESTING }}
JOB_COUNT: ${{ matrix.JOB_COUNT }}
LSMB_BASE_URL: http://lsmb:5000
LSMB_NEW_DB: lsmb_test
LSMB_NEW_DB_API: lsmb_test_api
MONITOR_FILE: cpu-memory-usage
PSGI_BASE_URL: http://lsmb:5762
RELEASE_TESTING: 1
REMOTE_SERVER_ADDR: 127.0.0.1
SSMTP_FROMLINE_OVERRIDE: YES
SSMTP_HOSTNAME: lsmb
SSMTP_MAILHUB: lsmb:1025
MH_SENDMAIL_SMTP_ADDR: lsmb:1025
UIUSER: Jest
UIPASSWORD: Tester
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Pre-run installation steps
run: |
# Set host alias
hostname -i | awk '{printf("%s lsmb\n",$1)}' | sudo tee -a /etc/hosts
# Set up 'sendmail'
wget --quiet https://github.com/mailhog/mhsendmail/releases/download/v0.2.0/mhsendmail_linux_amd64
sudo chmod +x mhsendmail_linux_amd64
sudo mv mhsendmail_linux_amd64 /usr/local/bin/sendmail
echo -e "To: you@lsmb\n" \
"Subject: sendmail test\n" \
"From: me@lsmb\n" "\n" \
"And here goes the e-mail body, test test test..\n" | \
sendmail me@test
curl lsmb:8025/api/v2/messages
# Create logging directories
mkdir -p logs/screens
# Set the correct LedgerSMB Server configuration
cp doc/conf/ledgersmb.conf.default ledgersmb.conf
sed -i -e 's/db_namespace = public/db_namespace = xyz/' ledgersmb.conf
# Start 'nginx' reverse proxy
nginx -c $GITHUB_WORKSPACE/doc/conf/webserver/nginx-github.conf \
-p $GITHUB_WORKSPACE &
- name: Cache Dojo
id: cache-dojo
uses: actions/cache@v4
with:
path: UI/js
key: dojo-${{ hashFiles('UI/js-src/**',
'UI/src/**',
'UI/css/**',
'UI/*.html',
'UI/**/*.html',
'doc/sources/**') }}
- name: Cache node_modules
id: cache-npm
uses: actions/cache@v4
with:
path: |
UI/node_modules
key: |
modules-${{ hashFiles('UI/yarn.lock') }}
# This will start a hub and JOB_COUNT matrix.
- name: Starting hub with ${{ matrix.BROWSER }}
run: |
docker compose \
--file=utils/selenium/docker-compose.yml \
--file=utils/selenium/docker-compose-${{ matrix.BROWSER }}.yml \
up \
--detach \
--scale ${{ matrix.BROWSER }}=$JOB_COUNT \
- name: Setup Perl environment & start starman
uses: ./.github/workflows/Install TEX & Perl
with:
perl-version: ${{ matrix.perl }}
DEVEL_COVER_OPTIONS: ${{ env.DEVEL_COVER_OPTIONS }}
coverage: ${{ matrix.COVERAGE }}
# Fix the condition to debug
- name: Setup upterm session
uses: mxschmitt/action-tmate@v3
if: ${{ matrix.BROWSER == 'chrome' && 0 }}
# Do perl tests
- name: Run Perl + Database + Browser tests
run: |
make devtest TESTS="--no-progress --job-count $JOB_COUNT $YATH_DEVEL_COVER_OPTIONS xt/4{[01],[3-9]}* xt/[5-9]*"
env:
LSMB_TEST_DB: 1
COA_TESTING: ${{ matrix.COA_TESTING }}
COVERAGE: ${{ matrix.COVERAGE }}
DB_TESTING: ${{ matrix.DB_TESTING }}
- name: Stop 'starman'
run: |
if [[ ! -e starman.pid ]]
then
echo "ERROR: Can't terminate Starman without PID file"
else
pid=$(cat starman.pid)
kill -quit $pid
echo "Waiting for Starman to terminate "
while kill -0 $pid >/dev/null 2>&1
do
echo -n "."
sleep 1
done
echo " "
fi
# Upload coverage data if needed
- name: Upload coverage data
run: |
unset PERL5OPT
cover -report coveralls
cover -report text > logs/coverage.txt
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_FLAG_NAME: remainder-perl
COVERALLS_PARALLEL: true
if: ${{ matrix.COVERAGE }}
# Send logs & artifacts
- name: Collect docker logs
uses: jwalton/gh-docker-logs@v2
with:
dest: 'logs/docker-logs'
if: always()
- name: Archive production artifacts
uses: actions/upload-artifact@v4
with:
name: logs-and-screens ${{ matrix.perl }} ${{ matrix.BROWSER }}
path: |
logs/**
/tmp/nginx*.log
if: always()
close-parallel-coverage:
runs-on: ubuntu-latest
needs: [ test-pure-perl, test-remainder, test-webservices ]
steps:
- name: Close parallel UI coverage data
uses: coverallsapp/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
parallel-finished: true
# Run the build hook again (Coveralls suggested patch)
- name: Rerun Build Webhook
run: |
curl --location --request GET "https://coveralls.io/rerun_build?repo_token=${{ secrets.GITHUB_TOKEN }}&build_num=${GITHUB_RUN_ID}"
testing-done:
runs-on: ubuntu-latest
needs: [ test-database, test-pure-perl, test-remainder, test-webservices ]
if: failure()
# This job gets skipped on successful completion of the dependent jobs
# Skipped jobs are interpreted as 'success' condition in branch protection rules...
steps:
- name: Failed
run: |
exit 1
build-dev:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: test-remainder
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check if merge must trigger
id: pr_trigger
shell: bash
run: |
URL="https://api.github.com/repos/${{ github.repository }}/commits/${{ github.sha }}"
if [$(curl -s -X GET -G $URL | jq -r '.files[].filename' | grep -q "cpanfile")]; then
echo ::set-output name=MUST_TRIGGER::1
fi
- name: Repository Dispatch to the Development image
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.DOCKER_TOKEN }}
repository: ${{ github.repository_owner }}/ledgersmb-dev-docker
event-type: master-updated
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
if: steps.pr_trigger.outputs.MUST_TRIGGER