forked from FerretDB/FerretDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Taskfile.yml
917 lines (832 loc) · 29.4 KB
/
Taskfile.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
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
---
version: 3
env:
GORACE: halt_on_error=1,history_size=2
GOCOVERDIR: tmp/cover
vars:
SHARD_INDEX: 0
SHARD_TOTAL: 0
DISABLE_PUSHDOWN: false
TEST_RUN: ""
TEST_TIMEOUT: 35m
BENCH_TIME: 5s
TESTJS_PORT: 27017
RACE_FLAG: -race={{and (ne OS "windows") (ne ARCH "arm") (ne ARCH "riscv64")}}
BUILD_TAGS: ferretdb_debug,ferretdb_hana
SERVICES: postgres postgres_secured mysql mongodb mongodb_secured jaeger
tasks:
# invoked when `task` is run without arguments
default:
deps: [all]
all:
desc: "Generate, format, build, unit test and lint code and documentation"
cmds:
- task: gen
- task: build-host
- task: test-unit
- task: lint
- task: security
- task: fmt-yaml
- task: docs
init-tools:
dir: tools
cmds:
- go mod tidy
- go mod verify
- go generate -x
init-tools-golangci:
dir: tools/golangci
cmds:
- go mod tidy
- go mod verify
- go generate -x
init-integration:
dir: integration
cmds:
- go mod tidy
- go mod verify
init:
desc: "Install development tools"
deps: [init-tools, init-tools-golangci, init-integration]
cmds:
- go mod tidy
- go mod verify
- task: gen-version
env-reset:
desc: "Clean ALL Go and Docker data (caches, images, volumes), and reset environment"
cmds:
- task: env-down
- cmd: docker buildx prune --all
ignore_error: true # build container may not exist
- docker system prune --all --volumes
- bin/golangci-lint{{exeExt}} cache clean
- go clean -cache -testcache -modcache -fuzzcache
- bin/envtool{{exeExt}} shell rmdir .cache .task tools/.task integration/.task tmp
- task: env-pull
- task: init
env-up-detach:
cmds:
- docker version
- docker compose version
# use -t instead of --timeout / --wait-timeout to be compatible with all versions:
# https://github.com/docker/compose/issues/10269#issuecomment-1495205234
- >
docker compose up --always-recreate-deps --force-recreate --remove-orphans --renew-anon-volumes -t 0 --detach
--build --pull=always
{{.SERVICES}}
env-up-detach-offline:
cmds:
- docker version
- docker compose version
# use -t instead of --timeout / --wait-timeout to be compatible with all versions:
# https://github.com/docker/compose/issues/10269#issuecomment-1495205234
- >
docker compose up --always-recreate-deps --force-recreate --remove-orphans --renew-anon-volumes -t 0 --detach
{{.SERVICES}}
env-setup:
deps: [gen-version]
cmds:
- bin/envtool{{exeExt}} setup
env-logs:
cmds:
- docker compose ps --all
- docker compose logs --follow
env-up:
desc: "Start development environment"
deps: [env-up-detach, env-setup]
cmds:
- task: env-logs
env-up-offline:
deps: [env-up-detach-offline, env-setup]
cmds:
- task: env-logs
env-pull:
desc: "Pull development environment's Docker images"
cmds:
- docker compose build --pull
env-down:
desc: "Stop development environment"
cmds:
# use -t instead of --timeout / --wait-timeout to be compatible with all versions:
# https://github.com/docker/compose/issues/10269#issuecomment-1495205234
- docker compose down --remove-orphans -t 0 --volumes
env-data:
desc: "Fill `test` database with data for experiments"
cmds:
- bin/task{{exeExt}} -d integration env-data
gen-version:
run: once
cmds:
# those two should always be in sync
- go generate -x ./build/version
- go build -v -o bin/ {{.RACE_FLAG}} -tags={{.BUILD_TAGS}} ./cmd/envtool/
build-host:
desc: "Build bin/ferretdb{{exeExt}} on the host for development"
run: once
deps: [gen-version]
cmds:
- echo 'build-host' > build/version/package.txt
- go build -v -o=bin/ferretdb{{exeExt}} {{.RACE_FLAG}} -tags={{.BUILD_TAGS}} -coverpkg=./... ./cmd/ferretdb
- bin/envtool{{exeExt}} shell mkdir tmp/cover
gen:
desc: "Generate (and format) Go code"
cmds:
- go generate -x ./...
- bin/task{{exeExt}} -d integration integration-gen
- task: fmt-go
# invoked by FerretDB/github-actions/linters action
fmt:
deps: [fmt-go]
fmt-go:
desc: "Format Go code"
cmds:
- bin/goimports{{exeExt}} -local=github.com/FerretDB/FerretDB -w .
- bin/gofumpt{{exeExt}} -w .
test:
desc: "Run all unit and integration tests in parallel"
deps: [test-unit, test-integration]
test-unit-short:
desc: "Run short unit tests (with caching)"
cmds:
- go test -short -timeout={{.TEST_TIMEOUT}} {{.RACE_FLAG}} -tags={{.BUILD_TAGS}} -shuffle=on -coverpkg=./... -coverprofile=cover.txt ./...
- bin/task{{exeExt}} -d tools tools-test-short
test-unit:
desc: "Run all unit tests"
cmds:
- go test -count=1 -timeout={{.TEST_TIMEOUT}} {{.RACE_FLAG}} -tags={{.BUILD_TAGS}} -shuffle=on -coverpkg=./... -coverprofile=cover.txt ./...
- go test -count=1 -timeout={{.TEST_TIMEOUT}} {{.RACE_FLAG}} -tags={{.BUILD_TAGS}} -shuffle=on -bench=. -benchtime=1x ./...
- bin/task{{exeExt}} -d tools tools-test
test-integration:
desc: "Run integration tests for several backends in parallel"
deps:
- test-integration-postgresql
- test-integration-sqlite
# no test-integration-hana
- test-integration-mongodb
test-integration-postgresql:
desc: "Run integration tests for `postgresql` backend"
deps: [gen-version]
dir: integration
cmds:
- >
../bin/envtool{{exeExt}} tests run
--shard-index={{.SHARD_INDEX}}
--shard-total={{.SHARD_TOTAL}}
--run='{{.TEST_RUN}}'
--skip='{{.TEST_SKIP}}'
--
-count=1
-timeout={{.TEST_TIMEOUT}}
{{.RACE_FLAG}}
-tags={{.BUILD_TAGS}}
-shuffle=on
-coverpkg=../...
-coverprofile=integration-postgresql.txt
./...
-target-backend=ferretdb-postgresql
-target-tls
-postgresql-url='postgres://username@127.0.0.1:5432/ferretdb?search_path='
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=client.pem&tlsCaFile=rootCA-cert.pem&replicaSet=rs0'
-disable-pushdown={{.DISABLE_PUSHDOWN}}
test-integration-sqlite:
desc: "Run integration tests for `sqlite` backend"
deps: [gen-version]
dir: integration
cmds:
- >
../bin/envtool{{exeExt}} tests run
--shard-index={{.SHARD_INDEX}}
--shard-total={{.SHARD_TOTAL}}
--run='{{.TEST_RUN}}'
--skip='{{.TEST_SKIP}}'
--
-count=1
-timeout={{.TEST_TIMEOUT}}
{{.RACE_FLAG}}
-tags={{.BUILD_TAGS}}
-shuffle=on
-coverpkg=../...
-coverprofile=integration-sqlite.txt
./...
-target-backend=ferretdb-sqlite
-sqlite-url=file:../tmp/sqlite-tests/
-target-tls
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=client.pem&tlsCaFile=rootCA-cert.pem&replicaSet=rs0'
-disable-pushdown={{.DISABLE_PUSHDOWN}}
test-integration-mysql:
desc: "Run integration tests for `mysql` handler"
deps: [gen-version]
dir: integration
cmds:
- >
../bin/envtool{{exeExt}} tests run
--shard-index={{.SHARD_INDEX}}
--shard-total={{.SHARD_TOTAL}}
--run='{{.TEST_RUN}}'
--skip='{{.TEST_SKIP}}'
--
-count=1
-timeout={{.TEST_TIMEOUT}}
{{.RACE_FLAG}}
-tags={{.BUILD_TAGS}}
-shuffle=on
-coverpkg=../...
-coverprofile=integration-mysql.txt
./...
-target-backend=ferretdb-mysql
-target-tls
-mysql-url='mysql://username:password@127.0.0.1:3306/ferretdb'
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=client.pem&tlsCaFile=rootCA-cert.pem&replicaSet=rs0'
-disable-pushdown={{.DISABLE_PUSHDOWN}}
test-integration-hana:
desc: "Run integration tests for `hana` handler"
deps: [gen-version]
dir: integration
cmds:
- >
../bin/envtool{{exeExt}} tests run
--shard-index={{.SHARD_INDEX}}
--shard-total={{.SHARD_TOTAL}}
--run='{{.TEST_RUN}}'
--skip='{{.TEST_SKIP}}'
--
-count=1
-timeout={{.TEST_TIMEOUT}}
{{.RACE_FLAG}}
-tags={{.BUILD_TAGS}}
-shuffle=on
-coverpkg=../...
-coverprofile=integration-hana.txt
./...
-target-backend=ferretdb-hana
-target-tls
-hana-url=$FERRETDB_HANA_URL
-compat-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=client.pem&tlsCaFile=rootCA-cert.pem&replicaSet=rs0'
-disable-pushdown={{.DISABLE_PUSHDOWN}}
test-integration-mongodb:
desc: "Run integration tests for MongoDB"
deps: [gen-version]
dir: integration
cmds:
- >
../bin/envtool{{exeExt}} tests run
--shard-index={{.SHARD_INDEX}}
--shard-total={{.SHARD_TOTAL}}
--run='{{.TEST_RUN}}'
--skip='{{.TEST_SKIP}}'
--
-count=1
-timeout={{.TEST_TIMEOUT}}
{{.RACE_FLAG}}
-tags={{.BUILD_TAGS}}
-shuffle=on
-coverpkg=../...
-coverprofile=integration-mongodb.txt
./...
-target-url='mongodb://username:password@127.0.0.1:47018/?tls=true&tlsCertificateKeyFile=client.pem&tlsCaFile=rootCA-cert.pem&replicaSet=rs0'
-target-backend=mongodb
bench-unit:
desc: "Run unit benchmarks"
cmds:
- go test -list='Benchmark.*' ./...
- go test -count=10 -bench=BenchmarkDocument -benchtime={{.BENCH_TIME}} ./internal/bson/ | tee -a new.txt
- bin/benchstat{{exeExt}} old.txt new.txt
run:
desc: "Run FerretDB with `postgresql` backend"
deps: [build-host]
cmds:
- >
bin/ferretdb{{exeExt}}
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
--repl-set-name=rs0
--handler=pg
--postgresql-url='postgres://username@127.0.0.1:5432/ferretdb?search_path='
--test-records-dir=tmp/records
--otel-traces-url=http://127.0.0.1:4318/v1/traces
run-sqlite:
desc: "Run FerretDB with `sqlite` backend"
deps: [build-host]
cmds:
- bin/envtool{{exeExt}} shell mkdir tmp/sqlite
- >
bin/ferretdb{{exeExt}}
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
--handler=sqlite
--sqlite-url=file:tmp/sqlite/
--test-records-dir=tmp/records
run-mysql:
desc: "Run FerretDB with `mysql` backend"
deps: [build-host]
cmds:
- >
bin/ferretdb{{exeExt}}
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
--handler=mysql
--mysql-url='mysql://username@127.0.0.1:3306/ferretdb'
--test-records-dir=tmp/records
# set FERRETDB_HANA_URL environment variable to use it
run-hana:
desc: "Run FerretDB with `hana` backend"
deps: [build-host]
cmds:
- >
bin/ferretdb{{exeExt}}
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
--handler=hana
--test-records-dir=tmp/records
run-secured:
desc: "Run FerretDB with `postgresql` backend (TLS, auth required)"
deps: [build-host]
cmds:
- >
bin/ferretdb{{exeExt}}
--listen-addr=''
--listen-tls=:27018
--listen-tls-cert-file=./build/certs/server-cert.pem
--listen-tls-key-file=./build/certs/server-key.pem
--listen-tls-ca-file=./build/certs/rootCA-cert.pem
--proxy-addr=127.0.0.1:47017
--mode=diff-normal
--handler=pg
--postgresql-url='postgres://127.0.0.1:5433/ferretdb?search_path='
--test-records-dir=tmp/records
run-proxy:
desc: "Run FerretDB in the diff-proxy mode"
deps: [build-host]
cmds:
- >
bin/ferretdb{{exeExt}}
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-proxy
--handler=pg
--postgresql-url='postgres://username@127.0.0.1:5432/ferretdb?search_path='
--test-records-dir=tmp/records
run-sqlite-proxy:
desc: "Run FerretDB with `sqlite` handler in the diff-proxy mode"
deps: [build-host]
cmds:
- bin/envtool{{exeExt}} shell mkdir tmp/sqlite
- >
bin/ferretdb{{exeExt}}
--listen-addr=:27017
--proxy-addr=127.0.0.1:47017
--mode=diff-proxy
--handler=sqlite
--sqlite-url=file:tmp/sqlite/
--test-records-dir=tmp/records
run-proxy-secured:
desc: "Run FerretDB in the diff-proxy mode (TLS, auth required)"
deps: [build-host]
cmds:
- >
bin/ferretdb{{exeExt}}
--listen-addr=''
--listen-tls=:27018
--listen-tls-cert-file=./build/certs/server-cert.pem
--listen-tls-key-file=./build/certs/server-key.pem
--listen-tls-ca-file=./build/certs/rootCA-cert.pem
--proxy-addr=127.0.0.1:47018
--proxy-tls-cert-file=./build/certs/client-cert.pem
--proxy-tls-key-file=./build/certs/client-key.pem
--proxy-tls-ca-file=./build/certs/rootCA-cert.pem
--mode=diff-proxy
--handler=pg
--postgresql-url='postgres://username@127.0.0.1:5433/ferretdb?search_path='
--test-records-dir=tmp/records
lint:
desc: "Run linters"
cmds:
- bin/envtool{{exeExt}} shell rmdir tmp/githubcache
- bin/envtool{{exeExt}} shell mkdir tmp/githubcache
- bin/golangci-lint{{exeExt}} run --config=.golangci.yml
- bin/golangci-lint{{exeExt}} run --config=.golangci-new.yml
- bin/go-consistent{{exeExt}} -pedantic ./cmd/... ./internal/... ./build/... ./ferretdb/...
- go vet -vettool=bin/checkswitch{{exeExt}} ./...
- go vet -vettool=bin/checkcomments{{exeExt}} ./...
- bin/task{{exeExt}} -d integration lint
- bin/task{{exeExt}} -d tools lint
security:
desc: "Run security scanners"
cmds:
# don't run them in parallel via `deps` because that breaks terminal output
- task: security-govulncheck
- task: security-trivy
security-govulncheck:
cmds:
- bin/govulncheck{{exeExt}} -test -show=verbose,color ./...
- bin/task{{exeExt}} -d integration integration-security
security-trivy:
cmds:
- >
docker compose run --rm trivy filesystem .
--secret-config=./build/trivy-secret.yml
--ignorefile=./build/trivy-ignore.yml
--cache-dir=./tmp/trivy
--exit-code=1
godocs:
desc: "Serve Go code documentation"
cmds:
- bin/pkgsite{{exeExt}} -http=127.0.0.1:6060 -open
psql:
desc: "Run psql"
cmds:
- docker compose exec -e PGPASSWORD=password postgres psql -U username -d ferretdb
sqlite3:
desc: "Run sqlite3"
cmds:
- sqlite3 tmp/sqlite/*.sqlite
mysql:
desc: "Run mysql"
cmds:
- docker compose exec -e MYSQL_PASSWORD=password mysql mysql -u username -ppassword ferretdb
mongosh:
desc: "Run MongoDB shell (`mongosh`)"
cmds:
- >
docker compose exec mongodb mongosh
--verbose --eval 'disableTelemetry()' --shell
'mongodb://host.docker.internal:27017/?heartbeatFrequencyMS=300000'
mongosh-secured:
desc: "Run MongoDB shell (`mongosh`) with TLS and auth"
cmds:
- >
docker compose exec mongodb mongosh
--verbose --eval 'disableTelemetry()' --shell
'mongodb://username:password@host.docker.internal:27018/?authMechanism=PLAIN&tls=true&tlsCertificateKeyFile=/etc/certs/client.pem&tlsCaFile=/etc/certs/rootCA-cert.pem'
testjs:
desc: "Run legacy MongoDB shell (`mongo`) with test.js script"
cmds:
- >
docker compose run --rm legacy-mongo-shell
'mongodb://host.docker.internal:{{.TESTJS_PORT}}/'
/legacy-mongo-shell/test.js
docker-init:
run: once
cmds:
- cmd: >
docker buildx create
--driver=docker-container
--name=ferretdb
--bootstrap=true
--use=false
--config=./build/buildkitd.toml
--driver=docker-container
--driver-opt network=host
--driver-opt env.JAEGER_TRACE=127.0.0.1:6831
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SIZE=-1
--driver-opt env.BUILDKIT_STEP_LOG_MAX_SPEED=-1
ignore_error: true
- docker buildx ls
docker-cleanup:
cmds:
- docker system df
- cmd: docker buildx --builder=ferretdb du
ignore_error: true
- cmd: docker buildx --builder=ferretdb rm --force
ignore_error: true
- docker system prune --force
- docker system df
docker-build:
deps: [gen-version, docker-init]
cmds:
- >
docker buildx build --builder=ferretdb
--file=build/{{.FILE}}.Dockerfile
--build-arg=LABEL_VERSION={{.VERSION}}
--build-arg=LABEL_COMMIT={{.COMMIT}}
--target={{.TARGET}}
{{if .PLATFORM}}--platform={{.PLATFORM}}{{end}}
{{if .DOCKER_IMAGES}}{{range splitList "," .DOCKER_IMAGES}}--tag={{trim .}} {{end}}{{end}}
--output={{.OUTPUT}}
.
vars:
VERSION:
sh: bin/envtool{{exeExt}} shell read build/version/version.txt
COMMIT:
sh: bin/envtool{{exeExt}} shell read build/version/commit.txt
requires:
vars: [FILE, TARGET, OUTPUT]
build-move-check:
cmds:
- mv tmp/build/linux_{{.DIR_ARCH}}/ferretdb tmp/{{.BIN_DIR}}/{{.BIN_FILE}}
- >
docker run --rm --platform=linux/{{.DOCKER_ARCH}} -v ./tmp/{{.BIN_DIR}}:/bins ubuntu
/bins/{{.BIN_FILE}} --version
requires:
vars: [DOCKER_ARCH, DIR_ARCH, BIN_FILE, BIN_DIR]
build-development:
desc: "Build development debug binaries"
cmds:
- echo 'bin-development' > build/version/package.txt
- bin/envtool{{exeExt}} shell rmdir tmp/build
- bin/envtool{{exeExt}} shell mkdir tmp/bin-dev
- task: docker-build
vars:
FILE: ferretdb/development
TARGET: development-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
- for: [amd64, arm64, arm/v7]
task: build-move-check
vars:
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
DIR_ARCH: '{{replace "/" "_" .ITEM}}' # arm/v7 -> arm_v7
BIN_FILE: 'ferretdb-dev-linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
BIN_DIR: bin-dev
build-production:
desc: "Build production non-debug binaries"
cmds:
- echo 'bin' > build/version/package.txt
- bin/envtool{{exeExt}} shell rmdir tmp/build
- bin/envtool{{exeExt}} shell mkdir tmp/bin
- task: docker-build
vars:
FILE: ferretdb/production
TARGET: production-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
- for: [amd64, arm64, arm/v7]
task: build-move-check
vars:
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
DIR_ARCH: '{{replace "/" "_" .ITEM}}' # arm/v7 -> arm_v7
BIN_FILE: 'ferretdb-linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
BIN_DIR: bin
docker-local:
desc: "Build `ferretdb-local` Docker image for the host platform"
cmds:
- echo 'docker-local-{{.FILE}}' > build/version/package.txt
- task: docker-build
vars:
FILE: ferretdb/{{.FILE}}
TARGET: "{{.FILE}}"
DOCKER_IMAGES: ferretdb-local
OUTPUT: type=docker
requires:
vars: [FILE]
# TODO https://github.com/FerretDB/FerretDB/issues/2212
docker-all-in-one-push:
cmds:
- echo 'docker-all-in-one' > build/version/package.txt
- task: docker-build
vars:
FILE: ferretdb/all-in-one
TARGET: all-in-one
PLATFORM: linux/amd64,linux/arm64 # no mongosh for arm/v6 and arm/v7
OUTPUT: type=image,push=true
requires:
vars: [DOCKER_IMAGES]
# TODO https://github.com/FerretDB/FerretDB/issues/2212
docker-development-push:
cmds:
- echo 'docker-development' > build/version/package.txt
- task: docker-build
vars:
FILE: ferretdb/development
TARGET: development
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=image,push=true
requires:
vars: [DOCKER_IMAGES]
# TODO https://github.com/FerretDB/FerretDB/issues/2212
docker-production-push:
cmds:
- echo 'docker' > build/version/package.txt
- task: docker-build
vars:
FILE: ferretdb/production
TARGET: production
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=image,push=true
requires:
vars: [DOCKER_IMAGES]
packages:
desc: "Build .deb and .rpm packages"
cmds:
- task: packages-deb-development
- task: packages-deb-production
- task: packages-rpm-development
- task: packages-rpm-production
# TODO https://github.com/FerretDB/FerretDB/issues/2172
packages-build:
cmds:
- >
bin/nfpm{{exeExt}} package
--config=build/nfpm.yml
--packager={{.PACKAGER}}
--target=tmp/{{.PACKAGER}}s/ferretdb-{{.FILE_SUFFIX}}.{{.PACKAGER}}
env:
PACKAGE_VERSION: "{{.PACKAGE_VERSION}}"
PACKAGE_ARCH: "{{.PACKAGE_ARCH}}"
DIR_ARCH: "{{.DIR_ARCH}}"
requires:
vars: [PACKAGER, PACKAGE_VERSION, PACKAGE_ARCH, DIR_ARCH, FILE_SUFFIX]
packages-deb-check:
cmds:
- >
docker run --rm --platform=linux/{{.DOCKER_ARCH}} -v ./tmp/debs:/debs ubuntu
/bin/sh -c '
dpkg-deb --info /debs/ferretdb-{{.FILE_SUFFIX}}.deb &&
dpkg --install /debs/ferretdb-{{.FILE_SUFFIX}}.deb &&
ferretdb --version
'
requires:
vars: [DOCKER_ARCH, FILE_SUFFIX]
packages-deb-development:
cmds:
- echo 'deb-development' > build/version/package.txt
- bin/envtool{{exeExt}} shell rmdir tmp/build
- bin/envtool{{exeExt}} shell mkdir tmp/debs
- task: docker-build
vars:
FILE: ferretdb/development
TARGET: development-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
- for: [amd64, arm64, arm/v7]
task: packages-build
vars:
PACKAGER: deb
PACKAGE_VERSION: "{{.PACKAGE_VERSION}}"
PACKAGE_ARCH: '{{replace "/" "" .ITEM | replace "v" ""}}' # arm/v7 -> arm7
DIR_ARCH: '{{replace "/" "_" .ITEM}}' # arm/v7 -> arm_v7
FILE_SUFFIX: 'dev-linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
- for: [amd64, arm64, arm/v7]
task: packages-deb-check
vars:
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
FILE_SUFFIX: 'dev-linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
vars:
PACKAGE_VERSION:
sh: bin/envtool{{exeExt}} package-version
packages-deb-production:
cmds:
- echo 'deb' > build/version/package.txt
- bin/envtool{{exeExt}} shell rmdir tmp/build
- bin/envtool{{exeExt}} shell mkdir tmp/debs
- task: docker-build
vars:
FILE: ferretdb/production
TARGET: production-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
- for: [amd64, arm64, arm/v7]
task: packages-build
vars:
PACKAGER: deb
PACKAGE_VERSION: "{{.PACKAGE_VERSION}}"
PACKAGE_ARCH: '{{replace "/" "" .ITEM | replace "v" ""}}' # arm/v7 -> arm7
DIR_ARCH: '{{replace "/" "_" .ITEM}}' # arm/v7 -> arm_v7
FILE_SUFFIX: 'linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
- for: [amd64, arm64, arm/v7]
task: packages-deb-check
vars:
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
FILE_SUFFIX: 'linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
vars:
PACKAGE_VERSION:
sh: bin/envtool{{exeExt}} package-version
packages-rpm-check:
cmds:
- >
docker run --rm --platform=linux/{{.DOCKER_ARCH}} -v ./tmp/rpms:/rpms opensuse/tumbleweed
/bin/sh -c '
rpm --query --info --package /rpms/ferretdb-{{.FILE_SUFFIX}}.rpm &&
rpm --install /rpms/ferretdb-{{.FILE_SUFFIX}}.rpm &&
ferretdb --version
'
requires:
vars: [DOCKER_ARCH, FILE_SUFFIX]
packages-rpm-development:
cmds:
- echo 'rpm-development' > build/version/package.txt
- bin/envtool{{exeExt}} shell rmdir tmp/build
- bin/envtool{{exeExt}} shell mkdir tmp/rpms
- task: docker-build
vars:
FILE: ferretdb/development
TARGET: development-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
- for: [amd64, arm64, arm/v7]
task: packages-build
vars:
PACKAGER: rpm
PACKAGE_VERSION: "{{.PACKAGE_VERSION}}"
PACKAGE_ARCH: '{{replace "/" "" .ITEM | replace "v" ""}}' # arm/v7 -> arm7
DIR_ARCH: '{{replace "/" "_" .ITEM}}' # arm/v7 -> arm_v7
FILE_SUFFIX: 'dev-linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
- for: [amd64, arm64, arm/v7]
task: packages-rpm-check
vars:
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
FILE_SUFFIX: 'dev-linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
vars:
PACKAGE_VERSION:
sh: bin/envtool{{exeExt}} package-version
packages-rpm-production:
cmds:
- echo 'rpm' > build/version/package.txt
- bin/envtool{{exeExt}} shell rmdir tmp/build
- bin/envtool{{exeExt}} shell mkdir tmp/rpms
- task: docker-build
vars:
FILE: ferretdb/production
TARGET: production-binary
PLATFORM: linux/amd64,linux/arm64,linux/arm/v7 # TODO https://github.com/FerretDB/FerretDB/issues/3354
OUTPUT: type=local,dest=tmp/build
- for: [amd64, arm64, arm/v7]
task: packages-build
vars:
PACKAGER: rpm
PACKAGE_VERSION: "{{.PACKAGE_VERSION}}"
PACKAGE_ARCH: '{{replace "/" "" .ITEM | replace "v" ""}}' # arm/v7 -> arm7
DIR_ARCH: '{{replace "/" "_" .ITEM}}' # arm/v7 -> arm_v7
FILE_SUFFIX: 'linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
- for: [amd64, arm64, arm/v7]
task: packages-rpm-check
vars:
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
FILE_SUFFIX: 'linux-{{replace "/" "" .ITEM}}' # arm/v7 -> armv7
vars:
PACKAGE_VERSION:
sh: bin/envtool{{exeExt}} package-version
fmt-yaml:
desc: "Format YAML files"
cmds:
- docker compose run --rm prettier --write --parser=yaml --print-width=120 "**/*.yml"
docs:
desc: "Format, lint and build documentation"
deps: [docs-fmt]
cmds:
- docker compose run --rm docusaurus-docs build
blog:
desc: "Format, lint and build blog"
deps: [docs-fmt]
cmds:
- docker compose run --rm docusaurus-blog build
# see https://github.com/DavidAnson/markdownlint-cli2#command-line for the reason we use double-quotes
docs-fmt:
desc: "Format and lint documentation"
run: once
cmds:
- docker compose run --rm textlint --fix --config build/.textlintrc --ignore-path .prettierignore "**/*.md" ".github/**/*.md"
- docker compose run --rm prettier --write --parser markdown --no-semi --single-quote --trailing-comma none "**/*.md"
- docker compose run --rm markdownlint --config "build/.markdownlint.yml" "**/*.md"
- bin/checkdocs
pngcrush:
cmds:
- pngcrush -ow -brute {{.FILE}}
requires:
vars: [FILE]
pngcrush-new:
cmds:
- git diff --name-only upstream/main '*.png' | parallel "pngcrush -ow -brute {} {.}.temp"
pngcrush-all:
cmds:
- find . -type f -name '*.png' | parallel "pngcrush -ow -brute {} {.}.temp"
docs-dev:
desc: "Start documentation development server"
cmds:
- docker compose run --rm --service-ports docusaurus-docs start --host=0.0.0.0
docs-version:
desc: "Create new documentation version"
cmds:
- docker compose run --rm docusaurus-docs docs:version v{{.VERSION}}
requires:
vars: [VERSION]
docs-cloudflare-preview:
cmds:
# for debugging
- >
docker compose run --rm
--entrypoint='/bin/sh -c "git config --global --add safe.directory /workdir && git status"'
wrangler
- docker compose run --rm --service-ports wrangler pages deployment create --project-name=docs website/build
blog-dev:
desc: "Start blog development server"
cmds:
- docker compose run --rm --service-ports docusaurus-blog start --host=0.0.0.0 --port=3001
blog-cloudflare-preview:
cmds:
# for debugging
- >
docker compose run --rm
--entrypoint='/bin/sh -c "git config --global --add safe.directory /workdir && git status"'
wrangler
- docker compose run --rm --service-ports wrangler pages deployment create --project-name=blog website/build
changelog:
desc: "Generate changelogs locally for a given milestone."
cmds:
- bin/generatechangelog -milestone={{.MILESTONE_TITLE}} -previous={{.PREVIOUS_MILESTONE_TITLE}}
requires:
vars: [MILESTONE_TITLE, PREVIOUS_MILESTONE_TITLE]