@@ -3,6 +3,7 @@ version: "3"
3
3
includes :
4
4
docs : " docs/tasks.yml"
5
5
lint : " lint-tasks.yml"
6
+ utils : " tools/yscope-dev-utils/taskfiles/utils.yml"
6
7
7
8
vars :
8
9
# Paths
60
61
- " init"
61
62
- " job-orchestration"
62
63
- " package-venv"
63
- - task : " validate-checksum"
64
+ - task : " utils: validate-checksum"
64
65
vars :
65
66
CHECKSUM_FILE : " {{.CHECKSUM_FILE}}"
66
67
DATA_DIR : " {{.OUTPUT_DIR}}"
97
98
cd "{{.OUTPUT_DIR}}/var/www/programs/server"
98
99
PATH="{{.G_WEBUI_NODEJS_BIN_DIR}}":$PATH npm install
99
100
# This command must be last
100
- - task : " compute-checksum"
101
+ - task : " utils: compute-checksum"
101
102
vars :
102
103
DATA_DIR : " {{.OUTPUT_DIR}}"
103
104
OUTPUT_FILE : " {{.CHECKSUM_FILE}}"
@@ -163,7 +164,7 @@ tasks:
163
164
deps :
164
165
- " init"
165
166
- " meteor"
166
- - task : " validate-checksum"
167
+ - task : " utils: validate-checksum"
167
168
vars :
168
169
CHECKSUM_FILE : " {{.CHECKSUM_FILE}}"
169
170
DATA_DIR : " {{.OUTPUT_DIR}}"
@@ -187,7 +188,7 @@ tasks:
187
188
# Remove temp files generated by `meteor build` before checksum
188
189
- " find node_modules -type f -name '.meteor-portable-2.json' -exec rm {} +"
189
190
# This command must be last
190
- - task : " compute-checksum"
191
+ - task : " utils: compute-checksum"
191
192
vars :
192
193
DATA_DIR : " {{.OUTPUT_DIR}}"
193
194
OUTPUT_FILE : " {{.CHECKSUM_FILE}}"
@@ -223,14 +224,14 @@ tasks:
223
224
OUTPUT_DIR : " submodules"
224
225
deps :
225
226
- " init"
226
- - task : " validate-checksum"
227
+ - task : " utils: validate-checksum"
227
228
vars :
228
229
CHECKSUM_FILE : " {{.CHECKSUM_FILE}}"
229
230
DATA_DIR : " {{.OUTPUT_DIR}}"
230
231
cmds :
231
232
- " tools/scripts/deps-download/download-all.sh"
232
233
# This command must be last
233
- - task : " compute-checksum"
234
+ - task : " utils: compute-checksum"
234
235
vars :
235
236
DATA_DIR : " {{.OUTPUT_DIR}}"
236
237
OUTPUT_FILE : " {{.CHECKSUM_FILE}}"
@@ -251,7 +252,7 @@ tasks:
251
252
TAR_PATH : " {{.OUTPUT_TMP_DIR}}/{{.TAR_NAME}}"
252
253
deps :
253
254
- " init"
254
- - task : " validate-checksum"
255
+ - task : " utils: validate-checksum"
255
256
vars :
256
257
CHECKSUM_FILE : " {{.CHECKSUM_FILE}}"
257
258
DATA_DIR : " {{.OUTPUT_DIR}}"
@@ -266,7 +267,7 @@ tasks:
266
267
- " mv '{{.EXTRACTED_DIR}}' '{{.OUTPUT_DIR}}'"
267
268
- " rm -rf '{{.OUTPUT_TMP_DIR}}'"
268
269
# This command must be last
269
- - task : " compute-checksum"
270
+ - task : " utils: compute-checksum"
270
271
vars :
271
272
DATA_DIR : " {{.OUTPUT_DIR}}"
272
273
OUTPUT_FILE : " {{.CHECKSUM_FILE}}"
@@ -337,12 +338,12 @@ tasks:
337
338
# `/parents/A` -> `/parents/B` rather than `/parents/A` -> `/parents/B/A`
338
339
- " rsync --archive '{{.G_PACKAGE_BUILD_DIR}}/' '{{.OUTPUT_DIR}}'"
339
340
# Set the storage engine for the package
340
- - task : " replace-text"
341
+ - task : " utils: replace-text"
341
342
vars :
342
343
FILE_PATH : " {{.OUTPUT_DIR}}/lib/python3/site-packages/clp_py_utils/clp_config.py"
343
344
SED_EXP : >-
344
345
s/([[:space:]]*storage_engine: str = ")[^"]+"/\1{{.STORAGE_ENGINE}}"/
345
- - task : " replace-text"
346
+ - task : " utils: replace-text"
346
347
vars :
347
348
FILE_PATH : " {{.OUTPUT_DIR}}/etc/clp-config.yml"
348
349
SED_EXP : >-
@@ -364,18 +365,18 @@ tasks:
364
365
OUTPUT_DIR : " {{.G_PACKAGE_VENV_DIR}}"
365
366
deps :
366
367
- " init"
367
- - task : " validate-checksum"
368
+ - task : " utils: validate-checksum"
368
369
vars :
369
370
CHECKSUM_FILE : " {{.CHECKSUM_FILE}}"
370
371
DATA_DIR : " {{.OUTPUT_DIR}}"
371
372
cmds :
372
- - task : " create-venv"
373
+ - task : " utils: create-venv"
373
374
vars :
374
375
LABEL : " package"
375
376
OUTPUT_DIR : " {{.OUTPUT_DIR}}"
376
377
REQUIREMENTS_FILE : " requirements.txt"
377
378
# This command must be last
378
- - task : " compute-checksum"
379
+ - task : " utils: compute-checksum"
379
380
vars :
380
381
DATA_DIR : " {{.OUTPUT_DIR}}"
381
382
OUTPUT_FILE : " {{.CHECKSUM_FILE}}"
@@ -427,15 +428,15 @@ tasks:
427
428
deps :
428
429
- " init"
429
430
- " meteor"
430
- - task : " validate-checksum"
431
+ - task : " utils: validate-checksum"
431
432
vars :
432
433
CHECKSUM_FILE : " {{.CHECKSUM_FILE}}"
433
434
DATA_DIR : " {{.OUTPUT_DIR}}"
434
435
cmds :
435
436
- " rm -rf '{{.OUTPUT_DIR}}'"
436
437
- " PATH='{{.G_METEOR_BUILD_DIR}}':$PATH meteor npm install --production"
437
438
# This command must be last
438
- - task : " compute-checksum"
439
+ - task : " utils: compute-checksum"
439
440
vars :
440
441
DATA_DIR : " {{.OUTPUT_DIR}}"
441
442
OUTPUT_FILE : " {{.CHECKSUM_FILE}}"
@@ -456,18 +457,18 @@ tasks:
456
457
CHECKSUM_FILE : " {{.G_BUILD_DIR}}/{{.COMPONENT}}-venv.md5"
457
458
deps :
458
459
- " init"
459
- - task : " validate-checksum"
460
+ - task : " utils: validate-checksum"
460
461
vars :
461
462
CHECKSUM_FILE : " {{.CHECKSUM_FILE}}"
462
463
DATA_DIR : " {{.OUTPUT_DIR}}"
463
464
cmds :
464
- - task : " create-venv"
465
+ - task : " utils: create-venv"
465
466
vars :
466
467
LABEL : " {{.COMPONENT}}"
467
468
OUTPUT_DIR : " {{.OUTPUT_DIR}}"
468
469
REQUIREMENTS_FILE : " {{.ROOT_DIR}}/requirements.txt"
469
470
# This command must be last
470
- - task : " compute-checksum"
471
+ - task : " utils: compute-checksum"
471
472
vars :
472
473
DATA_DIR : " {{.OUTPUT_DIR}}"
473
474
OUTPUT_FILE : " {{.CHECKSUM_FILE}}"
@@ -487,87 +488,8 @@ tasks:
487
488
cmds :
488
489
- " rm -rf dist"
489
490
490
- create-venv :
491
- internal : true
492
- requires :
493
- vars : ["LABEL", "OUTPUT_DIR", "REQUIREMENTS_FILE"]
494
- label : " create-venv-{{.LABEL}}"
495
- cmds :
496
- - " rm -rf '{{.OUTPUT_DIR}}'"
497
- - " python3 -m venv '{{.OUTPUT_DIR}}'"
498
- # Remove calls to `hash` from the venv activation script since Task uses `gosh` rather than
499
- # `bash`.
500
- # NOTE: Older versions of Python's venv would only call `hash` if they detected the running
501
- # shell was one that had the command, but that's not the case in newer versions.
502
- - task : " replace-text"
503
- vars :
504
- FILE_PATH : " {{.OUTPUT_DIR}}/bin/activate"
505
- SED_EXP : >-
506
- s/^([[:space:]]*)hash[[:space:]]+.*/\1true/g
507
- - |-
508
- . "{{.OUTPUT_DIR}}/bin/activate"
509
- pip3 install --upgrade pip
510
- pip3 install --upgrade -r "{{.REQUIREMENTS_FILE}}"
511
-
512
491
init :
513
492
internal : true
514
493
run : " once"
515
494
silent : true
516
495
cmd : " mkdir -p '{{.G_BUILD_DIR}}'"
517
-
518
- compute-checksum :
519
- desc : " Tries to compute a checksum for the given directory and output it to a file."
520
- internal : true
521
- # Ignore errors so that dependent tasks don't fail
522
- ignore_error : true
523
- silent : true
524
- requires :
525
- vars : ["DATA_DIR", "OUTPUT_FILE"]
526
- cmds :
527
- - >-
528
- tar cf -
529
- --directory "{{.DATA_DIR}}"
530
- --group=0
531
- --mtime='UTC 1970-01-01'
532
- --numeric-owner
533
- --owner=0
534
- --sort=name
535
- {{.CHECKSUM_TAR_BASE_ARGS}} . 2> /dev/null
536
- | md5sum > {{.OUTPUT_FILE}}
537
-
538
- validate-checksum :
539
- desc : " Validates the checksum of the given directory matches the checksum in the given file, or
540
- deletes the checksum file otherwise."
541
- internal : true
542
- silent : true
543
- requires :
544
- vars : ["CHECKSUM_FILE", "DATA_DIR"]
545
- vars :
546
- TMP_CHECKSUM_FILE : " {{.CHECKSUM_FILE}}.tmp"
547
- cmds :
548
- - task : " compute-checksum"
549
- vars :
550
- DATA_DIR : " {{.DATA_DIR}}"
551
- OUTPUT_FILE : " {{.TMP_CHECKSUM_FILE}}"
552
- - defer : " rm -f '{{.TMP_CHECKSUM_FILE}}'"
553
- # Check that the directory exists and the checksum matches; otherwise delete the checksum file
554
- - >-
555
- (
556
- test -d "{{.DATA_DIR}}"
557
- && diff -q '{{.TMP_CHECKSUM_FILE}}' '{{.CHECKSUM_FILE}}' 2> /dev/null
558
- ) || rm -f '{{.CHECKSUM_FILE}}'
559
-
560
- replace-text :
561
- desc : " Task to replace some text in a file using sed."
562
- internal : true
563
- requires :
564
- vars : ["FILE_PATH", "SED_EXP"]
565
- cmds :
566
- - |-
567
- # NOTE:
568
- # 1. We can't use `sed -i` since `-i` has different syntax on Linux and macOS
569
- # 2. We can't use `--regexp` instead of `-E` since `--regexp` is not supported on macOS
570
- src="{{.FILE_PATH}}"
571
- dst="{{.FILE_PATH}}.tmp"
572
- sed -E '{{.SED_EXP}}' "${src}" > "${dst}"
573
- mv "${dst}" "${src}"
0 commit comments