Skip to content

Commit 5dcf40a

Browse files
feat(hyperbytedb-cli): Add hyperbytedb-cli subcommand for interactive shell, batch queries, and write/import (#8)
* feat(hyperbytedb-cli): Add hyperbytedb-cli subcommand for interactive shell, batch queries, and write/import
1 parent d31631d commit 5dcf40a

38 files changed

Lines changed: 3063 additions & 83 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
# Clone hyperbyte-cloud/chdb-rust next to the hyperbytedb checkout.
3+
#
4+
# hyperbytedb/hyperbytedb/Cargo.toml uses path = "../../chdb-rust", which resolves
5+
# to a sibling of GITHUB_WORKSPACE (the hyperbytedb repo root):
6+
# <runner-work>/hyperbytedb/hyperbytedb <- GITHUB_WORKSPACE
7+
# <runner-work>/chdb-rust <- this script
8+
set -euo pipefail
9+
10+
: "${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is required}"
11+
12+
CHDB_RUST_REPO="${CHDB_RUST_REPO:-https://github.com/hyperbyte-cloud/chdb-rust.git}"
13+
CHDB_RUST_REF="${CHDB_RUST_REF:-feat_arrow_insert}"
14+
DEST="$(dirname "${GITHUB_WORKSPACE}")/chdb-rust"
15+
16+
echo "Checking out ${CHDB_RUST_REPO} @ ${CHDB_RUST_REF} -> ${DEST}"
17+
18+
if [[ -d "${DEST}/.git" ]]; then
19+
git -C "${DEST}" fetch --depth 1 origin "${CHDB_RUST_REF}"
20+
git -C "${DEST}" checkout FETCH_HEAD
21+
else
22+
git clone --depth 1 --branch "${CHDB_RUST_REF}" "${CHDB_RUST_REPO}" "${DEST}"
23+
fi
24+
25+
echo "chdb-rust HEAD: $(git -C "${DEST}" rev-parse --short HEAD)"
26+
27+
if [[ ! -f "${DEST}/Cargo.toml" ]]; then
28+
echo "error: ${DEST}/Cargo.toml not found after checkout" >&2
29+
exit 1
30+
fi
31+
32+
# Verify the path dependency from the main crate resolves on the host.
33+
CRATE_MANIFEST="${GITHUB_WORKSPACE}/hyperbytedb/Cargo.toml"
34+
if [[ -f "${CRATE_MANIFEST}" ]]; then
35+
RESOLVED="$(python3 -c "import os; print(os.path.normpath(os.path.join(os.path.dirname('${CRATE_MANIFEST}'), '../../chdb-rust')))")"
36+
if [[ ! -f "${RESOLVED}/Cargo.toml" ]]; then
37+
echo "error: path dependency does not resolve (${RESOLVED})" >&2
38+
exit 1
39+
fi
40+
echo "path dependency resolves to: ${RESOLVED}"
41+
fi

.github/scripts/run-in-rust-container.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ fi
1414
command=$1
1515
RUST_IMAGE="${RUST_IMAGE:-rust:bookworm}"
1616
WORKSPACE="${GITHUB_WORKSPACE:?GITHUB_WORKSPACE is required}"
17+
# chdb-rust is checked out as a sibling of GITHUB_WORKSPACE (see checkout-chdb-rust.sh).
18+
# Mount the parent directory so path = "../../chdb-rust" resolves inside the container.
19+
WORKSPACE_PARENT="$(dirname "${WORKSPACE}")"
1720

1821
if ! command -v docker >/dev/null 2>&1; then
1922
echo "docker is required but was not found on PATH." >&2
@@ -23,7 +26,7 @@ fi
2326

2427
docker_args=(
2528
--rm
26-
-v "${WORKSPACE}:${WORKSPACE}"
29+
-v "${WORKSPACE_PARENT}:${WORKSPACE_PARENT}"
2730
-w "${WORKSPACE}"
2831
-e "CARGO_TERM_COLOR=${CARGO_TERM_COLOR:-always}"
2932
-e "RUSTFLAGS=${RUSTFLAGS:-}"

.github/workflows/ci.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ env:
1414
CARGO_TERM_COLOR: always
1515
CARGO_INCREMENTAL: 0
1616
RUSTFLAGS: "-D warnings"
17+
CHDB_RUST_REPO: https://github.com/hyperbyte-cloud/chdb-rust.git
18+
CHDB_RUST_REF: feat_arrow_insert
1719

1820
jobs:
1921
doc_links:
@@ -35,6 +37,9 @@ jobs:
3537
steps:
3638
- uses: actions/checkout@v4
3739

40+
- name: Checkout chdb-rust
41+
run: bash .github/scripts/checkout-chdb-rust.sh
42+
3843
- name: Install CI dependencies
3944
uses: ./.github/actions/install-ci-deps
4045
with:
@@ -43,7 +48,7 @@ jobs:
4348
- name: Check formatting
4449
run: |
4550
bash .github/scripts/run-in-rust-container.sh \
46-
'rustup component add rustfmt && cargo fmt --all --check'
51+
'rustup component add rustfmt && cargo fmt --check'
4752
4853
clippy:
4954
name: Clippy
@@ -52,6 +57,9 @@ jobs:
5257
steps:
5358
- uses: actions/checkout@v4
5459

60+
- name: Checkout chdb-rust
61+
run: bash .github/scripts/checkout-chdb-rust.sh
62+
5563
- name: Install CI dependencies
5664
uses: ./.github/actions/install-ci-deps
5765
with:
@@ -71,6 +79,9 @@ jobs:
7179
steps:
7280
- uses: actions/checkout@v4
7381

82+
- name: Checkout chdb-rust
83+
run: bash .github/scripts/checkout-chdb-rust.sh
84+
7485
- name: Install CI dependencies
7586
uses: ./.github/actions/install-ci-deps
7687
with:
@@ -95,6 +106,9 @@ jobs:
95106
steps:
96107
- uses: actions/checkout@v4
97108

109+
- name: Checkout chdb-rust
110+
run: bash .github/scripts/checkout-chdb-rust.sh
111+
98112
- name: Install CI dependencies
99113
uses: ./.github/actions/install-ci-deps
100114
with:

.github/workflows/release.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name: Release
99
# stage per platform and package:
1010
# - hyperbytedb-<tag>-linux-x86_64.tar.gz (amd64 / x64)
1111
# - hyperbytedb-<tag>-linux-aarch64.tar.gz (arm64)
12-
# Each tarball contains hyperbytedb + matching libchdb.so, plus a sha256.
12+
# Each tarball contains hyperbytedb, hyperbytedb-cli, and matching libchdb.so, plus a sha256.
1313
# 3. Publish a GitHub Release for the tag with the tarballs attached.
1414
#
1515
# Jobs run directly on the ARC runner pod (not inside a job container) so
@@ -28,6 +28,8 @@ concurrency:
2828
cancel-in-progress: false
2929

3030
env:
31+
CHDB_RUST_REPO: https://github.com/hyperbyte-cloud/chdb-rust.git
32+
CHDB_RUST_REF: feat_arrow_insert
3133
REGISTRY: ghcr.io
3234
# Canonical package; docs and operator manifests reference
3335
# ghcr.io/hyperbyte-cloud/hyperbytedb. Hardcoded because github.repository
@@ -44,6 +46,9 @@ jobs:
4446
steps:
4547
- uses: actions/checkout@v4
4648

49+
- name: Checkout chdb-rust
50+
run: bash .github/scripts/checkout-chdb-rust.sh
51+
4752
- name: Install CI dependencies
4853
uses: ./.github/actions/install-ci-deps
4954
with:
@@ -107,7 +112,7 @@ jobs:
107112
-f hyperbytedb/Dockerfile \
108113
..
109114
NAME="hyperbytedb-${TAG}-linux-x86_64"
110-
tar -C staging-x86_64 -czf "out/${NAME}.tar.gz" hyperbytedb libchdb.so
115+
tar -C staging-x86_64 -czf "out/${NAME}.tar.gz" hyperbytedb hyperbytedb-cli libchdb.so
111116
( cd out && sha256sum "${NAME}.tar.gz" > "${NAME}.tar.gz.sha256" )
112117
ls -lh "out/${NAME}.tar.gz" "out/${NAME}.tar.gz.sha256"
113118
@@ -126,7 +131,7 @@ jobs:
126131
-f hyperbytedb/Dockerfile \
127132
..
128133
NAME="hyperbytedb-${TAG}-linux-aarch64"
129-
tar -C staging-aarch64 -czf "out/${NAME}.tar.gz" hyperbytedb libchdb.so
134+
tar -C staging-aarch64 -czf "out/${NAME}.tar.gz" hyperbytedb hyperbytedb-cli libchdb.so
130135
( cd out && sha256sum "${NAME}.tar.gz" > "${NAME}.tar.gz.sha256" )
131136
ls -lh "out/${NAME}.tar.gz" "out/${NAME}.tar.gz.sha256"
132137

0 commit comments

Comments
 (0)