-
Notifications
You must be signed in to change notification settings - Fork 706
Expand file tree
/
Copy pathTaskfile.yml
More file actions
198 lines (166 loc) · 5.72 KB
/
Taskfile.yml
File metadata and controls
198 lines (166 loc) · 5.72 KB
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
version: '3'
vars:
BUILD_MODE: '{{.BUILD_MODE | default "dev"}}'
PG_VERSION: 18
POSTGRES_SOURCE: "cpp/.ext/postgres-REL_{{.PG_VERSION}}_0"
POSTGRES_INSTALL: "{{.POSTGRES_SOURCE}}/install"
POSTGRES_DATA: "{{.POSTGRES_SOURCE}}/data"
POSTGRES_LOG: "postgres/tests/taskfile_server.log"
BUILD_DIR: "builds/deeplake-pg-{{.BUILD_MODE}}"
USER:
sh: echo ${USER:-postgres}
tasks:
build:
desc: "Build the pg_deeplake PostgreSQL extension (incremental)"
cmds:
- python3 scripts/build_pg_ext.py
"build:dev":
desc: "Full build in dev mode"
cmds:
- python3 scripts/build_pg_ext.py dev
"build:prod":
desc: "Full build in production mode"
cmds:
- python3 scripts/build_pg_ext.py prod
"build:debug":
desc: "Full build in debug mode"
cmds:
- python3 scripts/build_pg_ext.py debug
lint:
desc: "Run clang-tidy linter on cpp/deeplake_pg"
deps:
- build
cmds:
- bash scripts/run_clang_tidy.sh {{.BUILD_DIR}}
"lint:file":
desc: "Run clang-tidy on a specific file"
dir: cpp/deeplake_pg
cmds:
- |
if [ -z "{{.FILE}}" ]; then
echo "Error: Please specify FILE parameter"
echo "Usage: task lint:file FILE=table_am.cpp"
exit 1
fi
clang-tidy -p "../../{{.BUILD_DIR}}" "{{.FILE}}"
test:
desc: "Run PostgreSQL extension tests (Python pytest)"
dir: postgres/tests/py_tests
cmds:
- pytest -v {{.CLI_ARGS}}
"test:parallel":
desc: "Run tests in parallel using pytest-xdist"
dir: postgres/tests/py_tests
cmds:
- pytest -v -n auto {{.CLI_ARGS}}
"test:coverage":
desc: "Run tests with coverage report"
dir: postgres/tests/py_tests
cmds:
- pytest -v --cov=. --cov-report=html --cov-report=term {{.CLI_ARGS}}
- echo "Coverage report generated in postgres/tests/py_tests/htmlcov/index.html"
"test:single":
desc: "Run a single test file"
dir: postgres/tests/py_tests
cmds:
- |
if [ -z "{{.TEST}}" ]; then
echo "Error: Please specify TEST parameter"
echo "Usage: task test:single TEST=test_basic_ops.py"
exit 1
fi
pytest -v "{{.TEST}}" {{.CLI_ARGS}}
run:
desc: "Start PostgreSQL server with pg_deeplake extension loaded"
deps:
- build
cmds:
- |
echo "Starting PostgreSQL server with pg_deeplake extension..."
PG_CTL="{{.POSTGRES_INSTALL}}/bin/pg_ctl"
INITDB="{{.POSTGRES_INSTALL}}/bin/initdb"
PSQL="{{.POSTGRES_INSTALL}}/bin/psql"
DATA_DIR="{{.POSTGRES_DATA}}"
INSTALL_DIR="{{.POSTGRES_INSTALL}}"
LOG_FILE="{{.POSTGRES_LOG}}"
if [ -f "$DATA_DIR/postmaster.pid" ]; then
echo "PostgreSQL server appears to be running. Use 'task stop' to stop it first."
exit 1
fi
if [ ! -d "$DATA_DIR" ]; then
echo "Initializing PostgreSQL database cluster..."
"$INITDB" -D "$DATA_DIR" -U "{{.USER}}"
echo "shared_preload_libraries = 'pg_deeplake'" >> "$DATA_DIR/postgresql.conf"
echo "max_connections = 100" >> "$DATA_DIR/postgresql.conf"
fi
echo "Installing pg_deeplake extension files..."
EXT_DIR="$INSTALL_DIR/share/extension"
LIB_DIR="$INSTALL_DIR/lib"
mkdir -p "$EXT_DIR"
cp postgres/*.control "$EXT_DIR/" 2>/dev/null || true
cp postgres/*.sql "$EXT_DIR/" 2>/dev/null || grep -v "utils.psql" || true
cp postgres/pg_deeplake_{{.PG_VERSION}}.so "$LIB_DIR/pg_deeplake.so" 2>/dev/null || true
export LD_LIBRARY_PATH="$LIB_DIR:${LD_LIBRARY_PATH:-}"
echo "Starting PostgreSQL server..."
"$PG_CTL" -D "$DATA_DIR" -l "$LOG_FILE" start
sleep 2
echo "Creating pg_deeplake extension..."
"$PSQL" -U "{{.USER}}" -d postgres -c "CREATE EXTENSION IF NOT EXISTS pg_deeplake;"
echo ""
echo "✓ PostgreSQL server is running with pg_deeplake extension loaded"
echo ""
echo "Connection details:"
echo " Host: localhost"
echo " Database: postgres"
echo " User: {{.USER}}"
echo ""
echo "Connect with: psql -U {{.USER}} -d postgres"
echo "Stop server with: task stop"
echo "View logs: tail -f {{.POSTGRES_LOG}}"
stop:
desc: "Stop the PostgreSQL server"
cmds:
- |
PG_CTL="{{.POSTGRES_INSTALL}}/bin/pg_ctl"
DATA_DIR="{{.POSTGRES_DATA}}"
if [ ! -f "$DATA_DIR/postmaster.pid" ]; then
echo "PostgreSQL server is not running"
exit 0
fi
echo "Stopping PostgreSQL server..."
"$PG_CTL" -D "$DATA_DIR" stop -m fast
echo "✓ PostgreSQL server stopped"
status:
desc: "Check PostgreSQL server status"
cmds:
- |
PG_CTL="{{.POSTGRES_INSTALL}}/bin/pg_ctl"
DATA_DIR="{{.POSTGRES_DATA}}"
"$PG_CTL" -D "$DATA_DIR" status || echo "PostgreSQL server is not running"
clean:
desc: "Clean build artifacts and test outputs"
cmds:
- rm -rf builds/
- rm -rf postgres/tests/logs/*
- rm -rf postgres/tests/results/*
- rm -rf postgres/tests/py_tests/htmlcov/
- rm -rf postgres/tests/py_tests/.pytest_cache/
- rm -rf postgres/tests/py_tests/.coverage
- find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true
- echo "✓ Cleaned build artifacts and test outputs"
"clean:db":
desc: "Clean PostgreSQL data directory"
cmds:
- task: stop
- rm -rf "{{.POSTGRES_DATA}}"
- echo "✓ PostgreSQL data directory cleaned"
dev:
desc: "Full development workflow (build, lint, test)"
cmds:
- task: build
- task: lint
- task: test
help:
desc: "Show available tasks"
cmds:
- task --list