Skip to content

Commit

Permalink
Simplify make tasks and configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelff committed Nov 22, 2023
1 parent eae099c commit c689fe6
Show file tree
Hide file tree
Showing 12 changed files with 74 additions and 74 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/query-engine-driver-adapters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ jobs:
matrix:
adapter:
- name: 'planetscale'
setup_task: 'dev-planetscale-vitess8'
setup_task: 'dev-planetscale-js'
- name: 'pg (napi)'
setup_task: 'dev-pg-postgres13'
setup_task: 'dev-pg-js'
- name: 'neon:ws (napi)'
setup_task: 'dev-neon-ws-postgres13'
setup_task: 'dev-neon-js'
- name: 'libsql (napi)'
setup_task: 'dev-libsql-sqlite'
setup_task: 'dev-libsql-js'
# TODO: uncomment when WASM engine is functional
# - name: 'pg (wasm)'
# setup_task: 'dev-pg-postgres13-wasm'
# setup_task: 'dev-pg-wasm'
# needs_wasm_pack: true
# - name: 'neon:ws (wasm)'
# setup_task: 'dev-neon-ws-postgres13-wasm'
# setup_task: 'dev-neon-wasm'
# needs_wasm_pack: true
# - name: 'libsql (wasm)'
# setup_task: 'dev-libsql-sqlite-wasm'
# setup_task: 'dev-libsql-wasm'
# needs_wasm_pack: true
node_version: ['18']
env:
Expand Down
95 changes: 42 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ start-sqlite:
dev-sqlite:
cp $(CONFIG_PATH)/sqlite $(CONFIG_FILE)

dev-libsql-sqlite: build-qe-napi build-connector-kit-js
cp $(CONFIG_PATH)/libsql-sqlite $(CONFIG_FILE)
dev-libsql-js: build-qe-napi build-connector-kit-js
cp $(CONFIG_PATH)/libsql-js $(CONFIG_FILE)

test-libsql-sqlite: dev-libsql-sqlite test-qe-st
test-libsql-js: dev-libsql-js test-qe-st

test-driver-adapter-libsql: test-libsql-sqlite
test-driver-adapter-libsql: test-libsql-js

dev-libsql-sqlite-wasm: build-qe-wasm build-connector-kit-js
cp $(CONFIG_PATH)/libsql-sqlite-wasm $(CONFIG_FILE)
dev-libsql-wasm: build-qe-wasm build-connector-kit-js
cp $(CONFIG_PATH)/libsql-wasm $(CONFIG_FILE)

test-libsql-sqlite-wasm: dev-libsql-sqlite-wasm test-qe-st
test-driver-adapter-libsql-sqlite-wasm: test-libsql-sqlite-wasm
test-libsql-wasm: dev-libsql-wasm test-qe-st
test-driver-adapter-libsql-wasm: test-libsql-wasm

start-postgres9:
docker compose -f docker-compose.yml up --wait -d --remove-orphans postgres9
Expand Down Expand Up @@ -130,36 +130,36 @@ start-postgres13:
dev-postgres13: start-postgres13
cp $(CONFIG_PATH)/postgres13 $(CONFIG_FILE)

start-pg-postgres13: start-postgres13
start-pg-js: start-postgres13

dev-pg-postgres13: start-pg-postgres13 build-qe-napi build-connector-kit-js
cp $(CONFIG_PATH)/pg-postgres13 $(CONFIG_FILE)
dev-pg-js: start-pg-js build-qe-napi build-connector-kit-js
cp $(CONFIG_PATH)/pg-js $(CONFIG_FILE)

test-pg-postgres13: dev-pg-postgres13 test-qe-st
test-pg-js: dev-pg-js test-qe-st

dev-pg-postgres13-wasm: start-pg-postgres13 build-qe-wasm build-connector-kit-js
cp $(CONFIG_PATH)/pg-postgres13-wasm $(CONFIG_FILE)
dev-pg-wasm: start-pg-js build-qe-wasm build-connector-kit-js
cp $(CONFIG_PATH)/pg-wasm $(CONFIG_FILE)

