-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathjustfile
59 lines (48 loc) · 1.47 KB
/
justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
host := "localhost"
database := "postgres"
# Build the `wasm` extension.
build:
PG_INCLUDE_PATH=$(pg_config --includedir-server) cargo build --release
# Install the `wasm` extension
install:
cd src && make install
# Activate and initialize the extension.
activate:
echo 'CREATE EXTENSION wasm;' | \
psql -h {{host}} -d {{database}}
echo "SELECT wasm_init('$(pwd)/target/release/libpg_ext_wasm.dylib');" | \
psql -h {{host}} -d {{database}}
# Test the `wasm` extension.
test:
#!/usr/bin/env bash
set -euo pipefail
case "{{os()}}" in
"macos")
dylib_extension="dylib"
;;
"windows")
dylib_extension="dll"
;;
*)
dylib_extension="so"
esac
echo 'DROP EXTENSION IF EXISTS wasm; CREATE EXTENSION wasm;' | psql -h $(pwd)/tests/pg -d postgres
echo "SELECT wasm_init('$(pwd)/target/release/libpg_ext_wasm.${dylib_extension}');" | psql -h $(pwd)/tests/pg -d postgres --echo-all
PG_INCLUDE_PATH=$(pg_config --includedir-server) cargo test --release --tests
# Initialize Postgres.
pg-init:
pg_ctl init -D $(pwd)/tests/pg
# Start Postgres.
pg-start:
pg_ctl -o "-k $(pwd)/tests/pg" start -D $(pwd)/tests/pg -l $(pwd)/tests/pg/pg.log
# Stop Postgres.
pg-stop:
pg_ctl -o "-k $(pwd)/tests/pg" stop -D $(pwd)/tests/pg
# Start a shell into Postgres.
pg-shell:
psql -h $(pwd)/tests/pg -d postgres
pg-run-one-file FILE:
sed -e "s,%cwd%,$(pwd)," {{FILE}} | psql -h $(pwd)/tests/pg -d postgres --no-align | sed -e "s,$(pwd),%cwd%,"
# Local Variables:
# mode: makefile
# End: