Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add CI lint and build test #41

Merged
merged 10 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Rust

on:
pull_request:
paths:
- '.github/workflows/rust.yml'
- 'src/**'
- 'Cargo.lock'
- 'Cargo.toml'
- '*.control'
- 'rust-toolchain.toml'
push:
branches:
- main
paths:
- '.github/workflows/rust.yml'
- 'src/**'
- 'Cargo.lock'
- 'Cargo.toml'
- '*.control'
- 'rust-toolchain.toml'
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"
CARGO_PROFILE_OPT_BUILD_OVERRIDE_DEBUG: true

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
arch: ["x86_64", "aarch64"]
env:
PGRX_IMAGE: "kemingy/pgrx:0.12.6"
kemingy marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v4
- name: Cache
uses: mozilla-actions/[email protected]
kemingy marked this conversation as resolved.
Show resolved Hide resolved
- name: Set up docker images and permissions
run: |
docker pull $PGRX_IMAGE
echo "Default user: $(id -u):$(id -g)"
sudo chown -R 1000:1000 .

- name: Clippy
run: |
for v in {14..17}; do
docker run --rm -v .:/workspace $PGRX_IMAGE clippy --target ${{ matrix.arch }}-unknown-linux-gnu --features "pg$v" -- -D warnings
done
- name: Build
run: |
for v in {14..17}; do
docker run --rm -v .:/workspace $PGRX_IMAGE build --lib --target ${{ matrix.arch }}-unknown-linux-gnu --features "pg$v"
done
- name: Test
run: |
# pg agnostic tests
docker run --rm -v .:/workspace $PGRX_IMAGE test --no-fail-fast --target ${{ matrix.arch }}-unknown-linux-gnu --features pg17
kemingy marked this conversation as resolved.
Show resolved Hide resolved
39 changes: 39 additions & 0 deletions .github/workflows/style.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Style

on:
pull_request:
branches:
- main
push:
branches:
- main
merge_group:
workflow_dispatch:

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always

jobs:
lint:
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v4

- name: Typos
uses: crate-ci/typos@master

- name: TOML lint
run: |
curl -fsSL https://github.com/tamasfe/taplo/releases/latest/download/taplo-full-linux-x86_64.gz | gzip -d - | install -m 755 /dev/stdin /usr/local/bin/taplo
taplo fmt --check

- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
kemingy marked this conversation as resolved.
Show resolved Hide resolved
- name: Cargo Lint
run: |
cargo fmt -- --check
kemingy marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 18 additions & 0 deletions .taplo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[formatting]
indent_string = " "

[[rule]]
keys = ["dependencies", "*-denpendencies", "lints", "patch.*"]

[rule.formatting]
reorder_keys = true
reorder_arrays = true
align_comments = true

[[rule]]
keys = ["profile.*"]

[rule.formatting]
reorder_keys = true
reorder_arrays = true
align_comments = true
kemingy marked this conversation as resolved.
Show resolved Hide resolved
19 changes: 10 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,21 @@ pg16 = ["pgrx/pg16", "pgrx-catalog/pg16"]
pg17 = ["pgrx/pg17", "pgrx-catalog/pg17"]

[dependencies]
paste = "1"
pgrx = { version = "=0.12.8", default-features = false, features = ["cshim"] }
pgrx-catalog = "0.1.0"
rand = "0.8.5"
rand_chacha = "0.3.1"
rand_distr = "0.4.3"
serde = "1"
toml = "0.8.19"
validator = "0.18.1"

base = { git = "https://github.com/tensorchord/pgvecto.rs.git", branch = "rabbithole-2" }
common = { git = "https://github.com/tensorchord/pgvecto.rs.git", branch = "rabbithole-2" }
detect = { git = "https://github.com/tensorchord/pgvecto.rs.git", branch = "rabbithole-2" }
k_means = { git = "https://github.com/tensorchord/pgvecto.rs.git", branch = "rabbithole-2" }
quantization = { git = "https://github.com/tensorchord/pgvecto.rs.git", branch = "rabbithole-2" }
paste = "1"
serde = "1"
toml = "0.8.19"
rand = "0.8.5"
rand_chacha = "0.3.1"
rand_distr = "0.4.3"
validator = "0.18.1"

# lock algebra version forever so that the QR decomposition never changes for same input
nalgebra = { version = "=0.33.0", default-features = false }
Expand All @@ -48,12 +49,12 @@ rust.unused_lifetimes = "warn"
rust.unused_qualifications = "warn"

[profile.opt]
debug-assertions = false
inherits = "dev"
opt-level = 3
debug-assertions = false
overflow-checks = false

[profile.release]
lto = "fat"
codegen-units = 1
debug = true
lto = "fat"
2 changes: 1 addition & 1 deletion bench/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async def main(dataset):
await add_embeddings(conn, args.name, args.dim, dataset["train"])

index_finish = asyncio.Event()
# Need a seperate connection for monitor process
# Need a separate connection for monitor process
monitor_conn = await create_connection(url)
monitor_task = monitor_index_build(
monitor_conn,
Expand Down
38 changes: 38 additions & 0 deletions docker/pgrx.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# CNPG only support Debian 12 (Bookworm)
FROM ubuntu:22.04

ARG PGRX_VERSION=0.12.6

ENV DEBIAN_FRONTEND=noninteractive \
LANG=en_US.UTF-8 \
LC_ALL=en_US.UTF-8 \
RUSTFLAGS="-Dwarnings"

RUN apt update && \
apt install -y --no-install-recommends \
curl \
ca-certificates \
build-essential \
crossbuild-essential-arm64 \
qemu-user-static \
libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc ccache pkg-config \
clang && \
rm -rf /var/lib/apt/lists/*

# create a non-root user (make it compatible with Ubuntu 24.04)
RUN useradd -u 1000 -U -m ubuntu
USER ubuntu
ENV PATH="$PATH:/home/ubuntu/.cargo/bin"
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --default-toolchain=none -y

WORKDIR /workspace
COPY rust-toolchain.toml /workspace/rust-toolchain.toml
RUN set -ex; \
echo 'target.aarch64-unknown-linux-gnu.linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml; \
echo 'target.aarch64-unknown-linux-gnu.runner = ["qemu-aarch64-static", "-L", "/usr/aarch64-linux-gnu"]' >> ~/.cargo/config.toml
RUN rustup target add x86_64-unknown-linux-gnu aarch64-unknown-linux-gnu

RUN cargo install cargo-pgrx --locked --version=${PGRX_VERSION} && \
cargo pgrx init

ENTRYPOINT [ "cargo" ]
Loading