Skip to content

Commit 7d2dac2

Browse files
committed
Revert "Migrate driver adapters to prisma/prisma (#4380)"
This reverts commit 6dda9d7.
1 parent 685d9bc commit 7d2dac2

File tree

101 files changed

+5279
-348
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+5279
-348
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: Driver Adapters, Smoke Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
paths-ignore:
8+
- '.github/**'
9+
- '!.github/workflows/driver-adapter-smoke-tests.yml'
10+
- '.buildkite/**'
11+
- '*.md'
12+
- 'LICENSE'
13+
- 'CODEOWNERS'
14+
- 'renovate.json'
15+
16+
jobs:
17+
driver-adapter-smoke-tests:
18+
name: ${{ matrix.adapter }}
19+
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
adapter: ['neon:ws', 'neon:http', planetscale, pg, libsql]
24+
25+
runs-on: ubuntu-latest
26+
27+
services:
28+
postgres:
29+
image: postgres
30+
env:
31+
POSTGRES_PASSWORD: postgres
32+
options: >-
33+
--health-cmd pg_isready
34+
--health-interval 10s
35+
--health-timeout 5s
36+
--health-retries 5
37+
ports:
38+
- 5432:5432
39+
40+
# via package.json rewritten into DATABASE_URL before scripts are run
41+
env:
42+
JS_NEON_DATABASE_URL: ${{ secrets.JS_NEON_DATABASE_URL }}
43+
JS_PLANETSCALE_DATABASE_URL: ${{ secrets.JS_PLANETSCALE_DATABASE_URL }}
44+
JS_PG_DATABASE_URL: postgres://postgres:postgres@localhost:5432/test # ${{ secrets.JS_PG_DATABASE_URL }}
45+
# TODO: test sqld and embedded replicas
46+
JS_LIBSQL_DATABASE_URL: file:/tmp/libsql.db
47+
# TODO: test all three of ("number", "bigint", "string") and conditionally skip some tests as appropriate
48+
JS_LIBSQL_INT_MODE: bigint
49+
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- uses: dtolnay/rust-toolchain@stable
54+
55+
- uses: pnpm/action-setup@v2
56+
with:
57+
version: 8
58+
- uses: actions/setup-node@v3
59+
with:
60+
node-version: 18
61+
#cache: 'pnpm'
62+
63+
- name: Compile Query Engine
64+
run: cargo build -p query-engine-node-api
65+
66+
- name: Install Dependencies (Driver Adapters)
67+
run: pnpm install
68+
working-directory: ./query-engine/driver-adapters/js
69+
- name: Build Driver Adapters
70+
run: pnpm build
71+
working-directory: ./query-engine/driver-adapters/js
72+
73+
- run: pnpm prisma:${{ matrix.adapter }}
74+
working-directory: ./query-engine/driver-adapters/js/smoke-test-js
75+
- run: pnpm ${{ matrix.adapter }}:libquery
76+
working-directory: ./query-engine/driver-adapters/js/smoke-test-js
77+
- name: pnpm ${{ matrix.adapter }}:client (using @prisma/client - including engine! - from Npm)
78+
run: pnpm ${{ matrix.adapter }}:client
79+
if: always()
80+
working-directory: ./query-engine/driver-adapters/js/smoke-test-js
81+
82+
83+
driver-adapter-smoke-tests-errors:
84+
name: Errors
85+
86+
runs-on: ubuntu-latest
87+
88+
# services:
89+
# postgres:
90+
# image: postgres
91+
# env:
92+
# POSTGRES_PASSWORD: postgres
93+
# options: >-
94+
# --health-cmd pg_isready
95+
# --health-interval 10s
96+
# --health-timeout 5s
97+
# --health-retries 5
98+
# ports:
99+
# - 5432:5432
100+
101+
env:
102+
# via package.json rewritten into DATABASE_URL before scripts are run
103+
JS_PG_DATABASE_URL: postgres://postgres:postgres@localhost:5432/test
104+
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- uses: dtolnay/rust-toolchain@stable
109+
110+
- uses: pnpm/action-setup@v2
111+
with:
112+
version: 8
113+
- uses: actions/setup-node@v3
114+
with:
115+
node-version: 18
116+
#cache: 'pnpm'
117+
118+
- name: Compile Query Engine
119+
run: cargo build -p query-engine-node-api
120+
121+
- name: Install Dependencies (Driver Adapters)
122+
run: pnpm install
123+
working-directory: ./query-engine/driver-adapters/js
124+
- name: Build Driver Adapters
125+
run: pnpm build
126+
working-directory: ./query-engine/driver-adapters/js
127+
128+
- name: pnpm errors
129+
run: pnpm errors
130+
if: always()
131+
working-directory: ./query-engine/driver-adapters/js/smoke-test-js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Build and publish Prisma Driver Adapters
2+
run-name: npm - release Driver Adapters ${{ github.event.inputs.prismaVersion }} from ${{ github.event.inputs.enginesHash }} on ${{ github.event.inputs.npmDistTag }}
3+
4+
concurrency: publish-prisma-driver-adapters
5+
6+
on:
7+
# usually triggered via GH Actions Workflow in prisma/prisma repo
8+
workflow_dispatch:
9+
inputs:
10+
enginesHash:
11+
description: Engine commit hash to checkout for publishing
12+
required: true
13+
prismaVersion:
14+
description: Prisma version to use for publishing
15+
required: true
16+
npmDistTag:
17+
description: npm dist-tag to use for publishing
18+
required: true
19+
default: 'latest'
20+
dryRun:
21+
description: 'Check to do a dry run (does not publish packages)'
22+
type: boolean
23+
24+
jobs:
25+
build:
26+
name: Build and publish Prisma Driver Adapters
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Print input
30+
env:
31+
THE_INPUT: '${{ toJson(github.event.inputs) }}'
32+
run: |
33+
echo $THE_INPUT
34+
35+
- uses: actions/checkout@v4
36+
with:
37+
ref: ${{ github.event.inputs.enginesHash }}
38+
39+
- uses: pnpm/[email protected]
40+
with:
41+
version: 8
42+
43+
- uses: actions/setup-node@v3
44+
with:
45+
node-version: '20.x'
46+
registry-url: 'https://registry.npmjs.org/'
47+
48+
- name: Install dependencies
49+
run: pnpm i
50+
working-directory: query-engine/driver-adapters/js
51+
52+
- name: Build
53+
run: pnpm -r build
54+
working-directory: query-engine/driver-adapters/js
55+
56+
- name: Update version in package.json
57+
run: |
58+
# find all files package.json, and for each use jq to write the version, then write to temp file and overwrite original file with result
59+
find . -name "package.json" -exec bash -c 'jq --arg version "${{ github.event.inputs.prismaVersion }}" ".version = \$version" "{}" > tmpfile && mv tmpfile "{}"' \;
60+
working-directory: query-engine/driver-adapters/js
61+
62+
- name: Publish Prisma Driver Adapters packages
63+
run: |
64+
pnpm -r publish --no-git-checks --tag ${{ github.event.inputs.npmDistTag }} ${{ env.DRY_RUN }}
65+
working-directory: query-engine/driver-adapters/js
66+
env:
67+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
68+
DRY_RUN: ${{ github.event.inputs.dryRun == 'true' && '--dry-run' || '' }}
69+
70+
#
71+
# Failure handlers
72+
#
73+
74+
- name: Set current job url in SLACK_FOOTER env var
75+
if: ${{ failure() }}
76+
run: echo "SLACK_FOOTER=<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID|Click here to go to the job logs>" >> $GITHUB_ENV
77+
- name: Slack Notification on Failure
78+
if: ${{ failure() }}
79+
uses: rtCamp/[email protected]
80+
env:
81+
SLACK_TITLE: 'prisma driver adapters publishing failed :x:'
82+
SLACK_COLOR: '#FF0000'
83+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_DRIVER_ADPATERS_FAILING }}

