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

chore: extract query-compiler and query-compiler-wasm #5129

Merged
merged 16 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
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
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 }}
46 changes: 40 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ members = [
"query-engine/request-handlers",
"query-engine/schema",
"query-engine/query-builders/*",
"query-compiler/query-compiler",
"query-compiler/query-compiler-wasm",
"libs/*",
"prisma-fmt",
"prisma-schema-wasm",
Expand Down Expand Up @@ -72,13 +74,15 @@ napi = { version = "2.16.13", default-features = false, features = [
] }
napi-derive = "2.16.12"
pin-project = "1"
pretty = { version = "0.12", features = ["termcolor"] }
rand = { version = "0.8" }
regex = { version = "1", features = ["std"] }
serde_repr = { version = "0.1.17" }
serde-wasm-bindgen = { version = "0.5" }
tracing = { version = "0.1" }
tracing-futures = "0.2"
tsify = { version = "0.4.5" }
thiserror = "1.0"

# version for `[email protected]`, see:
# https://github.com/rustwasm/wasm-bindgen/pull/4072/
Expand Down
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ clean-se-wasm:
@echo "Cleaning schema-engine/schema-engine-wasm/pkg" && \
cd schema-engine/schema-engine-wasm/pkg && find . ! -name '.' ! -name '..' ! -name 'README.md' -exec rm -rf {} +

clean-qc-wasm:
@echo "Cleaning query-compiler/query-compiler-wasm/pkg" && \
cd query-compiler/query-compiler-wasm/pkg && find . ! -name '.' ! -name '..' ! -name 'README.md' -exec rm -rf {} +

clean-cargo:
@echo "Cleaning cargo" && \
cargo clean

clean: clean-qe-wasm clean-cargo
clean: clean-qe-wasm clean-se-wasm clean-qc-wasm clean-cargo

###################
# script wrappers #
Expand Down Expand Up @@ -79,6 +83,10 @@ build-se-wasm:
cd schema-engine/schema-engine-wasm && \
./build.sh $(QE_WASM_VERSION) schema-engine/schema-engine-wasm/pkg

build-qc-wasm:
cd query-compiler/query-compiler-wasm && \
./build.sh $(QE_WASM_VERSION) query-compiler/query-compiler-wasm/pkg

build-schema-wasm:
@printf '%s\n' "🛠️ Building the Rust crate"
cargo build --profile $(PROFILE) --target=wasm32-unknown-unknown -p prisma-schema-build
Expand All @@ -93,7 +101,12 @@ build-schema-wasm:
pedantic:
RUSTFLAGS="-D warnings" cargo fmt -- --check
RUSTFLAGS="-D warnings" cargo clippy --all-features --all-targets
RUSTFLAGS="-D warnings" cargo clippy --all-features --all-targets -p query-engine-wasm -p schema-engine-wasm -p prisma-schema-build --target wasm32-unknown-unknown
RUSTFLAGS="-D warnings" cargo clippy --all-features --all-targets \
-p query-engine-wasm \
-p schema-engine-wasm \
-p query-compiler-wasm \
aqrln marked this conversation as resolved.
Show resolved Hide resolved
-p prisma-schema-build \
--target wasm32-unknown-unknown

release:
cargo build --release
Expand Down
7 changes: 7 additions & 0 deletions query-compiler/query-compiler-wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/target
**/*.rs.bk
Cargo.lock
bin/
pkg/
wasm-pack.log
node_modules/
40 changes: 40 additions & 0 deletions query-compiler/query-compiler-wasm/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[package]
name = "query-compiler-wasm"
version = "0.1.0"
edition = "2021"

[lib]
doc = false
crate-type = ["cdylib"]
name = "query_compiler_wasm"

[dependencies]
psl.workspace = true
quaint.workspace = true
tracing.workspace = true

js-sys.workspace = true
serde.workspace = true
serde_json.workspace = true
tsify.workspace = true
wasm-bindgen.workspace = true
wasm-rs-dbg.workspace = true
driver-adapters = { path = "../../query-engine/driver-adapters" }
query-core = { path = "../../query-engine/core" }
query-compiler = { path = "../query-compiler", default-features = false }
schema = { path = "../../query-engine/schema" }
request-handlers = { path = "../../query-engine/request-handlers", default-features = false }

[build-dependencies]
build-utils.path = "../../libs/build-utils"

[features]
sqlite = ["driver-adapters/sqlite", "psl/sqlite", "query-compiler/sqlite"]
postgresql = ["driver-adapters/postgresql", "psl/postgresql", "query-compiler/postgresql"]
mysql = ["driver-adapters/mysql", "psl/mysql", "query-compiler/mysql"]

[package.metadata.wasm-pack.profile.release]
wasm-opt = false # use wasm-opt explicitly in `./build.sh`

[package.metadata.wasm-pack.profile.profiling]
wasm-opt = false # use wasm-opt explicitly in `./build.sh`
3 changes: 3 additions & 0 deletions query-compiler/query-compiler-wasm/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
build_utils::store_git_commit_hash_in_env();
}
Loading
Loading