加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Taskfile.yml 30.00 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930
---
version: 3
env:
GORACE: halt_on_error=1,history_size=2
GOCOVERDIR: tmp/cover
vars:
SHARD_INDEX: 1
SHARD_TOTAL: 1
DISABLE_PUSHDOWN: false
TEST_RUN: ""
TEST_TIMEOUT: 35m
BENCH_TIME: 5s
FUZZ_TIME: 15s
FUZZ_CORPUS: ../fuzz-corpus
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
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=../build/certs/client.pem&tlsCaFile=../build/certs/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=../build/certs/client.pem&tlsCaFile=../build/certs/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=../build/certs/client.pem&tlsCaFile=../build/certs/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=../build/certs/client.pem&tlsCaFile=../build/certs/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=../build/certs/client.pem&tlsCaFile=../build/certs/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
# That's not quite correct: https://github.com/golang/go/issues/15513
# But good enough for us.
fuzz-init:
deps: [gen-version]
cmds:
- go test -count=0 ./...
fuzz:
desc: "Fuzz for about 1 minute (with default FUZZ_TIME)"
cmds:
- go test -list='Fuzz.*' ./...
- go test -run=XXX -fuzz=FuzzDocument -fuzztime={{.FUZZ_TIME}} ./internal/bson/
- go test -run=XXX -fuzz=FuzzMsg -fuzztime={{.FUZZ_TIME}} ./internal/wire/
- go test -run=XXX -fuzz=FuzzQuery -fuzztime={{.FUZZ_TIME}} ./internal/wire/
- go test -run=XXX -fuzz=FuzzReply -fuzztime={{.FUZZ_TIME}} ./internal/wire/
fuzz-corpus:
desc: "Sync seed and generated fuzz corpora with FUZZ_CORPUS"
deps: [gen-version]
cmds:
- bin/envtool{{exeExt}} fuzz corpus generated {{.FUZZ_CORPUS}}
- bin/envtool{{exeExt}} fuzz corpus seed {{.FUZZ_CORPUS}}
- bin/envtool{{exeExt}} fuzz corpus {{.FUZZ_CORPUS}} generated
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
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 ./...
- 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:
DOCKER_IMAGES: ferretdb-local
OUTPUT: type=docker
TARGET: "{{.FILE}}"
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-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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化