Skip to content

feat: maxsim operator and indexing on maxsim operator (#197) #119

feat: maxsim operator and indexing on maxsim operator (#197)

feat: maxsim operator and indexing on maxsim operator (#197) #119

Workflow file for this run

name: Check
on:
pull_request:
paths:
- ".cargo"
- ".github/workflows/check.yml"
- "crates/**"
- "scripts/**"
- "src/**"
- "tests/**"
- "build.rs"
- "Cargo.lock"
- "Cargo.toml"
- "rust-toolchain.toml"
- "rustfmt.toml"
- "taplo.toml"
- "vchord.control"
push:
paths:
- ".cargo"
- ".github/workflows/check.yml"
- "crates/**"
- "scripts/**"
- "src/**"
- "tests/**"
- "build.rs"
- "Cargo.lock"
- "Cargo.toml"
- "rust-toolchain.toml"
- "rustfmt.toml"
- "taplo.toml"
- "vchord.control"
merge_group:
workflow_dispatch:
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
SCCACHE_GHA_ENABLED: true
RUSTC_WRAPPER: sccache
RUSTFLAGS: "-Dwarnings"
jobs:
style:
runs-on: "ubuntu-latest"
steps:
- name: Set up Environment
run: |
curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-$(uname -m).gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo
- name: Checkout
uses: actions/checkout@v4
- name: Typos
uses: crate-ci/typos@master
- name: Taplo
run: taplo fmt --check
- name: Ruff
uses: astral-sh/ruff-action@v1
- name: Rustfmt
run: cargo fmt --check
- name: SQL
run: |
! grep -P '\t' -r ./sql
lint:
strategy:
matrix:
arch: ["x86_64", "aarch64"]
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }}
steps:
- name: Set up Environment
run: |
sudo apt-get update
if [ "$(uname -m)" == "x86_64" ]; then
wget https://downloadmirror.intel.com/843185/sde-external-9.48.0-2024-11-25-lin.tar.xz -O /tmp/sde-external.tar.xz
sudo tar -xf /tmp/sde-external.tar.xz -C /opt
sudo mv /opt/sde-external-9.48.0-2024-11-25-lin /opt/sde
fi
if [ "$(uname -m)" == "aarch64" ]; then
sudo apt-get install -y qemu-user-static
fi
- name: Set up Sccache
uses: mozilla-actions/sccache-action@v0.0.7
- name: Checkout
uses: actions/checkout@v4
- name: Clippy
run: cargo clippy --workspace --exclude vchord
- name: Cargo Test
run: cargo test --workspace --exclude vchord --exclude simd --no-fail-fast
- name: Cargo Test (simd)
run: |
cargo test -p simd --release -- --nocapture
if [ "$(uname -m)" == "x86_64" ]; then
cargo \
--config 'target.'\''cfg(all())'\''.runner = ["/opt/sde/sde64", "-spr", "--"]' \
test -p simd --release -- --nocapture
fi
if [ "$(uname -m)" == "aarch64" ]; then
cargo \
--config 'target.'\''cfg(all())'\''.runner = ["qemu-aarch64-static", "-cpu", "max"]' \
test -p simd --release -- --nocapture
fi
psql:
strategy:
matrix:
version: ["13", "14", "15", "16", "17"]
arch: ["x86_64", "aarch64"]
runs-on: ${{ matrix.arch == 'x86_64' && 'ubuntu-22.04' || 'ubuntu-22.04-arm' }}
steps:
- name: Set up Environment
run: |
sudo apt-get update
sudo apt-get remove -y '^postgres.*' '^libpq.*'
sudo apt-get purge -y '^postgres.*' '^libpq.*'
curl --proto '=https' --tlsv1.2 -sSf https://apt.llvm.org/llvm.sh | sudo bash -s -- 18
sudo update-alternatives --install /usr/bin/clang clang $(which clang-18) 255
sudo apt-get install -y postgresql-common
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
sudo apt-get install -y postgresql-server-dev-${{ matrix.version }}
sudo apt-get install -y postgresql-${{ matrix.version }} postgresql-${{ matrix.version }}-pgvector
echo "local all all trust" | sudo tee /etc/postgresql/${{ matrix.version }}/main/pg_hba.conf
echo "host all all 127.0.0.1/32 trust" | sudo tee -a /etc/postgresql/${{ matrix.version }}/main/pg_hba.conf
echo "host all all ::1/128 trust" | sudo tee -a /etc/postgresql/${{ matrix.version }}/main/pg_hba.conf
sudo -iu postgres createuser -s -r $USER
sudo -iu postgres createdb -O $USER $USER
sudo -iu postgres psql -c 'ALTER SYSTEM SET shared_preload_libraries = "vchord.so"'
sudo systemctl stop postgresql
curl -fsSL https://github.com/tensorchord/pgrx/releases/download/v0.12.9/cargo-pgrx-v0.12.9-$(uname -m)-unknown-linux-musl.tar.gz | tar -xOzf - ./cargo-pgrx | install -m 755 /dev/stdin /usr/local/bin/cargo-pgrx
cargo pgrx init --pg${{ matrix.version }}=$(which pg_config)
curl -fsSL https://github.com/risinglightdb/sqllogictest-rs/releases/download/v0.26.4/sqllogictest-bin-v0.26.4-$(uname -m)-unknown-linux-musl.tar.gz | tar -xOzf - ./sqllogictest | install -m 755 /dev/stdin /usr/local/bin/sqllogictest
- name: Set up Sccache
uses: mozilla-actions/sccache-action@v0.0.7
- name: Checkout
uses: actions/checkout@v4
- name: Clippy
run: cargo clippy -p vchord --features pg${{ matrix.version }} -- --no-deps
- name: Install
run: cargo pgrx install -p vchord --features pg${{ matrix.version }} --release --sudo
- name: Sqllogictest
run: |
sudo systemctl start postgresql
psql -c 'CREATE EXTENSION IF NOT EXISTS vchord CASCADE;'
sqllogictest --db $USER --user $USER './tests/**/*.slt'
- name: Package
env:
SEMVER: "0.0.0"
VERSION: ${{ matrix.version }}
ARCH: ${{ matrix.arch }}
PLATFORM: ${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}
run: |
cat $(pg_config --sharedir)/extension/vchord--0.0.0.sql | expand -t 4 > ./sql/install/vchord--$SEMVER.sql
mkdir -p ./build/zip
cp -a ./sql/upgrade/. ./build/zip/
cp ./sql/install/vchord--$SEMVER.sql ./build/zip/vchord--$SEMVER.sql
sed -e "s/@CARGO_VERSION@/$SEMVER/g" < ./vchord.control > ./build/zip/vchord.control
cp ./target/release/libvchord.so ./build/zip/vchord.so
zip ./build/postgresql-${VERSION}-vchord_${SEMVER}_${ARCH}-linux-gnu.zip -j ./build/zip/*
mkdir -p ./build/deb
mkdir -p ./build/deb/DEBIAN
mkdir -p ./build/deb/usr/share/postgresql/$VERSION/extension/
mkdir -p ./build/deb/usr/lib/postgresql/$VERSION/lib/
for file in $(ls ./build/zip/*.sql | xargs -n 1 basename); do
cp ./build/zip/$file ./build/deb/usr/share/postgresql/$VERSION/extension/$file
done
for file in $(ls ./build/zip/*.control | xargs -n 1 basename); do
cp ./build/zip/$file ./build/deb/usr/share/postgresql/$VERSION/extension/$file
done
for file in $(ls ./build/zip/*.so | xargs -n 1 basename); do
cp ./build/zip/$file ./build/deb/usr/lib/postgresql/$VERSION/lib/$file
done
echo "Package: postgresql-${VERSION}-vchord
Version: ${SEMVER}-1
Section: database
Priority: optional
Architecture: ${PLATFORM}
Maintainer: Tensorchord <support@tensorchord.ai>
Description: Vector database plugin for Postgres, written in Rust, specifically designed for LLM
Homepage: https://vectorchord.ai/
License: AGPL-3 or Elastic-2" \
> ./build/deb/DEBIAN/control
(cd ./build/deb && md5sum usr/share/postgresql/$VERSION/extension/* usr/lib/postgresql/$VERSION/lib/*) > ./build/deb/DEBIAN/md5sums
dpkg-deb --root-owner-group -Zxz --build ./build/deb/ ./build/postgresql-${VERSION}-vchord_${SEMVER}-1_${PLATFORM}.deb
ls ./build
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts-psql-${{ matrix.version }}-${{ matrix.arch }}
path: |
./build/postgresql-${{ matrix.version }}-vchord_0.0.0_${{ matrix.arch }}-linux-gnu.zip
./build/postgresql-${{ matrix.version }}-vchord_0.0.0-1_${{ matrix.arch == 'x86_64' && 'amd64' || 'arm64' }}.deb
compression-level: 9
retention-days: 14