|
| 1 | +version: '3' |
| 2 | + |
| 3 | +vars: |
| 4 | + BUILD_MODE: '{{.BUILD_MODE | default "dev"}}' |
| 5 | + PG_VERSION: 18 |
| 6 | + POSTGRES_SOURCE: "cpp/.ext/postgres-REL_{{.PG_VERSION}}_0" |
| 7 | + POSTGRES_INSTALL: "{{.POSTGRES_SOURCE}}/install" |
| 8 | + POSTGRES_DATA: "{{.POSTGRES_SOURCE}}/data" |
| 9 | + POSTGRES_LOG: "postgres/tests/taskfile_server.log" |
| 10 | + BUILD_DIR: "builds/deeplake-pg-{{.BUILD_MODE}}" |
| 11 | + USER: |
| 12 | + sh: echo ${USER:-postgres} |
| 13 | + |
| 14 | +tasks: |
| 15 | + build: |
| 16 | + desc: "Build the pg_deeplake PostgreSQL extension (incremental)" |
| 17 | + cmds: |
| 18 | + - python3 scripts/build_pg_ext.py |
| 19 | + |
| 20 | + "build:dev": |
| 21 | + desc: "Full build in dev mode" |
| 22 | + cmds: |
| 23 | + - python3 scripts/build_pg_ext.py dev |
| 24 | + |
| 25 | + "build:prod": |
| 26 | + desc: "Full build in production mode" |
| 27 | + cmds: |
| 28 | + - python3 scripts/build_pg_ext.py prod |
| 29 | + |
| 30 | + "build:debug": |
| 31 | + desc: "Full build in debug mode" |
| 32 | + cmds: |
| 33 | + - python3 scripts/build_pg_ext.py debug |
| 34 | + |
| 35 | + lint: |
| 36 | + desc: "Run clang-tidy linter on cpp/deeplake_pg" |
| 37 | + deps: |
| 38 | + - build |
| 39 | + cmds: |
| 40 | + - bash scripts/run_clang_tidy.sh {{.BUILD_DIR}} |
| 41 | + |
| 42 | + "lint:file": |
| 43 | + desc: "Run clang-tidy on a specific file" |
| 44 | + dir: cpp/deeplake_pg |
| 45 | + cmds: |
| 46 | + - | |
| 47 | + if [ -z "{{.FILE}}" ]; then |
| 48 | + echo "Error: Please specify FILE parameter" |
| 49 | + echo "Usage: task lint:file FILE=table_am.cpp" |
| 50 | + exit 1 |
| 51 | + fi |
| 52 | + clang-tidy -p "../../{{.BUILD_DIR}}" "{{.FILE}}" |
| 53 | +
|
| 54 | + test: |
| 55 | + desc: "Run PostgreSQL extension tests (Python pytest)" |
| 56 | + dir: postgres/tests/py_tests |
| 57 | + cmds: |
| 58 | + - pytest -v {{.CLI_ARGS}} |
| 59 | + |
| 60 | + "test:parallel": |
| 61 | + desc: "Run tests in parallel using pytest-xdist" |
| 62 | + dir: postgres/tests/py_tests |
| 63 | + cmds: |
| 64 | + - pytest -v -n auto {{.CLI_ARGS}} |
| 65 | + |
| 66 | + "test:coverage": |
| 67 | + desc: "Run tests with coverage report" |
| 68 | + dir: postgres/tests/py_tests |
| 69 | + cmds: |
| 70 | + - pytest -v --cov=. --cov-report=html --cov-report=term {{.CLI_ARGS}} |
| 71 | + - echo "Coverage report generated in postgres/tests/py_tests/htmlcov/index.html" |
| 72 | + |
| 73 | + "test:single": |
| 74 | + desc: "Run a single test file" |
| 75 | + dir: postgres/tests/py_tests |
| 76 | + cmds: |
| 77 | + - | |
| 78 | + if [ -z "{{.TEST}}" ]; then |
| 79 | + echo "Error: Please specify TEST parameter" |
| 80 | + echo "Usage: task test:single TEST=test_basic_ops.py" |
| 81 | + exit 1 |
| 82 | + fi |
| 83 | + pytest -v "{{.TEST}}" {{.CLI_ARGS}} |
| 84 | +
|
| 85 | + run: |
| 86 | + desc: "Start PostgreSQL server with pg_deeplake extension loaded" |
| 87 | + deps: |
| 88 | + - build |
| 89 | + cmds: |
| 90 | + - | |
| 91 | + echo "Starting PostgreSQL server with pg_deeplake extension..." |
| 92 | +
|
| 93 | + PG_CTL="{{.POSTGRES_INSTALL}}/bin/pg_ctl" |
| 94 | + INITDB="{{.POSTGRES_INSTALL}}/bin/initdb" |
| 95 | + PSQL="{{.POSTGRES_INSTALL}}/bin/psql" |
| 96 | + DATA_DIR="{{.POSTGRES_DATA}}" |
| 97 | + INSTALL_DIR="{{.POSTGRES_INSTALL}}" |
| 98 | + LOG_FILE="{{.POSTGRES_LOG}}" |
| 99 | +
|
| 100 | + if [ -f "$DATA_DIR/postmaster.pid" ]; then |
| 101 | + echo "PostgreSQL server appears to be running. Use 'task stop' to stop it first." |
| 102 | + exit 1 |
| 103 | + fi |
| 104 | +
|
| 105 | + if [ ! -d "$DATA_DIR" ]; then |
| 106 | + echo "Initializing PostgreSQL database cluster..." |
| 107 | + "$INITDB" -D "$DATA_DIR" -U "{{.USER}}" |
| 108 | +
|
| 109 | + echo "shared_preload_libraries = 'pg_deeplake'" >> "$DATA_DIR/postgresql.conf" |
| 110 | + echo "max_connections = 100" >> "$DATA_DIR/postgresql.conf" |
| 111 | + fi |
| 112 | +
|
| 113 | + echo "Installing pg_deeplake extension files..." |
| 114 | + EXT_DIR="$INSTALL_DIR/share/extension" |
| 115 | + LIB_DIR="$INSTALL_DIR/lib" |
| 116 | + mkdir -p "$EXT_DIR" |
| 117 | +
|
| 118 | + cp postgres/*.control "$EXT_DIR/" 2>/dev/null || true |
| 119 | + cp postgres/*.sql "$EXT_DIR/" 2>/dev/null || grep -v "utils.psql" || true |
| 120 | + cp postgres/pg_deeplake_{{.PG_VERSION}}.so "$LIB_DIR/pg_deeplake.so" 2>/dev/null || true |
| 121 | +
|
| 122 | + export LD_LIBRARY_PATH="$LIB_DIR:${LD_LIBRARY_PATH:-}" |
| 123 | +
|
| 124 | + echo "Starting PostgreSQL server..." |
| 125 | + "$PG_CTL" -D "$DATA_DIR" -l "$LOG_FILE" start |
| 126 | +
|
| 127 | + sleep 2 |
| 128 | +
|
| 129 | + echo "Creating pg_deeplake extension..." |
| 130 | + "$PSQL" -U "{{.USER}}" -d postgres -c "CREATE EXTENSION IF NOT EXISTS pg_deeplake;" |
| 131 | +
|
| 132 | + echo "" |
| 133 | + echo "✓ PostgreSQL server is running with pg_deeplake extension loaded" |
| 134 | + echo "" |
| 135 | + echo "Connection details:" |
| 136 | + echo " Host: localhost" |
| 137 | + echo " Database: postgres" |
| 138 | + echo " User: {{.USER}}" |
| 139 | + echo "" |
| 140 | + echo "Connect with: psql -U {{.USER}} -d postgres" |
| 141 | + echo "Stop server with: task stop" |
| 142 | + echo "View logs: tail -f {{.POSTGRES_LOG}}" |
| 143 | +
|
| 144 | + stop: |
| 145 | + desc: "Stop the PostgreSQL server" |
| 146 | + cmds: |
| 147 | + - | |
| 148 | + PG_CTL="{{.POSTGRES_INSTALL}}/bin/pg_ctl" |
| 149 | + DATA_DIR="{{.POSTGRES_DATA}}" |
| 150 | +
|
| 151 | + if [ ! -f "$DATA_DIR/postmaster.pid" ]; then |
| 152 | + echo "PostgreSQL server is not running" |
| 153 | + exit 0 |
| 154 | + fi |
| 155 | +
|
| 156 | + echo "Stopping PostgreSQL server..." |
| 157 | + "$PG_CTL" -D "$DATA_DIR" stop -m fast |
| 158 | + echo "✓ PostgreSQL server stopped" |
| 159 | +
|
| 160 | + status: |
| 161 | + desc: "Check PostgreSQL server status" |
| 162 | + cmds: |
| 163 | + - | |
| 164 | + PG_CTL="{{.POSTGRES_INSTALL}}/bin/pg_ctl" |
| 165 | + DATA_DIR="{{.POSTGRES_DATA}}" |
| 166 | +
|
| 167 | + "$PG_CTL" -D "$DATA_DIR" status || echo "PostgreSQL server is not running" |
| 168 | +
|
| 169 | + clean: |
| 170 | + desc: "Clean build artifacts and test outputs" |
| 171 | + cmds: |
| 172 | + - rm -rf builds/ |
| 173 | + - rm -rf postgres/tests/logs/* |
| 174 | + - rm -rf postgres/tests/results/* |
| 175 | + - rm -rf postgres/tests/py_tests/htmlcov/ |
| 176 | + - rm -rf postgres/tests/py_tests/.pytest_cache/ |
| 177 | + - rm -rf postgres/tests/py_tests/.coverage |
| 178 | + - find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null || true |
| 179 | + - echo "✓ Cleaned build artifacts and test outputs" |
| 180 | + |
| 181 | + "clean:db": |
| 182 | + desc: "Clean PostgreSQL data directory" |
| 183 | + cmds: |
| 184 | + - task: stop |
| 185 | + - rm -rf "{{.POSTGRES_DATA}}" |
| 186 | + - echo "✓ PostgreSQL data directory cleaned" |
| 187 | + |
| 188 | + dev: |
| 189 | + desc: "Full development workflow (build, lint, test)" |
| 190 | + cmds: |
| 191 | + - task: build |
| 192 | + - task: lint |
| 193 | + - task: test |
| 194 | + |
| 195 | + help: |
| 196 | + desc: "Show available tasks" |
| 197 | + cmds: |
| 198 | + - task --list |
0 commit comments