Files
WrenAI/.github/workflows/wren-ci.yml
T
2026-06-23 14:15:44 +08:00

208 lines
6.5 KiB
YAML

name: Wren SDK CI
permissions:
contents: read
pull-requests: write
on:
pull_request:
paths:
- 'core/wren/**'
- 'core/wren-core/**'
- 'core/wren-core-py/**'
- 'core/wren-core-base/**'
concurrency:
group: ${{ github.workflow }}-${{ github.event.number }}
cancel-in-progress: true
jobs:
lint:
name: lint
runs-on: ubuntu-latest
defaults:
run:
working-directory: core/wren
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Lint
run: |
uvx ruff format --check src/
uvx ruff check src/
test-unit:
name: unit tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: core/wren
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./core/wren-core-py/target/
key: ${{ runner.os }}-cargo-wren-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build wren-core-py wheel
working-directory: core/wren-core-py
run: |
uv sync --locked --no-install-project
uv run --no-sync maturin build
- name: Install dependencies
run: |
uv sync --locked
uv pip install --reinstall --no-index --find-links ../wren-core-py/target/wheels/ wren-core-py
- name: Run unit tests
# Run the whole tests/unit/ tree rather than filtering on `-m unit`:
# the marker is opt-in, so any unmarked file (e.g. test_context_cli.py)
# was silently skipped. Exclude test_memory.py — it needs the `memory`
# extra and runs in the dedicated `memory tests` job below.
run: uv run --no-sync pytest tests/unit/ -v --ignore=tests/unit/test_memory.py
test-connector:
name: ${{ matrix.datasource }} tests
runs-on: ubuntu-latest
strategy:
matrix:
include:
- datasource: postgres
extra: postgres
test_file: tests/connectors/test_postgres.py
marker: postgres
- datasource: mysql
extra: mysql
test_file: tests/connectors/test_mysql.py
marker: mysql
defaults:
run:
working-directory: core/wren
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Install system dependencies for mysqlclient
if: matrix.datasource == 'mysql'
run: |
sudo apt-get update
sudo apt-get install -y default-libmysqlclient-dev pkg-config
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./core/wren-core-py/target/
key: ${{ runner.os }}-cargo-wren-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build wren-core-py wheel
working-directory: core/wren-core-py
run: |
uv sync --locked --no-install-project
uv run --no-sync maturin build
- name: Install dependencies
run: |
uv sync --locked --extra ${{ matrix.extra }}
uv pip install --reinstall --no-index --find-links ../wren-core-py/target/wheels/ wren-core-py
- name: Run ${{ matrix.datasource }} tests
run: uv run --no-sync pytest ${{ matrix.test_file }} -v -m ${{ matrix.marker }}
test-ui:
name: ui tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: core/wren
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./core/wren-core-py/target/
key: ${{ runner.os }}-cargo-wren-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build wren-core-py wheel
working-directory: core/wren-core-py
run: |
uv sync --locked --no-install-project
uv run --no-sync maturin build
- name: Install dependencies
run: |
uv sync --locked --extra ui
uv pip install --reinstall --no-index --find-links ../wren-core-py/target/wheels/ wren-core-py
- name: Run UI tests
run: uv run --no-sync pytest tests/test_profile_web.py tests/test_field_registry.py -v
test-memory:
name: memory tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: core/wren
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v4
- name: Cache Cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
./core/wren-core-py/target/
key: ${{ runner.os }}-cargo-wren-${{ hashFiles('**/Cargo.lock') }}
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build wren-core-py wheel
working-directory: core/wren-core-py
run: |
uv sync --locked --no-install-project
uv run --no-sync maturin build
- name: Install dependencies
run: |
uv sync --locked --extra memory
uv pip install --reinstall --no-index --find-links ../wren-core-py/target/wheels/ wren-core-py
- name: Cache sentence-transformers model
uses: actions/cache@v4
with:
path: ~/.cache/huggingface
key: hf-paraphrase-MiniLM-L3-v2
- name: Run memory tests
env:
WREN_EMBEDDING_MODEL: paraphrase-MiniLM-L3-v2
run: uv run --no-sync pytest tests/unit/test_memory.py -v