forked from ledgersmb/LedgerSMB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
395 lines (356 loc) · 11.1 KB
/
config.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
version: 2.1
# Define defaults
_defaults: &defaults
# Make sure that .profile is sourced to local::lib
shell: /bin/bash --login -eo pipefail
# Define aliases for simplification
aliases:
- &store_artifacts
store_artifacts:
path: /tmp/artifact/
# UI Coverage orbs
orbs:
coveralls: coveralls/coveralls@2.1.2
# Reuseable commands
commands:
check-changed-files-or-halt:
parameters:
pattern:
type: string
steps:
- run: git show -m HEAD --name-only --pretty="" | egrep -q -v '<< parameters.pattern >>' || circleci step halt
prove:
steps:
- run:
name: Set up coverage
command: |
if [ "x$COVERAGE" == "x1" ]
then
echo "JOB_COUNT=4" >> $BASH_ENV
echo "STARMAN_DEVEL_COVER_OPTIONS='-MDevel::Cover=$DEVEL_COVER_OPTIONS'" >> $BASH_ENV
echo "YATH_DEVEL_COVER_OPTIONS='--cover=$DEVEL_COVER_OPTIONS'" >> $BASH_ENV
echo "UITESTS='--coverage *'" >> $BASH_ENV
fi
- run:
name: Run API tests
command: |
export PWD="${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}"
export PERL5LIB="lib:old/lib:$PERL5LIB"
make jstest
- run:
command: |
source $BASH_ENV
export PERL5OPT="$PERL5OPT -MSyntax::Keyword::Try::Deparse"
if [ "x$COVERAGE" == "x1" ]
then
make devtest TESTS="--no-progress --job-count $JOB_COUNT \"--cover=$DEVEL_COVER_OPTIONS\" t/ xt/"
else
make devtest TESTS='--no-progress --job-count 2 t/ xt/'
fi
- run:
command: |
while [ $(pidof starman) ];
do
kill -SIGTERM `pidof starman`
echo -n "."
sleep 5
done
echo " done"
- run:
name: Plot monitoring graph & save artefacts
command: |
gnuplot -e "filename='logs/${MONITOR_FILE}.txt';outputfile='screens/${MONITOR_FILE}.png'" \
utils/test/monitor.gnuplot || true
mkdir -p /tmp/artifact/logs/screens;
cp -r logs/* /tmp/artifact/logs || true;
when: always
- run:
name: Upload coverage data
command: |
if [ "x$COVERAGE" == "x1" ]
then
COVERALLS_PARALLEL=true cover -report coveralls
COVERALLS_FLAG_NAME: Perl Tests
cover -report text > /tmp/artifact/coverage.txt
fi
- when:
condition:
equal: [ "$COVERAGE", "1" ]
steps:
- coveralls/upload:
parallel: true
flag_name: UI Tests
verbose: false
- when:
condition:
equal: [ "$COVERAGE", "1" ]
steps:
- coveralls/upload:
parallel_finished: true
- *store_artifacts
prep_env:
parameters:
perl:
type: string
description: "Prepare environment"
steps:
- checkout
- check-changed-files-or-halt:
pattern: ^.github/
- run:
name: "Monitor CPU & MEMORY"
command: |
mkdir -p logs/screens
./utils/test/monitor_rss.sh logs/${MONITOR_FILE}.txt
background: true
# Restore node_modules
- restore_cache:
keys:
# Find a cache corresponding to this specific package-lock.json checksum
# when this file is changed, this key will fail
- v1-npm-deps-{{ checksum "package-lock.json" }}
# Find the most recently generated cache used from any branch
- v1-npm-deps-
- run:
name: Make JS + README
command: |
make js
make readme
- save_cache:
key: v1-npm-deps-{{ checksum "package-lock.json" }}
paths:
- $HOME/.npm
- run:
name: Set up dirs and files
command: |
mkdir -p logs/screens
# these commands are in start.sh of the Perl container too:
cp doc/conf/ledgersmb.conf.default ledgersmb.conf
sed -i \
-e "s/\(cache_templates = \).*\$/cache_templates = 1/g" \
-e "s/\(host = \).*\$/\1$POSTGRES_HOST/g" \
-e "s/\(port = \).*\$/\1$POSTGRES_PORT/g" \
-e "s/\(default_db = \).*\$/\1$DEFAULT_DB/g" \
-e "s%\(sendmail = \).*%#\1/usr/sbin/ssmtp%g" \
-e "s/# \(smtphost = \).*\$/\1mailhog:1025/g" \
-e "s/# \(backup_email_from = \).*\$/\1lsmb-backups@example.com/g" \
-e "s/#dojo_built = 1/dojo_built = 0/" \
-e "s/db_namespace = public/db_namespace = xyz/" \
ledgersmb.conf
# Freshen up CPAN
- restore_cache:
keys:
# Get latest cache for the current specs
- v2-cpm-<< parameters.perl >>-{{ .Branch }}-{{ checksum "cpanfile" }}
# Fall back to the latest for the current branch
- v2-cpm-<< parameters.perl >>-{{ .Branch }}-
# Fall back to the latest for master
- v2-cpm-<< parameters.perl >>-master-
# Don't fall back any further
- run:
name: Refresh modules from CPAN
command: |
cpm install --local-lib-contained=$HOME/perl5 --no-test \
--resolver=metacpan \
--with-develop \
--feature=starman \
--feature=latex-pdf-ps \
--feature=openoffice \
--feature=xls \
--feature=edi
cpm install --local-lib-contained=$HOME/perl5 --no-test \
--resolver=metacpan \
JSON::PP~4.03 Gazelle
if [ "x$COVERAGE" == "x1" ]
then
cpm install --local-lib-contained=$HOME/perl5 --no-test \
--resolver=metacpan \
Devel::Cover \
Devel::Cover::Report::Coveralls
fi
rm -rf $HOME/.perl-cpm
- save_cache:
key: v2-cpm-<< parameters.perl >>-{{ .Branch }}-{{ checksum "cpanfile" }}
paths:
- $HOME/perl5
- run:
name: Set up host IP & BASE variables
command: |
echo "HOST_IP=$(hostname -I |awk '{print $1}')" >> $BASH_ENV
echo "export LSMB_BASE_URL=http://\$HOST_IP:5000" >> $BASH_ENV
echo "export PSGI_BASE_URL=http://\$HOST_IP:5762" >> $BASH_ENV
- run:
name: Test MailHog
command: |
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 localhost:8025/api/v2/messages
start_starman:
description: "Start starman"
steps:
- run:
command: |
source $BASH_ENV
if [ "x$COVERAGE" == "x1" ]
then
JOB_COUNT=2
fi
PERL5OPT="$PERL5OPT -MDevel::Cover=$DEVEL_COVER_OPTIONS" \
starman --preload-app --pid starman.pid --workers $JOB_COUNT \
--max-requests 5000 --error-log logs/starman-error.log \
-Ilib -Iold/lib --port 5762 bin/ledgersmb-server.psgi
echo "starman done!"
touch starman-done
background: true
start_proxy:
description: "Start the proxy"
parameters:
proxy:
type: string
default: nginx
steps:
- run:
command: |
/usr/local/bin/<< parameters.proxy >>.sh
background: true
# Define executors
executors:
test:
parameters:
perl:
type: string
default: latest
postgres:
type: string
default: latest
browser:
type: string
default: chrome
hub:
type: string
default: selenium/hub:3
selenium:
type: string
default: selenium/node-chrome:3
coverage:
type: integer
default: 0
docker:
- image: ledgersmbdev/ledgersmb_circleci-perl:<< parameters.perl >>
- image: ledgersmbdev/ledgersmb_circleci-postgres:<< parameters.postgres >>
environment:
POSTGRES_PASSWORD: test
- image: << parameters.hub >>
name: selenium-hub
environment:
GRID_DEBUG: "true"
GRID_HUB_PORT: 4444
GRID_MAX_SESSION: 100
- image: << parameters.selenium >>
environment:
GRID_DEBUG: "true"
HUB_HOST: selenium-hub
HUB_PORT: 4444
NODE_MAX_SESSION: 5
NODE_MAX_INSTANCES: 5
- image: mailhog/mailhog:latest
environment:
BROWSER: << parameters.browser >>
COVERAGE: << parameters.coverage >>
DEVEL_COVER_OPTIONS: -silent,1,+ignore,(^x?t/|^utils/|\.lttc$|^/usr/|/home/circleci/perl5|starman$$)
HARNESS_RULESFILE: t/testrules.yml
JOB_COUNT: 4
LSMB_BASE_URL: http://127.0.0.1:5000
LSMB_NEW_DB: lsmb_test
LSMB_NEW_DB_API: lsmb_test_api
LSMB_TEST_DB: 1
MONITOR_FILE: cpu-memory-usage
PGDB: lsmb_test
PGHOST: localhost
POSTGRES_HOST: localhost
PGPASSWORD: test
PGUSER: postgres
PSGI_BASE_URL: http://127.0.0.1:5762
PWD: $CIRCLE_WORKING_DIRECTORY
RELEASE_TESTING: 1
REMOTE_SERVER_ADDR: selenium-hub
STARMAN_DEVEL_COVER_OPTIONS: ''
UIUSER: Jest
UIPASSWORD: Tester
UITESTS: '*'
YATH_DEVEL_COVER_OPTIONS: ''
# Define jobs
jobs:
test_webpack_chrome:
<<: *defaults
executor:
name: test
perl: '5.34'
postgres: '11'
browser: chrome
selenium: selenium/node-chrome:3.141.59-20210607
# coverage: 1
steps:
- prep_env:
perl: '5.34'
- start_starman
- start_proxy
- prove
# The resource_class feature allows configuring CPU and RAM resources for each job.
# Different resource classes are available for different executors.
# https://circleci.com/docs/2.0/configuration-reference/#resourceclass
resource_class: large
test_webpack_firefox:
<<: *defaults
executor:
name: test
perl: '5.32'
postgres: '11'
browser: firefox
selenium: selenium/node-firefox:3
steps:
- prep_env:
perl: '5.32'
- start_starman
- start_proxy
- prove
environment:
COA_TESTING: 1
test_webpack_opera:
<<: *defaults
executor:
name: test
perl: '5.32'
postgres: '11'
browser: operablink
selenium: selenium/node-opera:3
steps:
- prep_env:
perl: '5.32'
- start_starman
- start_proxy
- prove
environment:
DB_TESTING: 1
# Workflows
# Tests multiple browsers, coverage and dojo
_filters: &_filters
branches:
ignore:
- /1\.2\..*/
- /1\.3\..*/
- /1\.4\..*/
- /1\.5\..*/
- /1\.6\..*/
workflows:
workflow:
jobs:
- test_webpack_chrome:
filters: *_filters
# - test_webpack_firefox:
# filters: *_filters
# - test_webpack_opera:
# filters: *_filters