Skip to content

Commit

Permalink
ci: fix wasm build script (#4519)
Browse files Browse the repository at this point in the history
The build script had an invalid `sed` command with an extra `''`
argument that caused it to fail with

```
sed: can't read s/name = "query_engine_wasm"/name = "query_engine"/g: No such file or directory
```

Example: https://github.com/prisma/prisma-engines/actions/runs/7090582268/job/19297872413

This is reproducible both on CI and locally for me. Perhaps it was
written for BSD sed and doesn't work with GNU sed (so it always fails on
Linux and also fails on macOS inside prisma-engines Nix flake but maybe
it works on macOS without Nix)?

Because of this, a broken package was published from CI.

The commit fixes the `sed` command and adds `set -e` so that errors like
this would fail CI instead of silently continuing and doing wrong
things.
  • Loading branch information
aqrln authored Dec 5, 2023
1 parent 0d724e3 commit a26fa4c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions query-engine/query-engine-wasm/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

# Call this script as `./build.sh <npm_version>`

OUT_VERSION="$1"
Expand All @@ -12,7 +14,7 @@ OUT_NPM_NAME="@prisma/query-engine-wasm"
# to avoid conflicts with libquery's `name = "query_engine"` library name declaration.
# This little `sed -i` trick below is a hack to publish "@prisma/query-engine-wasm"
# with the same binding filenames currently expected by the Prisma Client.
sed -i '' 's/name = "query_engine_wasm"/name = "query_engine"/g' Cargo.toml
sed -i 's/name = "query_engine_wasm"/name = "query_engine"/g' Cargo.toml

# use `wasm-pack build --release` on CI only
if [[ -z "$BUILDKITE" ]] && [[ -z "$GITHUB_ACTIONS" ]]; then
Expand All @@ -23,7 +25,7 @@ fi

wasm-pack build $BUILD_PROFILE --target $OUT_TARGET

sed -i '' 's/name = "query_engine"/name = "query_engine_wasm"/g' Cargo.toml
sed -i 's/name = "query_engine"/name = "query_engine_wasm"/g' Cargo.toml

sleep 1

Expand Down

0 comments on commit a26fa4c

Please sign in to comment.