Skip to content

feat: add query owner context metadata #2123

feat: add query owner context metadata

feat: add query owner context metadata #2123

Workflow file for this run

name: Rust Tests
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
env:
CARGO_TERM_COLOR: always
CI: true
jobs:
check-changes:
name: Check what code changed
runs-on: ubuntu-latest
outputs:
rust-changed: ${{ steps.changes.outputs.rust }}
npm-changed: ${{ steps.changes.outputs.npm }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for changes
id: changes
run: |
if [ "${{ github.event_name }}" == "push" ]; then
# For push events, check changes since the previous commit
CHANGED_FILES=$(git diff --name-only HEAD~1 HEAD)
else
# For pull requests, check changes against the base branch
git fetch origin "${{ github.base_ref }}"
CHANGED_FILES=$(git diff --name-only "origin/${{ github.base_ref }}" HEAD)
fi
echo "Changed files:"
echo "$CHANGED_FILES"
# Check if any Rust-related files changed
if echo "$CHANGED_FILES" | grep -E '\.(rs|toml)$|^Cargo\.|^Makefile$|^\.github/workflows/rust-tests\.yml$|^\.githooks/|^scripts/|^tests/' > /dev/null; then
echo "Rust code or related files changed"
echo "rust=true" >> "$GITHUB_OUTPUT"
else
echo "No Rust code changes detected"
echo "rust=false" >> "$GITHUB_OUTPUT"
fi
# Check if any NPM-related files changed
if echo "$CHANGED_FILES" | grep -E '^npm/|package\.json$|package-lock\.json$|\.js$|\.ts$|\.json$|^examples/chat/' > /dev/null; then
echo "NPM/Node.js code or related files changed"
echo "npm=true" >> "$GITHUB_OUTPUT"
else
echo "No NPM code changes detected"
echo "npm=false" >> "$GITHUB_OUTPUT"
fi
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: check-changes
if: needs.check-changes.outputs.rust-changed == 'true'
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.92.0
with:
components: rustfmt, clippy
- name: Setup Rust cache
uses: actions/cache@v4
timeout-minutes: 5
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('rust-toolchain', 'rust-toolchain.toml') || 'stable' }}
restore-keys: |
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-
${{ runner.os }}-cargo-
- name: Show tool versions
run: |
rustc --version
cargo --version
cargo clippy --version
- name: Check formatting
run: cargo fmt --all -- --check
- name: Set custom target directory on Windows
if: runner.os == 'Windows'
run: |
echo "CARGO_TARGET_DIR=C:/probe-target" >> "$GITHUB_ENV"
mkdir -p C:/probe-target
shell: bash
- name: Lint with clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Build
run: cargo build
- name: Run unit tests
run: cargo test --lib
- name: Run integration tests
run: cargo test --test integration_tests
- name: Run property tests
run: cargo test --test property_tests
- name: Run CLI tests (Sequential on CI)
run: cargo test --test cli_tests -- --test-threads=1