代码拉取完成,页面将自动刷新
---
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
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。