.github/workflows/query-engine-driver-adapters.yml

-11
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ jobs:
4949
runs-on: ubuntu-latest
5050
steps:
5151
- uses: actions/checkout@v4
52-
with:
53-
ref: ${{ github.event.pull_request.head.sha }}
5452

5553
- name: 'Setup Node.js'
5654
uses: actions/setup-node@v3
@@ -78,15 +76,6 @@ jobs:
7876
username: ${{ secrets.DOCKERHUB_USERNAME }}
7977
password: ${{ secrets.DOCKERHUB_TOKEN }}
8078

81-
- name: Extract Branch Name
82-
id: extract-branch
83-
run: |
84-
branch="$(git show -s --format=%s | grep -o "DRIVER_ADAPTERS_BRANCH=[^ ]*" | cut -f2 -d=)"
85-
if [ -n "$branch" ]; then
86-
echo "Using $branch branch of driver adapters"
87-
echo "DRIVER_ADAPTERS_BRANCH=$branch" >> "$GITHUB_ENV"
88-
fi
89-
9079
- run: make ${{ matrix.adapter.setup_task }}
9180

9281
- uses: dtolnay/rust-toolchain@stable

.gitignore

-3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,3 @@ dmmf.json
4646
graph.dot
4747

4848
prisma-schema-wasm/nodejs
49-
50-
# This symlink looks orphan here, but it comes from prisma/prisma where driver adapters reference a file in their parent directory
51-
tsconfig.build.adapter.json

