Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
13 changes: 8 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ jobs:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: "clippy --workspace --all-targets"
run: cargo clippy --locked --workspace --all-targets --no-deps --config "$RUST_CONFIG" -- -Dwarnings
run: cargo clippy --locked --workspace --exclude DiskAnnPy --all-targets --no-deps --config "$RUST_CONFIG" -- -Dwarnings
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did we manage to avoid -exclude DiskAnnPy in ADO?


clippy-features:
strategy:
Expand All @@ -114,6 +114,7 @@ jobs:
run: |
set -euxo pipefail
cargo clippy --locked --workspace \
--exclude DiskAnnPy \
--all-targets \
--no-deps \
--features ${{ env.DISKANN_FEATURES }} \
Expand Down Expand Up @@ -187,7 +188,7 @@ jobs:
- uses: Swatinem/rust-cache@v2

- name: Build workspace
run: cargo build --workspace --locked --profile ci
run: cargo build --workspace --exclude DiskAnnPy --locked --profile ci

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down Expand Up @@ -371,8 +372,8 @@ jobs:
- name: test workspace with nextest
run: |
set -euxo pipefail
cargo nextest run --locked --workspace --cargo-profile ci --config "$RUST_CONFIG"
cargo test --locked --doc --workspace --profile ci --config "$RUST_CONFIG"
cargo nextest run --locked --workspace --exclude DiskAnnPy --cargo-profile ci --config "$RUST_CONFIG"
cargo test --locked --doc --workspace --exclude DiskAnnPy --profile ci --config "$RUST_CONFIG"

test-workspace-features:
needs: basics
Expand Down Expand Up @@ -406,11 +407,12 @@ jobs:
run: |
set -euxo pipefail
cargo nextest run --locked --workspace \
--exclude DiskAnnPy \
--cargo-profile ci \
--config "$RUST_CONFIG" \
--features ${{ env.DISKANN_FEATURES }}

cargo test --locked --doc --workspace --profile ci --config "$RUST_CONFIG"
cargo test --locked --doc --workspace --exclude DiskAnnPy --profile ci --config "$RUST_CONFIG"

coverage:
needs: basics
Expand Down Expand Up @@ -446,6 +448,7 @@ jobs:
cargo llvm-cov nextest --locked --cargo-profile ci \
--config "$RUST_CONFIG" \
--workspace \
--exclude DiskAnnPy \
--lcov --output-path lcov.info

- name: Generate miri code coverage
Expand Down
200 changes: 200 additions & 0 deletions .github/workflows/publish-diskannpy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT license.

# Workflow: Build and publish diskannpy Python wheels to PyPI
#
# Triggers:
# - Manual dispatch (workflow_dispatch) for testing
# - On GitHub Release publish (the primary release mechanism)
#
# Architecture:
# 1. Build wheels for Linux (x86_64, aarch64) and Windows (x86_64) across
# Python 3.9-3.13 using maturin-action.
# 2. Build an sdist for source distribution.
# 3. Run tests on the built wheels to validate correctness.
# 4. Publish to PyPI using Trusted Publishing (OIDC).

name: Publish diskannpy to PyPI

on:
workflow_dispatch:
inputs:
publish:
description: "Publish to PyPI (false = build only)"
required: true
default: "false"
type: choice
options:
- "true"
- "false"
release:
types: [published]

permissions:
contents: read

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

env:
RUST_BACKTRACE: 1

jobs:
# ===========================================================================
# Build manylinux wheels (x86_64)
# ===========================================================================
build-linux-x86_64:
name: Build Linux x86_64 (Python ${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4

- uses: PyO3/maturin-action@v1
with:
target: x86_64
manylinux: auto
args: --release --out dist --manifest-path DiskAnnPy/Cargo.toml -i python${{ matrix.python }}

- uses: actions/upload-artifact@v4
with:
name: wheel-linux-x86_64-py${{ matrix.python }}
path: dist/*.whl
if-no-files-found: error

# NOTE: aarch64 builds are disabled because DiskAnnPy currently only
# compiles on x86_64 (see lib.rs cfg_if guard). Re-enable once the
# aarch64 linking issue is resolved.

# ===========================================================================
# Build Windows wheels (x86_64)
# ===========================================================================
build-windows-x86_64:
name: Build Windows x86_64 (Python ${{ matrix.python }})
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- uses: PyO3/maturin-action@v1
with:
target: x86_64
args: --release --out dist --manifest-path DiskAnnPy/Cargo.toml -i python${{ matrix.python }}

- uses: actions/upload-artifact@v4
with:
name: wheel-windows-x86_64-py${{ matrix.python }}
path: dist/*.whl
if-no-files-found: error

# NOTE: macOS universal2 builds are disabled because DiskAnnPy currently
# only compiles on x86_64 (see lib.rs cfg_if guard). Re-enable once the
# aarch64 linking issue is resolved.

# ===========================================================================
# Build source distribution
# ===========================================================================
build-sdist:
name: Build sdist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist --manifest-path DiskAnnPy/Cargo.toml

- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz
if-no-files-found: error

# ===========================================================================
# Test the built wheels
# ===========================================================================
test-wheels:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should run the python test for every PR as well ensuring that DiskAnnPy is not broken by changes in both Python and Rust code bases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A side question: will we calculate the code coverage in Python.

name: Test wheel (${{ matrix.os }}, Python ${{ matrix.python }})
needs: [build-linux-x86_64, build-windows-x86_64]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python: "3.10"
artifact: wheel-linux-x86_64-py3.10
- os: ubuntu-latest
python: "3.12"
artifact: wheel-linux-x86_64-py3.12
- os: windows-latest
python: "3.10"
artifact: wheel-windows-x86_64-py3.10
steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}

- uses: actions/download-artifact@v4
with:
name: ${{ matrix.artifact }}
path: dist

- name: Install wheel and test dependencies
shell: bash
run: |
pip install dist/*.whl
pip install scikit-learn numpy

- name: Run tests
shell: bash
working-directory: DiskAnnPy
run: python -m unittest discover tests

# ===========================================================================
# Publish to PyPI
# ===========================================================================
publish:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: [test-wheels, build-sdist]
if: >-
(github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.publish == 'true')
# Trusted Publishing: requires configuring PyPI to trust this workflow.
# See: https://docs.pypi.org/trusted-publishers/creating-a-project-through-oidc/
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v4
with:
pattern: "wheel-*"
path: dist
merge-multiple: true

- uses: actions/download-artifact@v4
with:
name: sdist
path: dist

- name: List artifacts
run: ls -lhR dist/

- uses: pypa/gh-action-pypi-publish@release/v1
with:
# No password needed: uses OIDC Trusted Publishing
verbose: true
Loading
Loading