/
Taskfile.yaml
138 lines (120 loc) · 3.75 KB
/
Taskfile.yaml
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
---
version: "3"
vars:
DB: ""
TEST: ""
PARALLEL: 0
tasks:
init-tools:
dir: tools
cmds:
- go mod tidy
- go mod verify
- go generate -x
init:
desc: "Install development tools"
deps: [init-tools]
cmds:
- go mod tidy
- go mod verify
fmt:
desc: "Format code"
cmds:
- bin/gofumpt -w ./cmd/ ./internal/
env-up:
desc: "Start environment"
deps: [env-up-detach]
cmds:
- docker compose logs --follow
env-up-detach:
desc: "Start dependencies in docker"
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 up --always-recreate-deps --force-recreate --remove-orphans --renew-anon-volumes -t 0 --detach
--build {{.DB}}
- task: init-repl
- task: init-user
preconditions:
- sh: "test {{.DB}}"
msg: "Please set DB variable to one of `postgresql`, `sqlite`, or `mongodb`"
env-pull:
cmds:
- docker compose build --pull
env-logs:
cmds:
- docker compose ps --all
- docker compose logs --follow
env-logs-collect:
cmds:
- docker compose ps --all
- docker compose logs
env-down:
desc: "Stop environment"
cmds:
- docker compose down --remove-orphans --volumes
dance:
desc: "Run all integration tests"
dir: tests
cmds:
- go run ../cmd/dance -db={{.DB}} -p={{.PARALLEL}} {{.TEST}}
preconditions:
- sh: "test {{.DB}}"
msg: "Please set DB variable to one of `postgresql`, `sqlite`, or `mongodb`"
lint:
desc: "Run linters"
cmds:
- >
bin/golangci-lint run --config=.golangci.yml
./cmd/... ./internal/... ./tests/mongo-tools/...
- >
bin/golangci-lint run --config=.golangci-new.yml
./cmd/... ./internal/... ./tests/mongo-tools/...
- >
bin/go-consistent -pedantic
./cmd/... ./internal/... ./tests/mongo-tools/...
psql:
desc: "Run psql"
cmds:
- docker compose exec postgres psql -U postgres -d ferretdb
mongo:
desc: "Run legacy MongoDB shell (`mongo`) with test script"
cmds:
- >
docker compose run --rm mongo
'mongodb://host.docker.internal:27017/'
{{.CLI_ARGS}}
mongosh:
desc: "Run mongo shell"
cmds:
- >
docker compose run --rm mongosh mongosh
'mongodb://host.docker.internal:27017/'
--eval 'disableTelemetry()' --shell
init-repl:
desc: "Initializes a new replica set"
cmds:
- >
docker compose run --rm mongosh mongosh
'mongodb://host.docker.internal:27017/'
--verbose --eval 'rs.initiate({_id: "rs0", members: [{_id: 0, host: "localhost"}]})'
# ignore already initialized error and no such command error for replSetInitiate
ignore_error: true
# creates a user similar to MONGO_INITDB_ROOT_USERNAME but does not enable authentication
# https://github.com/docker-library/mongo/blob/master/7.0/docker-entrypoint.sh#L260
init-user:
desc: "Creates a user with the root access role"
cmds:
- >
docker compose run --rm mongosh mongosh
'mongodb://host.docker.internal:27017/'
--verbose --eval 'db.getSiblingDB("admin").createUser({user: "user", pwd: "password", roles: [ "root" ]})'
# ignore roles that are not implemented yet
ignore_error: true
# see https://github.com/DavidAnson/markdownlint-cli2#command-line for the reason we use double-quotes
docs-fmt:
desc: "Format and lint documentation"
cmds:
- docker compose run --rm textlint --fix --rule one-sentence-per-line "**/*.md" ".github/**/*.md"
- docker compose run --rm markdownlint "**/*.md" "#dumps" "#tests"