diff --git a/.github/workflows/deploy-docs-netlify.yml b/.github/workflows/deploy-docs-netlify.yml new file mode 100644 index 000000000..60e82cda5 --- /dev/null +++ b/.github/workflows/deploy-docs-netlify.yml @@ -0,0 +1,95 @@ +name: Build and Deploy to Netlify +on: + push: + branches: + - main +permissions: + contents: write +jobs: + build-and-deploy: + concurrency: ci-${{ github.ref }} + runs-on: ubuntu-latest + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4 + + - name: Setup Rust nightly for WASM + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly-2025-11-15 + target: wasm32-unknown-unknown + override: true + + - name: Cache Rust dependencies + uses: actions/cache@v3 + with: + path: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + ahnlich/target/ + key: ${{ runner.os }}-cargo-wasm-${{ hashFiles('**/Cargo.lock') }} + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Install esbuild + run: npm install -g esbuild + + - name: Build SDK (for protobuf types) + run: | + cd sdk/ahnlich-client-node + npm install + npm run build + echo "SDK built at sdk/ahnlich-client-node/dist/" + + - name: Generate protobuf entry point + run: | + cat > ahnlich/wasm-db/protobuf-entry.js << 'EOF' + // Import and re-export with namespaces to avoid conflicts + import * as queryPb from '../../sdk/ahnlich-client-node/dist/grpc/db/query_pb.js'; + import * as serverPb from '../../sdk/ahnlich-client-node/dist/grpc/db/server_pb.js'; + import * as keyvalPb from '../../sdk/ahnlich-client-node/dist/grpc/keyval_pb.js'; + import * as metadataPb from '../../sdk/ahnlich-client-node/dist/grpc/metadata_pb.js'; + import * as predicatePb from '../../sdk/ahnlich-client-node/dist/grpc/predicate_pb.js'; + + // Export all individual types from keyval, metadata, predicate (no conflicts) + export * from '../../sdk/ahnlich-client-node/dist/grpc/keyval_pb.js'; + export * from '../../sdk/ahnlich-client-node/dist/grpc/metadata_pb.js'; + export * from '../../sdk/ahnlich-client-node/dist/grpc/predicate_pb.js'; + + // Export query and server as namespaces to avoid conflicts + export { queryPb, serverPb }; + EOF + echo "Protobuf entry point generated" + + - name: Build WASM package + run: | + cd ahnlich/wasm-db + chmod +x build.sh + ./build.sh + echo "WASM package built at ahnlich/wasm-db/pkg/" + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'yarn' + cache-dependency-path: web/ahnlich-web/yarn.lock + + - name: Install and Build Docusaurus 🔧 + working-directory: web/ahnlich-web + run: | + export G_TRACKING_ID=${{ secrets.G_TRACKING_ID }} + yarn install --frozen-lockfile + yarn run build + touch build/.nojekyll + cp netlify.toml build/netlify.toml + + - name: Deploy to gh-pages-netlify 🚀 + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: web/ahnlich-web/build + branch: gh-pages-netlify + clean: true diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml deleted file mode 100644 index 4a474bbb3..000000000 --- a/.github/workflows/pages.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build and Deploy -on: - push: - branches: - - main -permissions: - contents: write -jobs: - build-and-deploy: - concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession. - runs-on: ubuntu-latest - steps: - - name: Checkout 🛎️ - uses: actions/checkout@v4 - - - name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. - working-directory: web/ahnlich-web - run: | - export G_TRACKING_ID=${{ secrets.G_TRACKING_ID }} - yarn install - yarn run build - touch build/.nojekyll - echo "ahnlich.dev" >> build/CNAME - - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4 - with: - folder: web/ahnlich-web/build # The folder the action should deploy. diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b77fd40ef..9f4e2dbb1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -79,6 +79,36 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} shell: bash + build_wasm_and_publish: + needs: prebuild_preparation + name: Build WASM package + runs-on: ubuntu-latest + if: ${{needs.prebuild_preparation.outputs.bin_name == 'ahnlich-db'}} + steps: + - name: "Checkout" + uses: actions/checkout@v4 + + - name: Get Cargo toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: 1.97.1 + target: wasm32-unknown-unknown + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Build WASM package + working-directory: ./ahnlich/wasm-db + run: | + wasm-pack build --target web --out-dir pkg + tar -cvzf ahnlich-wasm-db.tar.gz pkg/ + + - name: Upload WASM package to release + working-directory: ./ahnlich/wasm-db + run: gh release upload ${{github.event.release.tag_name}} ahnlich-wasm-db.tar.gz + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + push_to_registries: needs: prebuild_preparation name: Push Docker image to multiple registries diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 87f78419b..c0884df18 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -104,7 +104,6 @@ jobs: working-directory: ./ahnlich run: cargo nextest run --workspace --exclude ai --no-capture - - name: Upload Test Results uses: actions/upload-artifact@v4 if: always() @@ -113,6 +112,7 @@ jobs: path: ahnlich/target/nextest/default/rust.xml + run-python-tests: if: always() runs-on: ubuntu-latest @@ -361,6 +361,12 @@ jobs: name: node path: ./node + - name: Download WASM Test Output + uses: actions/download-artifact@v4 + with: + name: wasm + path: ./wasm + - name: Publish Test Results uses: EnricoMi/publish-unit-test-result-action/macos@v2 if: always() @@ -370,3 +376,4 @@ jobs: python/*.xml go/*.xml node/*.xml + wasm/*.xml diff --git a/README.md b/README.md index f77dde105..bd143880e 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,7 @@

+ Search 1,000 passages across 4 George Orwell books using vector similarity +
++ Books: Animal Farm • 1984 • Homage to Catalonia • Down and Out in Paris and London +
++ Embeddings: Transformers.js (all-MiniLM-L6-v2) • Vector DB: Ahnlich WASM +
+How it works
++ This demo uses multi-threaded WASM to store and search vectors. Click any item to find similar ones using cosine similarity. + The visualization shows a 2D projection of high-dimensional (128-dim) vectors. +
+