Skip to content
Merged
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
67 changes: 67 additions & 0 deletions .github/CI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Native build reuse in CI

PR checks use `.github/scripts/ci_plan.py` and a merge-base diff (including both
sides of renames). Changes to native code, build configuration, dependencies or
CI helpers retain all five wheel platforms. CLI-only and Studio-only changes
build a Linux x86 wheel; Python runtime changes run API tests without building
release wheels. Independent plugin and SDK changes run their own checks.
Manual distribution builds and releases retain the full default matrix.

PR checks, API tests and Rust CLI checks cancel older runs for the same PR.
Release and scheduled runs are not cancelled by this policy.

The API workflow produces one Ubuntu 24.04 x86 native runtime with Python 3.10.
Its API test job (3.10) and cuVS job (3.11) reuse that same-run artifact. Both
native extensions target `cp310-abi3`. Restore requires matching commit, OS,
architecture, runtime libc, platform, build options and ABI, and validates every
file checksum before writing it. Other test platforms build locally. Release
wheels build independently in Ubuntu 20.04/macOS/Windows; Ubuntu 24.04 test
binaries and musl CLI binaries are never reused in release wheels.

Builds and ordinary tests use GitHub-hosted runners to measure build reuse and
cache behavior independently of self-hosted machine capacity. There is no
`ov-ci-runner` scheduling or manual selection in these workflows.
The existing P0 Memory Tests remain on their original ECS environment, selected
with `[self-hosted, Linux, X64, openviking-ecs]`. That runner must have the
`openviking-ecs` custom label; its display name alone does not select it.

The cuVS check now lives in the API workflow so it can consume the same artifact.
Its check name stays `cuvs-tests / Lite Test (ubuntu-24.04, 3.11)`, matching the
previous PR workflow. The caller job ID, reusable job name, Python version and
test list are preserved, so ordinary required status checks need no migration.

Cargo intermediates and ccache outputs are keyed by runner OS/architecture,
target and compiler fingerprint. Cargo also includes the lockfile. Both primary
keys end with the commit SHA so later main builds can save updated compiler
output into new immutable entries. Prefix restores select the newest compatible
cache, preferring the same Cargo lockfile before other entries for that toolchain.
Only non-PR runs on the official repository's `main`
branch save these caches; PR, fork and tag runs restore only. Ccache is capped at
256 MiB per entry and Cargo incremental output is disabled. Older main entries
remain subject to GitHub's cache quota and eviction. Source changes still rebuild
correctly through Cargo/ccache input validation.
Wheel building compiles each native component once.
Studio is built once per distribution workflow and downloaded by each wheel job.
Bootstrap/version/repair/test commands use `uv run --no-sync`; test environments
install dependencies first, then native binaries, then editable Python entry
points with native compilation disabled.

Markdown is not globally ignored at the workflow entry point or by the planner.
Known documentation trees and root README/security/contribution documents
skip API tests; runtime skills, prompt templates and bot workspace Markdown
select API tests, including newly introduced runtime paths.

Local checks:

```sh
python3 -m pytest --noconftest -q -o addopts='' \
tests/misc/test_abi3_packaging_config.py \
tests/misc/test_release_tag_selection.py
actionlint .github/workflows/pr.yml .github/workflows/api_test.yml \
.github/workflows/_build.yml .github/workflows/_test_lite.yml \
.github/workflows/_test_full.yml .github/workflows/rust-cli.yml
```

