mirror of
https://github.com/hanzoai/docdb.git
synced 2026-10-30 18:39:39 +00:00
944 lines
30 KiB
YAML
944 lines
30 KiB
YAML
---
|
|
version: 3
|
|
|
|
env:
|
|
GORACE: halt_on_error=1,history_size=2
|
|
GOCOVERDIR: tmp/cover
|
|
|
|
vars:
|
|
SHARD_INDEX: 0
|
|
SHARD_TOTAL: 0
|
|
TEST_RUN: ""
|
|
TEST_TIMEOUT: 35m
|
|
NO_XFAIL: false
|
|
BENCH_TIME: 5s
|
|
TESTJS_PORT: 27017
|
|
RACE_FLAG: -race={{and (ne OS "windows") (ne ARCH "arm") (ne ARCH "riscv64")}}
|
|
BUILD_TAGS: docdb_dev
|
|
MODE: diff-normal
|
|
SERVICES: jaeger mongodb mongodb-secure postgres yugabytedb
|
|
LLM: qwen3:0.6b # sync with code
|
|
LLM_CONTEXT: 40960 # https://ollama.com/library/qwen3:0.6b
|
|
|
|
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: 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-tools-mcphost:
|
|
dir: tools/mcphost
|
|
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-tools-mcphost, 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-logs-collect:
|
|
desc: "Collect logs from Docker and save them to tmp/logs"
|
|
cmds:
|
|
- bin/envtool{{exeExt}} shell mkdir tmp/logs
|
|
- docker compose ps --all > tmp/logs/compose-ps.txt
|
|
- docker compose logs > tmp/logs/compose-logs.txt
|
|
- docker compose exec yugabytedb sh -c "bin/yugabyted collect_logs --stdout | gunzip | tar -xf - --one-top-level=/tmp/logs"
|
|
- docker compose cp yugabytedb:/tmp/logs tmp/logs/yugabytedb
|
|
|
|
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/docdb{{exeExt}} on the host for development"
|
|
run: once
|
|
deps: [gen-version]
|
|
cmds:
|
|
- echo 'build-host' > build/version/package.txt
|
|
- go build -v -o=bin/docdb{{exeExt}} {{.RACE_FLAG}} -tags={{.BUILD_TAGS}} -coverpkg=./... ./cmd/docdb
|
|
- bin/envtool{{exeExt}} shell mkdir tmp/cover
|
|
|
|
gen:
|
|
desc: "Generate (and format) Go code"
|
|
cmds:
|
|
- go generate -x ./...
|
|
#- bin/deadcode{{exeExt}} -generated -test -filter=documentdb_api ./cmd/docdb
|
|
- bin/task{{exeExt}} -d integration integration-gen
|
|
- task: fmt-go
|
|
|
|
fmt:
|
|
deps: [fmt-go]
|
|
|
|
# invoked by DocDB/github-actions/linters action
|
|
fmt-go:
|
|
desc: "Format Go code"
|
|
cmds:
|
|
- bin/goimports{{exeExt}} -local=github.com/hanzoai/docdb/v2 -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 -c -o /dev/null ./...
|
|
- go test -short -timeout={{.TEST_TIMEOUT}} {{.RACE_FLAG}} -tags={{.BUILD_TAGS}} -shuffle=on -coverprofile=cover.txt ./...
|
|
- bin/task{{exeExt}} -d tools tools-test-short
|
|
|
|
test-unit:
|
|
desc: "Run all unit tests"
|
|
cmds:
|
|
- go test -c -o /dev/null ./...
|
|
- go test -v -count=1 -timeout={{.TEST_TIMEOUT}} {{.RACE_FLAG}} -tags={{.BUILD_TAGS}} -shuffle=on -coverprofile=cover.txt ./... | tee unit.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-build:
|
|
run: once
|
|
dir: integration
|
|
cmd: go test -c -o /dev/null ./...
|
|
|
|
test-integration:
|
|
desc: "Run integration tests in parallel"
|
|
deps: [test-integration-postgresql, test-integration-mongodb]
|
|
|
|
test-integration-postgresql:
|
|
desc: "Run integration tests for PostgreSQL/DocumentDB"
|
|
deps: [gen-version, test-integration-build]
|
|
dir: integration
|
|
cmds:
|
|
- >
|
|
../bin/envtool{{exeExt}} tests run
|
|
--shard-index={{.SHARD_INDEX}}
|
|
--shard-total={{.SHARD_TOTAL}}
|
|
--run='{{.TEST_RUN}}'
|
|
--skip='{{.TEST_SKIP}}'
|
|
--raw-prefix=postgresql-{{.SHARD_INDEX}}-{{.SHARD_TOTAL}}
|
|
--
|
|
-count=1
|
|
-timeout={{.TEST_TIMEOUT}}
|
|
{{.RACE_FLAG}}
|
|
-tags={{.BUILD_TAGS}}
|
|
-shuffle=on
|
|
-coverpkg=../...
|
|
-coverprofile=integration-postgresql.txt
|
|
./...
|
|
-target-backend=docdb
|
|
-postgresql-url='postgres://username:[email protected]:5432/postgres'
|
|
-compat-url='mongodb://username:[email protected]:47017/?replicaSet=rs0'
|
|
-no-xfail={{.NO_XFAIL}}
|
|
|
|
test-integration-mongodb:
|
|
desc: "Run integration tests for MongoDB"
|
|
deps: [gen-version, test-integration-build]
|
|
dir: integration
|
|
cmds:
|
|
- >
|
|
../bin/envtool{{exeExt}} tests run
|
|
--shard-index={{.SHARD_INDEX}}
|
|
--shard-total={{.SHARD_TOTAL}}
|
|
--run='{{.TEST_RUN}}'
|
|
--skip='{{.TEST_SKIP}}'
|
|
--raw-prefix=mongodb-{{.SHARD_INDEX}}-{{.SHARD_TOTAL}}
|
|
--
|
|
-count=1
|
|
-timeout={{.TEST_TIMEOUT}}
|
|
{{.RACE_FLAG}}
|
|
-tags={{.BUILD_TAGS}}
|
|
-shuffle=on
|
|
-coverpkg=../...
|
|
-coverprofile=integration-mongodb.txt
|
|
./...
|
|
-target-url='mongodb://username:[email protected]:47017/?replicaSet=rs0'
|
|
-target-backend=mongodb
|
|
-no-xfail={{.NO_XFAIL}}
|
|
|
|
test-integration-yugabytedb:
|
|
desc: "Run integration tests for DocDB with YugabyteDB sequentially"
|
|
vars:
|
|
# DPanic on InternalError stops execution of remaining tests,
|
|
# ensure to complete all tests by not setting development build tag and without race detector.
|
|
# TODO https://github.com/hanzoai/docdb/issues/5397
|
|
BUILD_TAGS: ""
|
|
RACE_FLAG: -race=false
|
|
deps:
|
|
- task: gen-version
|
|
vars:
|
|
BUILD_TAGS:
|
|
ref: .BUILD_TAGS
|
|
RACE_FLAG:
|
|
ref: .RACE_FLAG
|
|
- task: test-integration-build
|
|
dir: integration
|
|
cmds:
|
|
- >
|
|
../bin/envtool{{exeExt}} tests run
|
|
--shard-index={{.SHARD_INDEX}}
|
|
--shard-total={{.SHARD_TOTAL}}
|
|
--run='{{.TEST_RUN}}'
|
|
--skip='{{.TEST_SKIP}}'
|
|
--raw-prefix=yugabytedb-{{.SHARD_INDEX}}-{{.SHARD_TOTAL}}
|
|
--
|
|
-count=1
|
|
-parallel=1
|
|
-p=1
|
|
-timeout={{.TEST_TIMEOUT}}
|
|
{{.RACE_FLAG}}
|
|
-tags={{.BUILD_TAGS}}
|
|
-shuffle=on
|
|
-coverpkg=../...
|
|
-coverprofile=integration-yugabytedb.txt
|
|
./...
|
|
-target-backend=docdb-yugabytedb
|
|
-postgresql-url='postgres://pg-user:[email protected]:5433/yugabyte'
|
|
-compat-url='mongodb://username:[email protected]:47017/?replicaSet=rs0'
|
|
-no-xfail={{.NO_XFAIL}}
|
|
|
|
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 DocDB without auth"
|
|
deps: [build-host]
|
|
cmds:
|
|
- >
|
|
bin/docdb{{exeExt}}
|
|
--mode={{.MODE}}
|
|
--no-auth
|
|
--listen-addr=:27017
|
|
--listen-data-api-addr=127.0.0.1:8899
|
|
--listen-mcp-addr=127.0.0.1:8081
|
|
--proxy-addr=127.0.0.1:37017
|
|
--postgresql-url='postgres://username:[email protected]:5432/postgres'
|
|
--otel-traces-url=http://127.0.0.1:4318/v1/traces
|
|
--dev-records-dir=tmp/records
|
|
|
|
run-secure:
|
|
desc: "Run DocDB with auth"
|
|
deps: [build-host]
|
|
cmds:
|
|
- >
|
|
bin/docdb{{exeExt}}
|
|
--mode={{.MODE}}
|
|
--listen-addr=:27017
|
|
--listen-data-api-addr=127.0.0.1:8899
|
|
--listen-mcp-addr=127.0.0.1:8081
|
|
--proxy-addr=127.0.0.1:47017
|
|
--postgresql-url='postgres://username:[email protected]:5432/postgres'
|
|
--otel-traces-url=http://127.0.0.1:4318/v1/traces
|
|
--dev-repl-set-name=rs0
|
|
--dev-records-dir=tmp/records
|
|
|
|
run-yugabytedb:
|
|
desc: "Run DocDB with YugabyteDB without auth"
|
|
deps: [build-host]
|
|
cmds:
|
|
- >
|
|
bin/docdb{{exeExt}}
|
|
--mode={{.MODE}}
|
|
--no-auth
|
|
--listen-addr=:27017
|
|
--listen-data-api-addr=127.0.0.1:8899
|
|
--listen-mcp-addr=127.0.0.1:8081
|
|
--proxy-addr=127.0.0.1:37017
|
|
--postgresql-url='postgres://username:[email protected]:5433/yugabyte'
|
|
--otel-traces-url=http://127.0.0.1:4318/v1/traces
|
|
--dev-records-dir=tmp/records
|
|
|
|
run-yugabytedb-secure:
|
|
desc: "Run DocDB with YugabyteDB with auth"
|
|
deps: [build-host]
|
|
cmds:
|
|
- >
|
|
bin/docdb{{exeExt}}
|
|
--mode={{.MODE}}
|
|
--listen-addr=:27017
|
|
--listen-data-api-addr=127.0.0.1:8899
|
|
--listen-mcp-addr=127.0.0.1:8081
|
|
--proxy-addr=127.0.0.1:47017
|
|
--postgresql-url='postgres://username:[email protected]:5433/yugabyte'
|
|
--otel-traces-url=http://127.0.0.1:4318/v1/traces
|
|
--dev-repl-set-name=rs0
|
|
--dev-records-dir=tmp/records
|
|
|
|
# invoked by DocDB/github-actions/linters action
|
|
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/... ./docdb/... ./internal/...
|
|
- 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 --config=./build/trivy.yml filesystem --ignorefile=./build/.trivyignore .
|
|
|
|
godocs:
|
|
desc: "Serve Go code documentation"
|
|
cmds:
|
|
- bin/pkgsite{{exeExt}} -http=127.0.0.1:6060 -open
|
|
|
|
ollama:
|
|
desc: "Run local Ollama server"
|
|
cmds:
|
|
- ollama serve
|
|
env:
|
|
OLLAMA_CONTEXT_LENGTH: "{{.LLM_CONTEXT}}"
|
|
OLLAMA_DEBUG: 2
|
|
|
|
ollama-model:
|
|
desc: "Pull and load Ollama model"
|
|
cmds:
|
|
- ollama pull {{.LLM}}
|
|
- ollama run --think=false {{.LLM}} 'Hi!'
|
|
|
|
mcphost:
|
|
desc: "Run MCPHost for local Ollama server"
|
|
cmds:
|
|
- bin/mcphost --config=build/mcphost.json --model=ollama:{{.LLM}}
|
|
|
|
psql:
|
|
desc: "Run psql"
|
|
cmds:
|
|
- docker compose exec postgres psql -p 5432 -U username -d postgres
|
|
|
|
ysqlsh:
|
|
desc: "Run YugabyteDB SQL shell"
|
|
cmds:
|
|
- docker compose exec yugabytedb ./bin/ysqlsh postgres://username:[email protected]:5433/yugabyte
|
|
|
|
mongosh:
|
|
desc: "Run MongoDB shell (`mongosh`)"
|
|
cmds:
|
|
- >
|
|
docker compose exec mongodb mongosh
|
|
--verbose --eval 'disableTelemetry()' --shell
|
|
'mongodb://host.docker.internal:27017/?heartbeatFrequencyMS=300000'
|
|
|
|
mongosh-secure:
|
|
desc: "Run MongoDB shell (`mongosh`) with auth"
|
|
cmds:
|
|
- >
|
|
docker compose exec mongodb mongosh
|
|
--verbose --eval 'disableTelemetry()' --shell
|
|
'mongodb://username:[email protected]:27017/?heartbeatFrequencyMS=300000'
|
|
|
|
mongo:
|
|
desc: "Run legacy MongoDB shell (`mongo`)"
|
|
cmds:
|
|
- >
|
|
docker compose run --rm legacy-mongo-shell
|
|
'mongodb://username:[email protected]:27017/'
|
|
|
|
testsql:
|
|
desc: "Run pgTAP with test.sql script"
|
|
cmds:
|
|
- docker compose exec postgres pg_prove --ext .sql --verbose -p 5432 -U username -d postgres /testscripts/
|
|
|
|
testjs:
|
|
desc: "Run legacy MongoDB shell (`mongo`) with test.js script"
|
|
cmds:
|
|
# Authentication with username:password will not work
|
|
# because this user is created by setup with a different salt length,
|
|
# and there are no other credentials to use.
|
|
- >
|
|
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=docdb
|
|
--bootstrap=true
|
|
--use=false
|
|
--config=./build/buildkitd.toml
|
|
--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=docdb du
|
|
ignore_error: true
|
|
- cmd: docker buildx --builder=docdb rm --force
|
|
ignore_error: true
|
|
- docker system prune --force
|
|
- docker system df
|
|
|
|
docker-build:
|
|
deps: [gen-version, docker-init]
|
|
cmds:
|
|
- >
|
|
docker buildx build --builder=docdb
|
|
--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}}/docdb 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 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: docdb/development
|
|
TARGET: development-binary
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=local,dest=tmp/build
|
|
- for: [amd64, arm64]
|
|
task: build-move-check
|
|
vars:
|
|
# TODO https://github.com/hanzoai/docdb/issues/5019
|
|
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
|
|
DIR_ARCH: '{{replace "/" "_" .ITEM}}' # arm/v7 -> arm_v7
|
|
BIN_FILE: 'docdb-dev-{{replace "/" "" .ITEM}}-linux' # arm/v7 -> armv7
|
|
BIN_DIR: bin-dev
|
|
|
|
build-production:
|
|
desc: "Build production 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: docdb/production
|
|
TARGET: production-binary
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=local,dest=tmp/build
|
|
- for: [amd64, arm64]
|
|
task: build-move-check
|
|
vars:
|
|
# TODO https://github.com/hanzoai/docdb/issues/5019
|
|
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
|
|
DIR_ARCH: '{{replace "/" "_" .ITEM}}' # arm/v7 -> arm_v7
|
|
BIN_FILE: 'docdb-{{replace "/" "" .ITEM}}-linux' # arm/v7 -> armv7
|
|
BIN_DIR: bin
|
|
|
|
docker-local:
|
|
desc: "Build `docdb-local` Docker image for the host platform"
|
|
cmds:
|
|
- echo 'docker-local-{{.FILE}}' > build/version/package.txt
|
|
- task: docker-build
|
|
vars:
|
|
FILE: docdb/{{.FILE}}
|
|
TARGET: "{{.FILE}}"
|
|
DOCKER_IMAGES: docdb-local
|
|
OUTPUT: type=docker
|
|
requires:
|
|
vars: [FILE]
|
|
|
|
# TODO https://github.com/hanzoai/docdb/issues/2212
|
|
docker-eval-dev-push:
|
|
cmds:
|
|
- echo 'docker-eval-dev' > build/version/package.txt
|
|
- task: docker-build
|
|
vars:
|
|
FILE: docdb/eval-dev
|
|
TARGET: eval-dev
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=image,push=true
|
|
requires:
|
|
vars: [DOCKER_IMAGES]
|
|
|
|
# TODO https://github.com/hanzoai/docdb/issues/2212
|
|
docker-eval-push:
|
|
cmds:
|
|
- echo 'docker-eval' > build/version/package.txt
|
|
- task: docker-build
|
|
vars:
|
|
FILE: docdb/eval
|
|
TARGET: eval
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=image,push=true
|
|
requires:
|
|
vars: [DOCKER_IMAGES]
|
|
|
|
# TODO https://github.com/hanzoai/docdb/issues/2212
|
|
docker-development-push:
|
|
cmds:
|
|
- echo 'docker-development' > build/version/package.txt
|
|
- task: docker-build
|
|
vars:
|
|
FILE: docdb/development
|
|
TARGET: development
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=image,push=true
|
|
requires:
|
|
vars: [DOCKER_IMAGES]
|
|
|
|
# TODO https://github.com/hanzoai/docdb/issues/2212
|
|
docker-production-push:
|
|
cmds:
|
|
- echo 'docker' > build/version/package.txt
|
|
- task: docker-build
|
|
vars:
|
|
FILE: docdb/production
|
|
TARGET: production
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
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/hanzoai/docdb/issues/2172
|
|
|
|
packages-build:
|
|
cmds:
|
|
- >
|
|
bin/nfpm{{exeExt}} package
|
|
--config=build/nfpm.yml
|
|
--packager={{.PACKAGER}}
|
|
--target=tmp/{{.PACKAGER}}s/docdb-{{.FILE_SUFFIX}}.{{.PACKAGER}}
|
|
env:
|
|
# TODO https://github.com/hanzoai/docdb/issues/5019
|
|
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/docdb-{{.FILE_SUFFIX}}.deb &&
|
|
dpkg --install /debs/docdb-{{.FILE_SUFFIX}}.deb &&
|
|
docdb --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: docdb/development
|
|
TARGET: development-binary
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=local,dest=tmp/build
|
|
- for: [amd64, arm64]
|
|
task: packages-build
|
|
vars:
|
|
# TODO https://github.com/hanzoai/docdb/issues/5019
|
|
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-{{replace "/" "" .ITEM}}-linux' # arm/v7 -> armv7
|
|
- for: [amd64, arm64]
|
|
task: packages-deb-check
|
|
vars:
|
|
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
|
|
FILE_SUFFIX: 'dev-{{replace "/" "" .ITEM}}-linux' # 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: docdb/production
|
|
TARGET: production-binary
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=local,dest=tmp/build
|
|
- for: [amd64, arm64]
|
|
task: packages-build
|
|
vars:
|
|
# TODO https://github.com/hanzoai/docdb/issues/5019
|
|
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: '{{replace "/" "" .ITEM}}-linux' # arm/v7 -> armv7
|
|
- for: [amd64, arm64]
|
|
task: packages-deb-check
|
|
vars:
|
|
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
|
|
FILE_SUFFIX: '{{replace "/" "" .ITEM}}-linux' # 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/docdb-{{.FILE_SUFFIX}}.rpm &&
|
|
rpm --install /rpms/docdb-{{.FILE_SUFFIX}}.rpm &&
|
|
docdb --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: docdb/development
|
|
TARGET: development-binary
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=local,dest=tmp/build
|
|
- for: [amd64, arm64]
|
|
task: packages-build
|
|
vars:
|
|
# TODO https://github.com/hanzoai/docdb/issues/5019
|
|
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-{{replace "/" "" .ITEM}}-linux' # arm/v7 -> armv7
|
|
- for: [amd64, arm64]
|
|
task: packages-rpm-check
|
|
vars:
|
|
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
|
|
FILE_SUFFIX: 'dev-{{replace "/" "" .ITEM}}-linux' # 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: docdb/production
|
|
TARGET: production-binary
|
|
PLATFORM: linux/amd64,linux/arm64
|
|
OUTPUT: type=local,dest=tmp/build
|
|
- for: [amd64, arm64]
|
|
task: packages-build
|
|
vars:
|
|
# TODO https://github.com/hanzoai/docdb/issues/5019
|
|
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: '{{replace "/" "" .ITEM}}-linux' # arm/v7 -> armv7
|
|
- for: [amd64, arm64]
|
|
task: packages-rpm-check
|
|
vars:
|
|
DOCKER_ARCH: "{{.ITEM}}" # arm/v7
|
|
FILE_SUFFIX: '{{replace "/" "" .ITEM}}-linux' # arm/v7 -> armv7
|
|
vars:
|
|
PACKAGE_VERSION:
|
|
sh: bin/envtool{{exeExt}} package-version
|
|
|
|
fmt-js:
|
|
desc: "Format JS files"
|
|
cmds:
|
|
- docker compose run --rm prettier --write --print-width 120 "**/*.js"
|
|
|
|
# .js files are also used for mongosh output snippets
|
|
# (with added `response = ` to make them valid JavaScript).
|
|
# The formatting of quotes, commas and semicolons should not be modified.
|
|
# Flags are set to ensure that.
|
|
- >
|
|
docker compose run --rm prettier --write --single-quote --trailing-comma none --no-semi
|
|
--print-width 120 "website/*docs/**/*.js"
|
|
|
|
fmt-json:
|
|
desc: "Format JSON files"
|
|
cmds:
|
|
- docker compose run --rm prettier --write --print-width 120 "**/*.json"
|
|
|
|
fmt-yaml:
|
|
desc: "Format YAML files"
|
|
cmds:
|
|
- docker compose run --rm prettier --write --print-width 120 "**/*.yml"
|
|
|
|
# See https://github.com/DavidAnson/markdownlint-cli2#command-line for the reason we use double quotes in command.
|
|
fmt-docs:
|
|
desc: "Format and lint documentation"
|
|
deps: [gen-version, fmt-js, fmt-json, fmt-yaml]
|
|
run: once
|
|
cmds:
|
|
- >
|
|
docker compose run --rm textlint --fix --config build/.textlintrc --ignore-path .prettierignore
|
|
"**/*.md" "**/*.mdx" ".github/**/*.md"
|
|
|
|
# Use the same flags as in fmt-js for mongosh snippets above.
|
|
#
|
|
# Note that embedded code snippets in ``` Markdown blocks are not reformatted if they can't be parsed.
|
|
# Ensure that the code is valid and can be parsed by changing formatting manually
|
|
# and running this task again, checking that formatting changes.
|
|
#
|
|
# TODO --print-width 120 (https://github.com/hanzoai/docdb/issues/4636)
|
|
- >
|
|
docker compose run --rm prettier --write --single-quote --trailing-comma none --no-semi
|
|
"**/*.md" "**/*.mdx"
|
|
|
|
- >
|
|
docker compose run --rm markdownlint --config "build/.markdownlint.yml"
|
|
"**/*.md" "**/*.mdx" "#build/postgres-documentdb/documentdb/"
|
|
- bin/envtool{{exeExt}} shell rmdir tmp/githubcache
|
|
- bin/envtool{{exeExt}} shell mkdir tmp/githubcache
|
|
- bin/checkdocs
|
|
|
|
docs-fmt:
|
|
deps: [fmt-docs]
|
|
|
|
docs-gen:
|
|
desc: "Generate documentation examples using CTS tool"
|
|
cmds:
|
|
- bin/opendocdb-cts fmt --dir=website/docs/guides
|
|
- bin/opendocdb-cts convert --dir=website/docs/guides website/docs/guides --db=db
|
|
- task: fmt-docs
|
|
|
|
cts:
|
|
desc: "Run CTS tests against DocDB"
|
|
cmds:
|
|
- bin/opendocdb-cts run --dir=website/docs/guides --uri=mongodb://127.0.0.1:27017/cts
|
|
|
|
docs:
|
|
desc: "Format, lint and build documentation"
|
|
deps: [docs-gen]
|
|
cmds:
|
|
- docker compose run --rm docusaurus-docs build
|
|
|
|
blog:
|
|
desc: "Format, lint and build blog"
|
|
deps: [fmt-docs]
|
|
cmds:
|
|
- docker compose run --rm docusaurus-blog build
|
|
|
|
pngcrush:
|
|
cmds:
|
|
- pngcrush -ow -brute -rem text {{.FILE}}
|
|
requires:
|
|
vars: [FILE]
|
|
|
|
pngcrush-new:
|
|
cmds:
|
|
- git diff --name-only upstream/main '*.png' | parallel "pngcrush -ow -brute -rem text {} {.}.temp"
|
|
|
|
pngcrush-all:
|
|
cmds:
|
|
- find . -type f -name '*.png' | parallel "pngcrush -ow -brute -rem text {} {.}.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 changelog"
|
|
cmds:
|
|
- bin/generatechangelog -prev={{.PREV}} -next={{.NEXT}}
|
|
requires:
|
|
vars: [PREV, NEXT]
|