Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: query compiler proof of concept #5024

Merged
merged 67 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
740a356
Prepare playground
aqrln Oct 24, 2024
b89fd0d
Implement more structure
aqrln Oct 25, 2024
82537d9
Inline the schema in the compiler example
aqrln Oct 25, 2024
f2f088f
Remove useless explicit to_string
aqrln Oct 25, 2024
a364a78
Fix expression formatting
aqrln Oct 25, 2024
6be72d0
Split ReadQuery and WriteQuery
aqrln Oct 25, 2024
d9afbeb
Implement translating simple read query
aqrln Oct 25, 2024
22e73a7
Implement more queries
aqrln Oct 25, 2024
ff2390e
Implement placeholders
aqrln Oct 26, 2024
94bd641
[integration]
aqrln Oct 26, 2024
440e3e2
[integration]
aqrln Oct 26, 2024
f4d21ea
Expand comment
aqrln Oct 26, 2024
f261563
Implement napi method
aqrln Oct 26, 2024
0c1f1f4
[integration]
aqrln Oct 26, 2024
06c3968
Remove useless deref
aqrln Oct 26, 2024
362f5b2
[integration]
aqrln Oct 26, 2024
fdcc718
Improve placeholder serialization
aqrln Oct 26, 2024
4b729e6
[integration]
aqrln Oct 26, 2024
20bb454
Fix warnings
aqrln Oct 26, 2024
b0d1b7f
Add compile method on wasm
aqrln Oct 27, 2024
3bb68da
Make PrismaValue param parsing consistent with serialization
aqrln Oct 27, 2024
d8ebea2
[integration]
aqrln Oct 28, 2024
e27a869
Switch dialect to sqlite
aqrln Oct 28, 2024
af8159d
[integration]
aqrln Oct 28, 2024
ce0e4f6
[integration]
aqrln Oct 28, 2024
b820b6a
Comment out react native
aqrln Oct 28, 2024
8f2d9e3
[integration]
aqrln Oct 28, 2024
e995e5d
wip add param to dmmf
aqrln Oct 28, 2024
12a506f
Add comment
aqrln Oct 28, 2024
721ced9
[integration]
aqrln Oct 28, 2024
323a232
disable more react-native
aqrln Oct 28, 2024
8c78d8d
check param in query schema in validation
aqrln Oct 28, 2024
f778321
switch to sqlite visitor
aqrln Oct 28, 2024
2d54430
[integration]
aqrln Oct 28, 2024
cfb698a
add nested query in example
aqrln Dec 19, 2024
89b40cb
Use lld via .cargo/config.toml and not env vars
aqrln Dec 23, 2024
58f35a7
use postgres
aqrln Dec 23, 2024
da96b5d
remove dbg
aqrln Dec 23, 2024
18a7faf
first pass at read nested
aqrln Dec 26, 2024
ec1a304
Use `pretty` for pretty printing
aqrln Jan 11, 2025
8e7a29c
refactor formatting
aqrln Jan 11, 2025
740e996
Add parent field name to join node
aqrln Jan 11, 2025
96f7233
Drop "with" in "with params"
aqrln Jan 11, 2025
10a05b7
Add filters
aqrln Jan 11, 2025
6836d42
fix: fix createOne (#5121)
jacek-prisma Jan 13, 2025
9ef2ff8
Mark to-one nested reads as unique
aqrln Jan 14, 2025
159c4a0
Add `LIMIT 1` for to-one queries
aqrln Jan 14, 2025
0e6a694
Implement templates for IN
aqrln Jan 14, 2025
361de20
Remove unused stuff
aqrln Jan 14, 2025
244e52c
Extract sql query builder (#5123)
jacek-prisma Jan 15, 2025
6bb3256
Remove napi copypasta from wasm engine
aqrln Jan 15, 2025
9cd8301
feat(compiler): pass through connection_info (#5125)
FGoessler Jan 15, 2025
5f0c232
feat: generic query building (#5127)
jacek-prisma Jan 16, 2025
48e2fc1
chore: extract query-compiler and query-compiler-wasm (#5129)
jacek-prisma Jan 17, 2025
0101a7a
Merge branch 'main' into HEAD
aqrln Jan 17, 2025
db04604
Fix building WASM under Nix
aqrln Jan 20, 2025
5fc1879
Fix type error
aqrln Jan 17, 2025
c71ba31
Uncomment react-native
aqrln Jan 20, 2025
4bee1bd
Add workspace lints to query-engine-wasm
aqrln Jan 20, 2025
384c3d1
Add workspace lints to schema-engine-wasm
aqrln Jan 20, 2025
8035f1b
Remove obsolete query schema params handling
aqrln Jan 20, 2025
851c3a0
Don't build QC executor for now
aqrln Jan 20, 2025
be6edc5
Merge latest main
aqrln Jan 20, 2025
405c44a
Add playground back
aqrln Jan 20, 2025
e5f4ae7
cleanup(compiler): revert unneeded changes
FGoessler Jan 20, 2025
d6f8a09
cleanup(compiler): make query compiler playground a binary crate
FGoessler Jan 20, 2025
7d1763d
cleanup(compiler): drop example files
FGoessler Jan 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,11 @@ if command -v nix &> /dev/null && [ -z ${DISABLE_NIX+x} ]
then
use nix
fi

if [[ "$OSTYPE" == "linux-gnu"* ]] && command -v lld &> /dev/null && [ ! -f .cargo/config.toml ]; then
mkdir -p .cargo
cat << EOF > .cargo/config.toml
[target.$(uname -m)-unknown-linux-gnu]
rustflags = ["-C", "link-arg=-fuse-ld=lld"]
EOF
fi
Comment on lines +56 to +63
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated changes, can be dropped or extracted to a different PR

96 changes: 48 additions & 48 deletions .github/workflows/build-engines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,30 @@ on:
push:
branches:
- main
- '*.*.x'
- 'integration/*'
- "*.*.x"
- "integration/*"
paths-ignore:
- '!.github/workflows/build-engines*'
- '.github/**'
- '.buildkite/**'
- '*.md'
- 'LICENSE'
- 'CODEOWNERS'
- 'renovate.json'
- "!.github/workflows/build-engines*"
- ".github/**"
- ".buildkite/**"
- "*.md"
- "LICENSE"
- "CODEOWNERS"
- "renovate.json"
workflow_dispatch:
pull_request:
paths-ignore:
- '!.github/workflows/build-engines*'
- '.github/**'
- '.buildkite/**'
- '*.md'
- 'LICENSE'
- 'CODEOWNERS'
- 'renovate.json'
- "!.github/workflows/build-engines*"
- ".github/**"
- ".buildkite/**"
- "*.md"
- "LICENSE"
- "CODEOWNERS"
- "renovate.json"

jobs:
is-release-necessary:
name: 'Decide if a release of the engines artifacts is necessary'
name: "Decide if a release of the engines artifacts is necessary"
runs-on: ubuntu-22.04
outputs:
release: ${{ steps.decision.outputs.release }}
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:
END_OF_COMMIT_MESSAGE
echo "Commit message contains [integration]: ${{ contains(steps.commit-msg.outputs.commit-msg, '[integration]') }}"

- name: 'Check if commit message conatains `[integration]` and the PR author has permissions to trigger the workflow'
- name: "Check if commit message conatains `[integration]` and the PR author has permissions to trigger the workflow"
id: check-commit-message
# See https://docs.github.com/en/graphql/reference/enums
# https://michaelheap.com/github-actions-check-permission/
Expand All @@ -68,16 +68,16 @@ jobs:
# - the PR author has permissions to trigger the workflow (must be part of the org or a collaborator)
if: |
github.event_name == 'pull_request' &&
contains(steps.commit-msg.outputs.commit-msg, '[integration]') &&
contains(steps.commit-msg.outputs.commit-msg, '[integration]') &&
(
github.event.pull_request.author_association == 'OWNER' ||
github.event.pull_request.author_association == 'MEMBER' ||
github.event.pull_request.author_association == 'CONTRIBUTOR' ||
github.event.pull_request.author_association == 'COLLABORATOR'
)
run: |
echo "Commit message contains [integration] and PR author has permissions"
# set value to GitHub output
echo "Commit message contains [integration] and PR author has permissions"
# set value to GitHub output
echo "release=true" >> $GITHUB_OUTPUT

#
Expand Down Expand Up @@ -118,9 +118,9 @@ jobs:
# https://github.com/peter-evans/find-comment/tree/v3/?tab=readme-ov-file#outputs
# Tip: Empty strings evaluate to zero in GitHub Actions expressions. e.g. If comment-id is an empty string steps.fc.outputs.comment-id == 0 evaluates to true.
if: |
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
steps.check-commit-message.outputs.release == 'true' ||
github.event_name == 'workflow_dispatch' ||
github.event_name == 'push' ||
steps.check-commit-message.outputs.release == 'true' ||
steps.check-branch.outputs.release == 'true'

id: decision
Expand All @@ -140,7 +140,7 @@ jobs:

build-linux:
name: Build Engines for Linux
needs:
needs:
- is-release-necessary
if: ${{ needs.is-release-necessary.outputs.release == 'true' }}
uses: ./.github/workflows/build-engines-linux-template.yml
Expand All @@ -149,7 +149,7 @@ jobs:

build-macos-intel:
name: Build Engines for Apple Intel
needs:
needs:
- is-release-necessary
if: ${{ needs.is-release-necessary.outputs.release == 'true' }}
uses: ./.github/workflows/build-engines-apple-intel-template.yml
Expand All @@ -158,7 +158,7 @@ jobs:

build-macos-silicon:
name: Build Engines for Apple Silicon
needs:
needs:
- is-release-necessary
if: ${{ needs.is-release-necessary.outputs.release == 'true' }}
uses: ./.github/workflows/build-engines-apple-silicon-template.yml
Expand All @@ -167,7 +167,7 @@ jobs:

build-react-native:
name: Build Engines for React native
needs:
needs:
- is-release-necessary
if: ${{ needs.is-release-necessary.outputs.release == 'true' }}
uses: ./.github/workflows/build-engines-react-native-template.yml
Expand All @@ -176,15 +176,15 @@ jobs:

build-windows:
name: Build Engines for Windows
needs:
needs:
- is-release-necessary
if: ${{ needs.is-release-necessary.outputs.release == 'true' }}
uses: ./.github/workflows/build-engines-windows-template.yml
with:
commit: ${{ github.sha }}

release-artifacts:
name: 'Release artifacts from branch ${{ github.head_ref || github.ref_name }} for commit ${{ github.sha }}'
name: "Release artifacts from branch ${{ github.head_ref || github.ref_name }} for commit ${{ github.sha }}"
runs-on: ubuntu-22.04
concurrency:
group: ${{ github.sha }}
Expand All @@ -195,9 +195,9 @@ jobs:
- build-react-native
- build-windows
env:
BUCKET_NAME: 'prisma-builds'
BUCKET_NAME: "prisma-builds"
PRISMA_ENGINES_COMMIT_SHA: ${{ github.sha }}
DESTINATION_TARGET_PATH: 's3://prisma-builds/all_commits/${{ github.sha }}'
DESTINATION_TARGET_PATH: "s3://prisma-builds/all_commits/${{ github.sha }}"

steps:
# Because we need the scripts
Expand All @@ -215,22 +215,22 @@ jobs:
# run-id: 9526334324
# github-token: ${{ secrets.GITHUB_TOKEN }}

- name: 'R2: Check if artifacts were already built and uploaded before via `.finished` file'
- name: "R2: Check if artifacts were already built and uploaded before via `.finished` file"
env:
FILE_PATH: 'all_commits/${{ github.sha }}/.finished'
FILE_PATH_LEGACY: 'all_commits/${{ github.sha }}/rhel-openssl-1.1.x/.finished'
AWS_DEFAULT_REGION: 'auto'
FILE_PATH: "all_commits/${{ github.sha }}/.finished"
FILE_PATH_LEGACY: "all_commits/${{ github.sha }}/rhel-openssl-1.1.x/.finished"
AWS_DEFAULT_REGION: "auto"
AWS_ACCESS_KEY_ID: ${{ vars.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_ENDPOINT_URL_S3: ${{ vars.R2_ENDPOINT }}
working-directory: .github/workflows/utils
run: bash checkFinishedMarker.sh

- name: 'S3: Check if artifacts were already built and uploaded before via `.finished` file'
- name: "S3: Check if artifacts were already built and uploaded before via `.finished` file"
env:
FILE_PATH: 'all_commits/${{ github.sha }}/.finished'
FILE_PATH_LEGACY: 'all_commits/${{ github.sha }}/rhel-openssl-1.1.x/.finished'
AWS_DEFAULT_REGION: 'eu-west-1'
FILE_PATH: "all_commits/${{ github.sha }}/.finished"
FILE_PATH_LEGACY: "all_commits/${{ github.sha }}/rhel-openssl-1.1.x/.finished"
AWS_DEFAULT_REGION: "eu-west-1"
AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
working-directory: .github/workflows/utils
Expand All @@ -254,7 +254,7 @@ jobs:
zip -r react-native/binaries.zip ios android
rm -rf ios android

- name: 'Create compressed engine files (.gz)'
- name: "Create compressed engine files (.gz)"
working-directory: engines-artifacts
run: |
set -eu
Expand All @@ -266,13 +266,13 @@ jobs:

ls -Rl .

- name: 'Create SHA256 checksum files (.sha256).'
- name: "Create SHA256 checksum files (.sha256)."
working-directory: engines-artifacts
run: |
set -eu

find . -type f | while read filename; do
sha256sum "$filename" > "$filename.sha256"
sha256sum "$filename" > "$filename.sha256"
echo "$filename.sha256 file created."
done

Expand All @@ -292,7 +292,7 @@ jobs:
run: gpg -K

# next to each file (excluding .sha256 files)
- name: 'Create a GPG detached signature (.sig)'
- name: "Create a GPG detached signature (.sig)"
working-directory: engines-artifacts
run: |
set -eu
Expand All @@ -303,18 +303,18 @@ jobs:

ls -Rl .

- name: 'Cloudflare R2: Upload to bucket and verify uploaded files then create `.finished` file'
- name: "Cloudflare R2: Upload to bucket and verify uploaded files then create `.finished` file"
# https://docs.aws.amazon.com/cli/v1/userguide/cli-configure-envvars.html
env:
AWS_DEFAULT_REGION: 'auto'
AWS_DEFAULT_REGION: "auto"
AWS_ACCESS_KEY_ID: ${{ vars.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
AWS_ENDPOINT_URL_S3: ${{ vars.R2_ENDPOINT }}
run: bash .github/workflows/utils/uploadAndVerify.sh engines-artifacts-for-r2

- name: 'AWS S3: Upload to bucket and verify uploaded files then create `.finished` file'
- name: "AWS S3: Upload to bucket and verify uploaded files then create `.finished` file"
env:
AWS_DEFAULT_REGION: 'eu-west-1'
AWS_DEFAULT_REGION: "eu-west-1"
AWS_ACCESS_KEY_ID: ${{ vars.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: bash .github/workflows/utils/uploadAndVerify.sh engines-artifacts-for-s3
Expand Down
24 changes: 3 additions & 21 deletions .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,16 @@ concurrency:
cancel-in-progress: true

jobs:
clippy:
name: clippy linting
checks:
name: run lints and formatting checks
runs-on: ubuntu-latest
env:
RUSTFLAGS: "-Dwarnings"
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: clippy
targets: wasm32-unknown-unknown
# Check the whole workspace with clippy for the native compilation
# target, and query-engine-wasm and dependencies for wasm32-unknown-unknown.
# Note that `--all-targets` is unrelated to `--target` as in target platform,
# it is a shortcut for `--lib --bins --tests --benches --examples`.
- run: |
cargo clippy --workspace --all-features --all-targets
cargo clippy --all-features --all-targets -p query-engine-wasm -p prisma-schema-build --target wasm32-unknown-unknown

rustfmt:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Check formatting
run: cargo fmt -- --check
- run: make pedantic

shellcheck:
runs-on: ubuntu-latest
Expand Down
65 changes: 65 additions & 0 deletions .github/workflows/publish-query-compiler-wasm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Build and publish @prisma/query-compiler-wasm
run-name: npm - release @prisma/query-compiler-wasm@${{ github.event.inputs.packageVersion }} from ${{ github.event.inputs.enginesHash }} on ${{ github.event.inputs.npmDistTag }}

concurrency: publish-query-compiler-wasm

on:
# usually triggered via GH Actions Workflow in prisma/engines-wrapper repo
workflow_dispatch:
inputs:
packageVersion:
required: true
description: "New @prisma/query-compiler-wasm package version"
enginesHash:
required: true
description: "query-compiler commit to build"
npmDistTag:
required: true
default: "latest"
description: "npm dist-tag (e.g. latest or integration)"

jobs:
build:
name: Build and publish @prisma/query-compiler-wasm
runs-on: ubuntu-latest
steps:
- name: Print input
run: echo "${{ toJson(github.event.inputs) }}"

- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.enginesHash }}

- uses: ./.github/workflows/include/rust-wasm-setup

- name: Build @prisma/query-compiler-wasm
run: make build-qc-wasm
env:
QE_WASM_VERSION: ${{ github.event.inputs.packageVersion }}

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"

- name: Set up NPM token for publishing
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc

- name: Publish @prisma/query-compiler-wasm
run: npm publish --access public --tag ${{ github.event.inputs.npmDistTag }}
working-directory: query-compiler/query-compiler-wasm/pkg

#
# Failure handlers
#
- name: Set current job url in SLACK_FOOTER env var
if: ${{ failure() }}
run: echo "SLACK_FOOTER=<$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID|Click here to go to the job logs>" >> $GITHUB_ENV
- name: Slack Notification on Failure
if: ${{ failure() }}
uses: rtCamp/[email protected]
env:
SLACK_TITLE: "Building and publishing @prisma/query-compiler-wasm failed :x:"
SLACK_COLOR: "#FF0000"
SLACK_CHANNEL: feed-prisma-query-compiler-wasm-publish-failures
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_WASM_FAILING }}
Loading
Loading