Compare wall time, runner queue time, compiler cache hits and native build counts
on GitHub before quoting a speedup. A local workflow validation cannot measure
runner queueing or exercise the complete multi-platform build.
3 changes: 3 additions & 0 deletions .github/actionlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
self-hosted-runner:
labels:
- openviking-ecs
87 changes: 87 additions & 0 deletions .github/actions/compiler-cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Cache native compilers
description: Cache Cargo intermediates and C++ compiler output with toolchain isolation
inputs:
target:
description: Explicit Cargo target or host
default: host
runs:
using: composite
steps:
- name: Install ccache
shell: bash
run: |
if ! command -v ccache >/dev/null; then
case "$RUNNER_OS" in
Linux)
if [ "$(id -u)" = 0 ]; then
apt-get update && apt-get install -y ccache
else
sudo apt-get update && sudo apt-get install -y ccache
fi ;;
macOS) brew install ccache ;;
Windows) choco install ccache --no-progress -y ;;
esac
fi
- name: Fingerprint toolchain
id: toolchain
shell: bash
env:
CACHE_TARGET: ${{ inputs.target }}
run: |
fingerprint=$(
{ rustc -vV;
for compiler in "${CC:-gcc}" "${CXX:-g++}"; do
if command -v "$compiler" >/dev/null; then "$compiler" --version; fi
done
cmake --version; printf '%s\n' "$CACHE_TARGET" "${RUSTFLAGS:-}" "${CFLAGS:-}" "${CXXFLAGS:-}";
} | { if command -v sha256sum >/dev/null; then sha256sum; else shasum -a 256; fi; } | cut -d' ' -f1
)
echo "hash=$fingerprint" >> "$GITHUB_OUTPUT"
echo "CCACHE_DIR=$GITHUB_WORKSPACE/.cache/ccache" >> "$GITHUB_ENV"
echo "CCACHE_BASEDIR=$GITHUB_WORKSPACE" >> "$GITHUB_ENV"
echo "CCACHE_COMPILERCHECK=content" >> "$GITHUB_ENV"
echo "CCACHE_MAXSIZE=256M" >> "$GITHUB_ENV"
echo "CARGO_INCREMENTAL=0" >> "$GITHUB_ENV"
echo "CMAKE_C_COMPILER_LAUNCHER=ccache" >> "$GITHUB_ENV"
echo "CMAKE_CXX_COMPILER_LAUNCHER=ccache" >> "$GITHUB_ENV"
# Only official main runs populate shared caches. PRs, forks and tag builds
# restore without registering a post-job save. Commit suffixes allow each
# main revision to save new compiler output into immutable cache entries.
- uses: actions/cache/restore@v5
if: github.repository != 'volcengine/OpenViking' || github.ref != 'refs/heads/main' || github.event_name == 'pull_request'
with:
path: |
~/.cargo/registry
~/.cargo/git/db
target
key: cargo-v3-${{ runner.os }}-${{ runner.arch }}-${{ inputs.target }}-${{ steps.toolchain.outputs.hash }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}
restore-keys: |
cargo-v3-${{ runner.os }}-${{ runner.arch }}-${{ inputs.target }}-${{ steps.toolchain.outputs.hash }}-${{ hashFiles('Cargo.lock') }}-
cargo-v3-${{ runner.os }}-${{ runner.arch }}-${{ inputs.target }}-${{ steps.toolchain.outputs.hash }}-
- uses: actions/cache@v5
if: github.repository == 'volcengine/OpenViking' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
with:
path: |
~/.cargo/registry
~/.cargo/git/db
target
key: cargo-v3-${{ runner.os }}-${{ runner.arch }}-${{ inputs.target }}-${{ steps.toolchain.outputs.hash }}-${{ hashFiles('Cargo.lock') }}-${{ github.sha }}
restore-keys: |
cargo-v3-${{ runner.os }}-${{ runner.arch }}-${{ inputs.target }}-${{ steps.toolchain.outputs.hash }}-${{ hashFiles('Cargo.lock') }}-
cargo-v3-${{ runner.os }}-${{ runner.arch }}-${{ inputs.target }}-${{ steps.toolchain.outputs.hash }}-
- uses: actions/cache/restore@v5
if: github.repository != 'volcengine/OpenViking' || github.ref != 'refs/heads/main' || github.event_name == 'pull_request'
with:
path: .cache/ccache
key: ccache-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.hash }}-${{ github.sha }}
restore-keys: |
ccache-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.hash }}-
ccache-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.hash }}
- uses: actions/cache@v5
if: github.repository == 'volcengine/OpenViking' && github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
with:
path: .cache/ccache
key: ccache-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.hash }}-${{ github.sha }}
restore-keys: |
ccache-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.hash }}-
ccache-v2-${{ runner.os }}-${{ runner.arch }}-${{ steps.toolchain.outputs.hash }}
50 changes: 50 additions & 0 deletions .github/actions/native-runtime/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Prepare native test runtime
description: Build once or restore a validated stable-ABI bundle from this workflow run
inputs:
artifact:
description: Same-run native bundle name; empty builds locally
default: ''
runs:
using: composite
steps:
- name: Install runtime and test dependencies without building the project
shell: bash
run: |
uv sync --frozen --extra test --no-install-project
uv pip install setuptools setuptools_scm wheel cmake maturin
- name: Download same-run native bundle
if: inputs.artifact != ''
uses: actions/download-artifact@v8
with:
name: ${{ inputs.artifact }}
path: .cache/native
- name: Validate and restore native bundle
if: inputs.artifact != ''
shell: bash
run: uv run --no-sync python .github/scripts/native_bundle.py restore .cache/native/runtime.tar.gz
- uses: dtolnay/rust-toolchain@v1
if: inputs.artifact == ''
with:
toolchain: stable
- uses: ./.github/actions/compiler-cache
if: inputs.artifact == ''
- name: Build native runtime
if: inputs.artifact == ''
shell: bash
env:
OV_REQUIRE_RAGFS_BUILD: '1'
OV_SKIP_STUDIO_BUILD: '1'
run: uv run --no-sync python setup.py build_ext --inplace
- name: Verify native imports
shell: bash
run: |
uv run --no-sync python -c "import openviking.lib.ragfs_python; import openviking.storage.vectordb.engine as engine; assert engine.ENGINE_VARIANT != 'unavailable', 'Native engine was not loaded'"
- name: Install Python entry points without recompiling native code
shell: bash
env:
OV_SKIP_CPP_BUILD: '1'
OV_SKIP_RAGFS_BUILD: '1'
OV_SKIP_OV_BUILD: '1'
OV_SKIP_STUDIO_BUILD: '1'
OV_REQUIRE_RAGFS_BUILD: '0'
run: uv pip install --no-deps --no-build-isolation --editable .
97 changes: 97 additions & 0 deletions .github/scripts/ci_plan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
"""Select PR jobs from a merge-base diff; non-PR events retain full coverage."""

