-
Notifications
You must be signed in to change notification settings - Fork 39
/
justfile
164 lines (132 loc) · 4.9 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Shows help command
default: help
export CARGO_TERM_COLOR := "always"
export PROTOC := justfile_directory() + "/deps/protoc/bin/protoc"
alias py := python
alias js := javascript
alias slt := sql-logic-tests
alias unit-tests := test
os_arch := os() + '-' + arch()
VENV := ".venv"
VENV_BIN := VENV / "bin"
# Run benchmarks subcommands. see `benchmarks/justfile` for more details.
bench cmd *args:
just benchmarks/{{cmd}} {{args}}
# Run py-glaredb subcommands. see `bindings/python/justfile` for more details.
python cmd *args: protoc
just bindings/python/{{cmd}} {{args}}
# Run js-glaredb subcommands. see `bindings/nodejs/justfile` for more details.
javascript cmd *args: protoc
just bindings/nodejs/{{cmd}} {{args}}
# Run glaredb server
run *args: protoc
cargo run --bin glaredb -- {{args}}
# Build glaredb.
build *args: protoc
cargo build --bin glaredb {{args}}
# Build glaredb with unstable_tokio flag.
#
# Need to run the local command with `--debug-tokio` argument.
build-debug-tokio *args:
RUSTFLAGS="--cfg tokio_unstable" CARGO_TARGET_DIR=tokio-unstable-target just build {{args}}
run-debug-tokio *args:
RUSTFLAGS="--cfg tokio_unstable" CARGO_TARGET_DIR=tokio-unstable-target just run {{args}}
# A zip archive will be placed in `target/dist` containing the release binary.
# Build the dist binary for release. The target can be overridden by passing in a target triple.
dist triple=target_triple: protoc
#!/usr/bin/env bash
set -euo pipefail
just build --release --target {{triple}}
src_path="target/{{triple}}/release/{{executable_name}}"
dest_path="target/dist/glaredb-{{triple}}.zip"
mkdir -p target/dist
cargo xtask zip --src $src_path --dst $dest_path
# Run tests with arbitrary arguments.
test *args: protoc
cargo test {{args}}
# Run doc tests.
doc-tests: protoc
just test --doc
# Run SQL Logic Tests.
sql-logic-tests *args: build
just slt-bin {{args}}
slt-bin *args:
./target/debug/glaredb sql-logic-tests {{args}}
slt-bin-debug *args:
./target/debug/glaredb -v sql-logic-tests {{args}}
# Run SQL Logic Tests over RPC
rpc-tests:
just slt --protocol=rpc "sqllogictests/*" \
--exclude "sqllogictests/cloud_instance" \
--exclude "sqllogictests/functions/cache_external_database_tables" \
--exclude "sqllogictests/functions/postgres"
# Check formatting.
fmt-check: protoc
cargo +nightly fmt --check
# Apply formatting.
fmt *args: protoc
cargo +nightly fmt {{args}}
# Run clippy.
clippy: protoc
cargo clippy --all --all-features -- --deny warnings
# combined target for all lint
lint: clippy fmt-check
# apply linting & clippy fixes.
fix: protoc
cargo clippy --fix --all --all-features --allow-staged --allow-dirty
cargo fix --all --allow-staged --allow-dirty
just fmt --all
# Displays help message.
help:
@just --list
protoc:
#!/bin/bash
if ! $PROTOC --version > /dev/null; then
echo "Installing protoc..." && \
curl -L {{protoc_url}} -o protoc.zip && \
rm -rf deps/protoc && \
mkdir -p deps/ && \
unzip -o protoc.zip -d deps/protoc && \
rm protoc.zip
fi
# Installs python dependencies for testing
venv:
if python3 -c "import virtualenv"; then python3 -m virtualenv {{VENV}}; else python3 -m venv {{VENV}}; fi
{{VENV_BIN}}/python -m pip install --upgrade pip
{{VENV_BIN}}/python -m pip install poetry
poetry:
{{VENV_BIN}}/poetry -C tests lock --no-update
{{VENV_BIN}}/poetry -C tests install --no-root
# Runs pytest in the tests directory.
pytest *args: poetry
{{VENV_BIN}}/poetry -C tests run pytest -v --rootdir={{invocation_directory()}}/tests {{ if args == "" {'tests'} else {args} }}
# private helpers below
# ---------------------
default_target_triple := if os_arch == "macos-x86_64" {
"x86_64-apple-darwin"
} else if os_arch == 'macos-aarch64' {
"aarch64-apple-darwin"
} else if os_arch == "linux-x86_64" {
"x86_64-unknown-linux-gnu"
} else if os_arch == "linux-aarch64" {
"aarch64-unknown-linux-gnu"
} else if os_arch == "windows-x86_64" {
"x86_64-pc-windows-msvc"
} else {
error("Unsupported platform: " + os_arch)
}
target_triple:= env_var_or_default("DIST_TARGET_TRIPLE", default_target_triple)
protoc_url := if os_arch == "macos-x86_64" {
"https://github.com/protocolbuffers/protobuf/releases/download/v23.1/protoc-23.1-osx-universal_binary.zip"
} else if os_arch == 'macos-aarch64' {
"https://github.com/protocolbuffers/protobuf/releases/download/v23.1/protoc-23.1-osx-universal_binary.zip"
} else if os_arch == "linux-x86_64" {
"https://github.com/protocolbuffers/protobuf/releases/download/v23.1/protoc-23.1-linux-x86_64.zip"
} else if os_arch == "linux-aarch64" {
"https://github.com/protocolbuffers/protobuf/releases/download/v23.1/protoc-23.1-linux-aarch_64.zip"
} else if os_arch == "windows-x86_64" {
"https://github.com/protocolbuffers/protobuf/releases/download/v23.1/protoc-23.1-win64.zip"
} else {
error("Unsupported platform: " + os_arch)
}
executable_name:= if os() == "windows" {"glaredb.exe"} else {"glaredb"}