test-pg-postgres13-wasm: dev-pg-postgres13-wasm test-qe-st
test-pg-wasm: dev-pg-wasm test-qe-st

test-driver-adapter-pg: test-pg-postgres13
test-driver-adapter-pg-wasm: test-pg-postgres13-wasm
test-driver-adapter-pg: test-pg-js
test-driver-adapter-pg-wasm: test-pg-wasm

start-neon-postgres13:
docker compose -f docker-compose.yml up --wait -d --remove-orphans neon-postgres13
start-neon-js:
docker compose -f docker-compose.yml up --wait -d --remove-orphans neon-proxy

dev-neon-ws-postgres13: start-neon-postgres13 build-qe-napi build-connector-kit-js
cp $(CONFIG_PATH)/neon-ws-postgres13 $(CONFIG_FILE)
dev-neon-js: start-neon-js build-qe-napi build-connector-kit-js
cp $(CONFIG_PATH)/neon-js $(CONFIG_FILE)

test-neon-ws-postgres13: dev-neon-ws-postgres13 test-qe-st
test-neon-js: dev-neon-js test-qe-st

dev-neon-ws-postgres13-wasm: start-neon-postgres13 build-qe-wasm build-connector-kit-js
cp $(CONFIG_PATH)/neon-ws-postgres13-wasm $(CONFIG_FILE)
dev-neon-wasm: start-neon-js build-qe-wasm build-connector-kit-js
cp $(CONFIG_PATH)/neon-wasm $(CONFIG_FILE)

test-neon-ws-postgres13-wasm: dev-neon-ws-postgres13-wasm test-qe-st
test-neon-wasm: dev-neon-wasm test-qe-st

test-driver-adapter-neon: test-neon-ws-postgres13
test-driver-adapter-neon-wasm: test-neon-ws-postgres13-wasm
test-driver-adapter-neon: test-neon-js
test-driver-adapter-neon-wasm: test-neon-wasm

start-postgres14:
docker compose -f docker-compose.yml up --wait -d --remove-orphans postgres14
Expand Down Expand Up @@ -283,51 +283,40 @@ start-vitess_8_0:
dev-vitess_8_0: start-vitess_8_0
cp $(CONFIG_PATH)/vitess_8_0 $(CONFIG_FILE)

start-planetscale-vitess8:
docker compose -f docker-compose.yml up -d --remove-orphans planetscale-vitess8
start-planetscale-js:
docker compose -f docker-compose.yml up -d --remove-orphans planetscale-proxy

dev-planetscale-vitess8: start-planetscale-vitess8 build-qe-napi build-connector-kit-js
cp $(CONFIG_PATH)/planetscale-vitess8 $(CONFIG_FILE)
dev-planetscale-js: start-planetscale-js build-qe-napi build-connector-kit-js
cp $(CONFIG_PATH)/planetscale-js $(CONFIG_FILE)

test-planetscale-vitess8: dev-planetscale-vitess8 test-qe-st
test-planetscale-js: dev-planetscale-js test-qe-st

dev-planetscale-vitess8-wasm: start-planetscale-vitess8 build-qe-wasm build-connector-kit-js
cp $(CONFIG_PATH)/planetscale-vitess8-wasm $(CONFIG_FILE)
dev-planetscale-wasm: start-planetscale-js build-qe-wasm build-connector-kit-js
cp $(CONFIG_PATH)/planetscale-wasm $(CONFIG_FILE)

test-planetscale-vitess8-wasm: dev-planetscale-vitess8-wasm test-qe-st
test-planetscale-wasm: dev-planetscale-wasm test-qe-st

test-driver-adapter-planetscale: test-planetscale-vitess8
test-driver-adapter-planetscale-wasm: test-planetscale-vitess8-wasm
test-driver-adapter-planetscale: test-planetscale-js
test-driver-adapter-planetscale-wasm: test-planetscale-wasm