import argparse
import json
import re
import subprocess

FULL_OS = [
"ubuntu-24.04",
"ubuntu-24.04-arm",
"macos-14",
"macos-15-intel",
"windows-latest",
]
CI = r"^\.github/(workflows/(pr|api_test|_build|_test_lite|_test_full)\.yml|actions/|scripts/(ci_plan|native_bundle|test_ci_helpers)\.py)"
PACKAGING = r"^(pyproject\.toml|uv\.lock|setup\.py|MANIFEST\.in|Cargo\.(toml|lock))$|^scripts/build_support/"
NATIVE = r"^(src/|third_party/|crates/(?!ov_cli/))"


def plan(paths, full=False):
def changed(pattern):
return full or any(re.search(pattern, path) for path in paths)

cross_platform = changed(f"{NATIVE}|{PACKAGING}|{CI}")
# CLI-only and Studio-only changes need a packaging smoke test, without
# occupying all five wheel runners. Native/build configuration changes do.
wheel = changed(f"{NATIVE}|{PACKAGING}|{CI}|^crates/ov_cli/|^web-studio/")
plugins = changed(
r"^(examples/[^/]*(plugin|extension)[^/]*/|examples/memory-plugin-shared/|"
r"agent-plugins/|\.github/scripts/.*(plugin|marketplace|installer)|"
Comment thread
zhanglistar marked this conversation as resolved.
Resolved
r"\.github/workflows/pr\.yml)|"
r"^(examples/)?(\.claude-plugin|\.agents/plugins)/marketplace\.json$"
)
# Keep unfamiliar paths on the safe side: only known independent trees
# bypass API tests. Added/removed/renamed paths are all included in the diff.
independent = re.compile(
r"^(docs/|bot/docs/|sdk/|integrations/frameworks/|agent-plugins/|npm/|"
r"examples/[^/]*(plugin|extension)[^/]*/|examples/memory-plugin-shared/)"
r"|^(README(?:\.[^/]+)?|CONTRIBUTING|SECURITY|LICENSE)\.md$"
r"|(\.png|\.jpg|\.jpeg|\.gif|\.svg)$"
)
api = full or any(not independent.search(path) for path in paths)
return {
"deps_changed": wheel,
"wheel_os": FULL_OS if cross_platform else ["ubuntu-24.04"],
"cuvs_changed": changed(
f"{NATIVE}|{PACKAGING}|{CI}|"
r"^openviking/storage/vectordb/|"
r"^openviking/storage/vectordb_adapters/(factory|local_adapter)\.py$|"
r"^openviking_cli/utils/config/vectordb_config\.py$|"
r"^tests/(vectordb/test_cuvs_|benchmark/test_cuvs_|vectordb/test_str_to_uint64)|"
r"^benchmark/cuvs/|^examples/cuvs_smoke\.py$"
),
"api_changed": api,
"plugins_changed": plugins,
"langchain_changed": changed(
r"^integrations/frameworks/langchain/|^openviking/integrations/|"
r"^tests/unit/test_langchain_[^/]*\.py$|^tests/integration/langchain_langgraph/|"
r"^examples/(langchain|langchain-langgraph|agent-framework)/|"
r"^(pyproject\.toml|uv\.lock)$|"
r"^\.github/workflows/(pr|python-langchain-release)\.yml$"
),
"openclaw_changed": changed(
r"^examples/openclaw-plugin/|^examples/memory-plugin-shared/(lib/|sync\.mjs)|"
r"^\.github/workflows/pr\.yml$"
),
"sdk_python_changed": changed(r"^sdk/python/|^\.github/workflows/pr\.yml$"),
}


def main():
parser = argparse.ArgumentParser()
parser.add_argument("--base")
parser.add_argument("--full", action="store_true")
parser.add_argument("--output", required=True)
args = parser.parse_args()
if not args.full and not args.base:
parser.error("--base is required unless --full is selected")
paths = []
if not args.full:
paths = (
subprocess.check_output(
["git", "diff", "--name-only", "--no-renames", "-z", f"{args.base}...HEAD"],
)
.decode()
.split("\0")
)
paths = [path for path in paths if path]
result = plan(paths, full=args.full)
print(json.dumps(result, indent=2))
with open(args.output, "a", encoding="utf-8") as output:
for key, value in result.items():
output.write(f"{key}={json.dumps(value, separators=(',', ':'))}\n")


if __name__ == "__main__":
main()
Loading
Loading