Makefile

+2-53
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ CONFIG_PATH = ./query-engine/connector-test-kit-rs/test-configs
22
CONFIG_FILE = .test_config
33
SCHEMA_EXAMPLES_PATH = ./query-engine/example_schemas
44
DEV_SCHEMA_FILE = dev_datamodel.prisma
5-
DRIVER_ADAPTERS_BRANCH ?= main
65

76
LIBRARY_EXT := $(shell \
87
case "$$(uname -s)" in \
@@ -45,13 +44,7 @@ release:
4544
#################
4645

4746
test-qe:
48-
ifndef DRIVER_ADAPTER
4947
cargo test --package query-engine-tests
50-
else
51-
@echo "Executing query engine tests with $(DRIVER_ADAPTER) driver adapter"; \
52-
# Add your actual command for the "test-driver-adapter" task here
53-
$(MAKE) test-driver-adapter-$(DRIVER_ADAPTER);
54-
endif
5548

5649
test-qe-verbose:
5750
cargo test --package query-engine-tests -- --nocapture
@@ -87,10 +80,6 @@ dev-sqlite:
8780
dev-libsql-sqlite: build-qe-napi build-connector-kit-js
8881
cp $(CONFIG_PATH)/libsql-sqlite $(CONFIG_FILE)
8982

90-
test-libsql-sqlite: dev-libsql-sqlite test-qe-st
91-
92-
test-driver-adapter-libsql: test-libsql-sqlite
93-
9483
start-postgres9:
9584
docker compose -f docker-compose.yml up --wait -d --remove-orphans postgres9
9685

@@ -126,20 +115,12 @@ start-pg-postgres13: build-qe-napi build-connector-kit-js start-postgres13
126115
dev-pg-postgres13: start-pg-postgres13
127116
cp $(CONFIG_PATH)/pg-postgres13 $(CONFIG_FILE)
128117

129-
test-pg-postgres13: dev-pg-postgres13 test-qe-st
130-
131-
test-driver-adapter-pg: test-pg-postgres13
132-
133118
start-neon-postgres13: build-qe-napi build-connector-kit-js
134119
docker compose -f docker-compose.yml up --wait -d --remove-orphans neon-postgres13
135120

136121
dev-neon-ws-postgres13: start-neon-postgres13
137122
cp $(CONFIG_PATH)/neon-ws-postgres13 $(CONFIG_FILE)
138123

139-
test-neon-ws-postgres13: dev-neon-ws-postgres13 test-qe-st
140-
141-
test-driver-adapter-neon: test-neon-ws-postgres13
142-
143124
start-postgres14:
144125
docker compose -f docker-compose.yml up --wait -d --remove-orphans postgres14
145126

@@ -274,47 +255,15 @@ start-planetscale-vitess8: build-qe-napi build-connector-kit-js
274255
dev-planetscale-vitess8: start-planetscale-vitess8
275256
cp $(CONFIG_PATH)/planetscale-vitess8 $(CONFIG_FILE)
276257

277-
test-planetscale-vitess8: dev-planetscale-vitess8 test-qe-st
278-
279-
test-driver-adapter-planetscale: test-planetscale-vitess8
280-
281258
######################
282259
# Local dev commands #
283260
######################
284261

285262
build-qe-napi:
286263
cargo build --package query-engine-node-api
287264

288-
build-connector-kit-js: build-driver-adapters symlink-driver-adapters
289-
cd query-engine/driver-adapters/connector-test-kit-executor && pnpm i && pnpm build
290-
291-
build-driver-adapters: ensure-prisma-present
292-
@echo "Building driver adapters..."
293-
@cd ../prisma && pnpm --filter "*adapter*" i && pnpm --filter "*adapter*" build
294-
@echo "Driver adapters build completed.";
295-
296-
symlink-driver-adapters: ensure-prisma-present
297-
@echo "Creating symbolic links for driver adapters..."
298-
@for dir in $(wildcard $(realpath ../prisma)/packages/*adapter*); do \
299-
if [ -d "$$dir" ]; then \
300-
dir_name=$$(basename "$$dir"); \
301-
ln -sfn "$$dir" "$(realpath .)/query-engine/driver-adapters/$$dir_name"; \
302-
echo "Created symbolic link for $$dir_name"; \
303-
fi; \
304-
done;
305-
echo "Symbolic links creation completed.";
306-
307-
ensure-prisma-present:
308-
@if [ -d ../prisma ]; then \
309-
cd "$(realpath ../prisma)" && git fetch origin main; \
310-
LOCAL_CHANGES=$$(git diff --name-only HEAD origin/main -- 'packages/*adapter*'); \
311-
if [ -n "$$LOCAL_CHANGES" ]; then \
312-
echo "⚠️ ../prisma diverges from prisma/prisma main branch. Test results might diverge from those in CI ⚠️ "; \
313-
fi \
314-
else \
315-
echo "git clone --depth=1 https://github.com/prisma/prisma.git --branch=$(DRIVER_ADAPTERS_BRANCH) ../prisma"; \
316-
git clone --depth=1 https://github.com/prisma/prisma.git --branch=$(DRIVER_ADAPTERS_BRANCH) "../prisma" && echo "Prisma repository has been cloned to ../prisma"; \
317-
fi;
265+
build-connector-kit-js:
266+
cd query-engine/driver-adapters/js && pnpm i && pnpm build
318267

319268
# Quick schema validation of whatever you have in the dev_datamodel.prisma file.
320269
validate:

README.md

-26
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ integration tests.
203203
- Alternatively: Load the defined environment in `./.envrc` manually in your shell.
204204

205205
**Setup:**
206-
207206
There are helper `make` commands to set up a test environment for a specific
208207
database connector you want to test. The commands set up a container (if needed)
209208
and write the `.test_config` file, which is picked up by the integration
@@ -235,31 +234,6 @@ Other variables may or may not be useful.
235234

236235
Run `cargo test` in the repository root.
237236

238-
### Testing driver adapters
239-
240-
Please refer to the [Testing driver adapters](./query-engine/connector-test-kit-rs/README.md#testing-driver-adapters) section in the connector-test-kit-rs README.
241-
242-
**ℹ️ Important note on developing features that require changes to the both the query engine, and driver adapters code**
243-
244-
As explained in [Testing driver adapters](./query-engine/connector-test-kit-rs/README.md#testing-driver-adapters), running `DRIVER_ADAPTER=$adapter make qe-test`
245-
will ensure you have prisma checked out in your filesystem in the same directory as prisma-engines. This is needed because the driver adapters code is symlinked in prisma-engines.
246-
247-
When working on a feature or bugfix spanning adapters code and query-engine code, you will need to open sibling PRs in `prisma/prisma` and `prisma/prisma-engines` respectively.
248-
Locally, each time you run `DRIVER_ADAPTER=$adapter make qe-test` tests will run using the driver adapters built from the source code in the working copy of prisma/prisma. All good.
249-
250-
In CI, tho', we need to denote which branch of prisma/prisma we want to use for tests. In CI, there's no working copy of prisma/prisma before tests run.
251-
The CI jobs clones prisma/prisma `main` branch by default, which doesn't include your local changes. To test in integration, we can tell CI to use the branch of prisma/prisma containing
252-
the changes in adapters. To do it, you can use a simple convention in commit messages. Like this:
253-
254-
```
255-
git commit -m "DRIVER_ADAPTERS_BRANCH=prisma-branch-with-changes-in-adapters [...]"
256-
```
257-
258-
GitHub actions will then pick up the branch name and use it to clone that branch's code of prisma/prisma, and build the driver adapters code from there.
259-
260-
When it's time to merge the sibling PRs, you'll need to merge the prisma/prisma PR first, so when merging the engines PR you have the code of the adapters ready in prisma/prisma `main` branch.
261-
262-
263237
## Parallel rust-analyzer builds
264238

265239
When rust-analzyer runs `cargo check` it will lock the build directory and stop any cargo commands from running until it has completed. This makes the build process feel a lot longer. It is possible to avoid this by setting a different build path for

0 commit comments

Comments
 (0)