######################
# Local dev commands #
######################

build-qe-napi:
cargo build --package query-engine-node-api
@echo "Build qe napi"

build-qe-wasm:
cd query-engine/query-engine-wasm && ./build.sh
@echo "Build qe wasm"

build-connector-kit-js: install-driver-adapters
cd query-engine/driver-adapters && pnpm i && pnpm build
@echo "Build connector kit js"

install-driver-adapters: ensure-prisma-present
@echo "Installing dependencies for driver adapters..."
@cd ../prisma && pnpm --filter "*adapter*" i
@echo "Dependencies for driver adapters installed.";
@echo "install driver adapters"

ensure-prisma-present:
@if [ -d ../prisma ]; then \
cd "$(realpath ../prisma)" && git fetch origin main; \
LOCAL_CHANGES=$$(git diff --name-only HEAD origin/main -- 'packages/*adapter*'); \
if [ -n "$$LOCAL_CHANGES" ]; then \
echo "⚠️ ../prisma diverges from prisma/prisma main branch. Test results might diverge from those in CI ⚠️ "; \
fi \
else \
echo "git clone --depth=1 https://github.com/prisma/prisma.git --branch=$(DRIVER_ADAPTERS_BRANCH) ../prisma"; \
git clone --depth=1 https://github.com/prisma/prisma.git --branch=$(DRIVER_ADAPTERS_BRANCH) "../prisma" && echo "Prisma repository has been cloned to ../prisma"; \
fi;
@echo "Ensure prisma present"

# Quick schema validation of whatever you have in the dev_datamodel.prisma file.
validate:
Expand Down
30 changes: 25 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ services:
networks:
- databases

neon-postgres13:
neon-proxy:
image: ghcr.io/neondatabase/wsproxy:latest
restart: unless-stopped
environment:
Expand All @@ -123,16 +123,36 @@ services:
networks:
- databases

planetscale-vitess8:
# Tests using a vitess backend were not running properly for query-engine tests, and In
# https://github.com/prisma/prisma-engines/pull/4423 work was done to have coverage of the correctness of planetscale
# driver adapters.
#
# Given these tests run against the planetscale proxy, and given a different test suite will exist for vitess with
# rust drivers, we opted for the path of least friction when running the driver adapter tests, which is putting a
# single mysql box behind the planetscale proxy instead of full vttest cluster.
#
# The tradeoffs are:
#
# - we don't exercise vitess but mysql. This is a close approximation, but there might be small differences in
# behavior. (ex. vttest can be returning different error messages than mysql)
#
# - however, we 1) do exercise the planetscale proxy, 2) we use relationMode=prisma and this resembles what actually
# happens within the query engine, where vitess does not exist as a provider, and as such there isn't any particular
# capability or conditional code making the engine behave differently then when using Mysql.
# In the end Vitess is just an abstraction existing in the test kit to a) use the mysql provider, b) run the suite
# with relationMode=prisma; c) being able to run or exclude specific tests for that configuration. But the existence
# of this testing connector is misleading, and it should probably be just a version of the MySQL testing connector
# instead.
planetscale-proxy:
build: ./docker/planetscale_proxy
environment:
MYSQL_HOST: 'planetscale-mysql'
MYSQL_HOST: 'mysql-planetscale'
MYSQL_PORT: 3306
MYSQL_DATABASE: prisma
ports:
- '8085:8085'
depends_on:
planetscale-mysql:
mysql-planetscale:
condition: service_healthy
restart: unless-stopped
healthcheck:
Expand All @@ -143,7 +163,7 @@ services:
networks:
- databases

planetscale-mysql:
mysql-planetscale:
image: mysql:8.0.28
command: mysqld
restart: unless-stopped
Expand Down
9 changes: 0 additions & 9 deletions query-engine/connector-test-kit-rs/test-configs/planetscale

This file was deleted.

0 comments on commit c689fe6

Please sign in to comment.