Skip to content

Avoid copy by using VectorView and update benchmark.py for sqlite-vec #42

Avoid copy by using VectorView and update benchmark.py for sqlite-vec

Avoid copy by using VectorView and update benchmark.py for sqlite-vec #42

Workflow file for this run

name: CI
on:
workflow_dispatch:
inputs:
upload_wheel:
description: 'whether/where to upload the wheel'
required: false
default: 'no'
type: 'choice'
options: ['no', 'pypi', 'testpypi']
publish_npm:
description: 'whether to publish the npm packages'
required: false
default: 'no'
type: 'choice'
options: ['no', 'yes']
pull_request:
branches:
- main
jobs:
build_wheels:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
# os: [ubuntu-latest, macos-13, macos-14]
# os: [windows-latest]
steps:
- uses: actions/checkout@v4
- uses: benjlevesque/[email protected]
id: short_sha
# Used to host cibuildwheel
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install cibuildwheel
run: python -m pip install cibuildwheel==2.19.2 pytest apsw numpy
- uses: ilammy/msvc-dev-cmd@v1
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: '3.29.6'
- name: Setup Ninja
uses: seanmiddleditch/gha-setup-ninja@v5
with:
version: 1.11.1
- name: Bootstrap vcpkg
run: |
git submodule update --init --recursive
python bootstrap_vcpkg.py
- name: Build wheels
run: python -m cibuildwheel --output-dir wheelhouse
- uses: actions/upload-artifact@v4
with:
name: vectorlite-wheel-${{ matrix.os }}-${{ steps.short_sha.outputs.sha }}
path: ./wheelhouse/*.whl
- name: Run python examples
shell: bash
run: |
for wheel in wheelhouse/*.whl; do
echo "Running examples for $wheel"
python -m pip install $wheel --force-reinstall
python -m pip install -r examples/requirements.txt
for example in examples/*.py; do
echo "Running $example"
python $example
done
done
- name: Run benchmark
shell: bash
run: |
python -m pip install -r benchmark/requirements.txt
python benchmark/benchmark.py
upload_wheels:
name: Upload wheels
if: ${{ github.event.inputs.upload_wheel != 'no' && github.event_name != 'pull_request' }}
needs: build_wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: benjlevesque/[email protected]
id: short_sha
# Download all artifacts
- uses: actions/download-artifact@v4
with:
path: ./wheelhouse
- name: Upload to test.pypi.org
if: ${{ github.event.inputs.upload_wheel == 'testpypi' }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TEST_PYPI_TOKEN }}
run: pipx run twine upload --repository testpypi wheelhouse/**/*.whl
- name: Upload to pypi.org
if: ${{ github.event.inputs.upload_wheel == 'pypi' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/release/')) }}
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: pipx run twine upload wheelhouse/**/*.whl
- name: Fail if uploading to pypi.org without a tag
if: ${{ github.event.inputs.upload_wheel == 'pypi' && !(startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/release/')) }}
run: |
echo "Error: Uploading to pypi.org requires a tag"
exit 1
publish_npm_pkgs:
name: Upload npm packages
if: ${{ github.event.inputs.publish_npm == 'yes' && github.event_name != 'pull_request' && (startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/release/')) }}
needs: build_wheels
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: benjlevesque/[email protected]
id: short_sha
# Download all artifacts
- uses: actions/download-artifact@v4
with:
path: ./wheelhouse
# extract vectorlite from wheels and copy to nodejs bindings directory
- name: unzip wheels
run: |
sh extract_wheels.sh
- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
- name: Test locally
working-directory: bindings/nodejs/packages/vectorlite
run: |
npm i -D
npm link ../vectorlite-linux-x64
npm run test
- name: Publish to npm
working-directory: bindings/nodejs
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
run: |
mv package.json.tpl package.json
npm publish --workspaces --access public