fix(ci): install client from release branch before uv sync

CI was failing on release branches because uv sync tried to resolve
llama-stack-client>=0.3.1rc1 from PyPI, but RC versions only exist on
test.pypi. The dependency resolution would fail before we could install
the client from git.

Solution: On release-X.Y.x branches, pre-install llama-stack-client
from the matching git branch before running uv sync. This satisfies
the RC version requirement in pyproject.toml and allows dependency
resolution to succeed.

Changes:
- setup-runner: Pre-install client from git on release branches
- pre-commit: Add same pre-install logic before uv sync
- setup-test-environment: Remove duplicate logic (now in setup-runner)

Example failure: 5415478835
This commit is contained in:
Ashwin Bharambe 2025-10-30 22:31:44 -07:00
parent 6d80ca4bf7
commit afa9f08823
3 changed files with 66 additions and 32 deletions

View file

@ -21,6 +21,32 @@ runs:
- name: Install dependencies - name: Install dependencies
shell: bash shell: bash
run: | run: |
# Determine the branch we're working with
# For PRs: use base_ref (target branch)
# For pushes: use ref (current branch)
BRANCH="${{ github.base_ref || github.ref }}"
BRANCH="${BRANCH#refs/heads/}" # Strip refs/heads/ prefix
echo "Working with branch: $BRANCH"
# If on a release branch, install from matching release branch BEFORE uv sync
# This allows uv sync to resolve dependencies that reference unreleased RC versions
# We always do this on release branches regardless of client-version to satisfy pyproject.toml
if [[ "$BRANCH" =~ ^release-[0-9]+\.[0-9]+\.x$ ]]; then
echo "Detected release branch: $BRANCH"
echo "Checking if matching branch exists in llama-stack-client-python..."
# Check if the branch exists in the client repo
if git ls-remote --exit-code --heads https://github.com/llamastack/llama-stack-client-python.git "$BRANCH" > /dev/null 2>&1; then
echo "Installing llama-stack-client-python from matching branch: $BRANCH"
uv pip install git+https://github.com/llamastack/llama-stack-client-python.git@$BRANCH
else
echo "::error::Branch $BRANCH not found in llama-stack-client-python repository"
echo "::error::Please create the matching release branch in llama-stack-client-python before testing"
exit 1
fi
fi
echo "Updating project dependencies via uv sync" echo "Updating project dependencies via uv sync"
uv sync --all-groups uv sync --all-groups
@ -28,15 +54,18 @@ runs:
uv pip install faiss-cpu uv pip install faiss-cpu
# Install llama-stack-client-python based on the client-version input # Install llama-stack-client-python based on the client-version input
if [ "${{ inputs.client-version }}" = "latest" ]; then # Only applies to non-release branches (on release branches, we already installed from git above)
echo "Installing latest llama-stack-client-python from main branch" if [[ ! "$BRANCH" =~ ^release-[0-9]+\.[0-9]+\.x$ ]]; then
uv pip install git+https://github.com/llamastack/llama-stack-client-python.git@main if [ "${{ inputs.client-version }}" = "latest" ]; then
elif [ "${{ inputs.client-version }}" = "published" ]; then echo "Installing latest llama-stack-client-python from main branch"
echo "Installing published llama-stack-client-python from PyPI" uv pip install git+https://github.com/llamastack/llama-stack-client-python.git@main
uv pip install llama-stack-client elif [ "${{ inputs.client-version }}" = "published" ]; then
else echo "Installing published llama-stack-client-python from PyPI"
echo "Invalid client-version: ${{ inputs.client-version }}" uv pip install llama-stack-client
exit 1 else
echo "Invalid client-version: ${{ inputs.client-version }}"
exit 1
fi
fi fi
echo "Installed llama packages" echo "Installed llama packages"

View file

@ -42,29 +42,7 @@ runs:
- name: Build Llama Stack - name: Build Llama Stack
shell: bash shell: bash
run: | run: |
# Install llama-stack-client-python based on the client-version input # Client is already installed by setup-runner (handles both main and release branches)
if [ "${{ inputs.client-version }}" = "latest" ]; then
# Check if PR is targeting a release branch
TARGET_BRANCH="${{ github.base_ref }}"
if [[ "$TARGET_BRANCH" =~ ^release-[0-9]+\.[0-9]+\.x$ ]]; then
echo "PR targets release branch: $TARGET_BRANCH"
echo "Checking if matching branch exists in llama-stack-client-python..."
# Check if the branch exists in the client repo
if git ls-remote --exit-code --heads https://github.com/llamastack/llama-stack-client-python.git "$TARGET_BRANCH" > /dev/null 2>&1; then
echo "Installing llama-stack-client-python from matching branch: $TARGET_BRANCH"
uv pip install --force-reinstall git+https://github.com/llamastack/llama-stack-client-python.git@$TARGET_BRANCH
else
echo "::error::Branch $TARGET_BRANCH not found in llama-stack-client-python repository"
echo "::error::Please create the matching release branch in llama-stack-client-python before testing"
exit 1
fi
fi
# For main branch, client is already installed by setup-runner
fi
# For published version, client is already installed by setup-runner
echo "Building Llama Stack" echo "Building Llama Stack"
LLAMA_STACK_DIR=. \ LLAMA_STACK_DIR=. \

View file

@ -130,6 +130,33 @@ jobs:
exit 1 exit 1
fi fi
- name: Install client from release branch if needed
run: |
# Determine the branch we're working with
# For PRs: use base_ref (target branch)
# For pushes: use ref (current branch)
BRANCH="${{ github.base_ref || github.ref }}"
BRANCH="${BRANCH#refs/heads/}" # Strip refs/heads/ prefix
echo "Working with branch: $BRANCH"
# If on a release branch, install from matching release branch BEFORE uv sync
# This allows uv sync to resolve dependencies that reference unreleased RC versions
if [[ "$BRANCH" =~ ^release-[0-9]+\.[0-9]+\.x$ ]]; then
echo "Detected release branch: $BRANCH"
echo "Checking if matching branch exists in llama-stack-client-python..."
# Check if the branch exists in the client repo
if git ls-remote --exit-code --heads https://github.com/llamastack/llama-stack-client-python.git "$BRANCH" > /dev/null 2>&1; then
echo "Installing llama-stack-client-python from matching branch: $BRANCH"
uv pip install git+https://github.com/llamastack/llama-stack-client-python.git@$BRANCH
else
echo "::error::Branch $BRANCH not found in llama-stack-client-python repository"
echo "::error::Please create the matching release branch in llama-stack-client-python before testing"
exit 1
fi
fi
- name: Sync dev + type_checking dependencies - name: Sync dev + type_checking dependencies
run: uv sync --group dev --group type_checking run: uv sync --group dev --group type_checking