From 0815663211068c8b914541a4c892b051b9e0f2a5 Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Thu, 30 Oct 2025 23:11:14 -0700 Subject: [PATCH] fix: use test.pypi for uv sync on release branches The previous approach tried to install before uv sync, but there's no venv yet. The correct solution: - Release branches: Point UV_INDEX_URL to test.pypi so uv sync can resolve RC versions, then install exact git version after sync - Non-release branches: Run uv sync normally, then install git version if client-version=latest This lets uv sync create the venv first, then we install/override the client version as needed. --- .../install-llama-stack-client/action.yml | 59 +++++++++++-------- .github/actions/setup-runner/action.yml | 12 +++- .github/workflows/pre-commit.yml | 15 ++++- 3 files changed, 60 insertions(+), 26 deletions(-) diff --git a/.github/actions/install-llama-stack-client/action.yml b/.github/actions/install-llama-stack-client/action.yml index 15d678f3f..553d82f01 100644 --- a/.github/actions/install-llama-stack-client/action.yml +++ b/.github/actions/install-llama-stack-client/action.yml @@ -7,45 +7,58 @@ inputs: required: false default: "" +outputs: + uv-index-url: + description: 'UV_INDEX_URL to use (set for release branches)' + value: ${{ steps.configure.outputs.uv-index-url }} + uv-extra-index-url: + description: 'UV_EXTRA_INDEX_URL to use (set for release branches)' + value: ${{ steps.configure.outputs.uv-extra-index-url }} + install-after-sync: + description: 'Whether to install client after uv sync' + value: ${{ steps.configure.outputs.install-after-sync }} + install-source: + description: 'Where to install client from after sync' + value: ${{ steps.configure.outputs.install-source }} + runs: using: "composite" steps: - - name: Install llama-stack-client + - name: Configure client installation + id: configure shell: bash 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 + BRANCH="${BRANCH#refs/heads/}" echo "Working with branch: $BRANCH" - # On release branches: always install from matching git branch to satisfy RC dependencies - # On non-release branches: install based on client-version input + # On release branches: use test.pypi for uv sync, then install from git + # On non-release branches: install based on client-version after sync 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 + # Check if matching branch exists in 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 "::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 + + # Configure to use test.pypi for sync (to resolve RC versions) + echo "uv-index-url=https://test.pypi.org/simple/" >> $GITHUB_OUTPUT + echo "uv-extra-index-url=https://pypi.org/simple/" >> $GITHUB_OUTPUT + echo "install-after-sync=true" >> $GITHUB_OUTPUT + echo "install-source=git+https://github.com/llamastack/llama-stack-client-python.git@$BRANCH" >> $GITHUB_OUTPUT + elif [ "${{ inputs.client-version }}" = "latest" ]; then + # Install from main git after sync + echo "install-after-sync=true" >> $GITHUB_OUTPUT + echo "install-source=git+https://github.com/llamastack/llama-stack-client-python.git@main" >> $GITHUB_OUTPUT + elif [ "${{ inputs.client-version }}" = "published" ]; then + # Use published version from PyPI (installed by sync) + echo "install-after-sync=false" >> $GITHUB_OUTPUT elif [ -n "${{ inputs.client-version }}" ]; then - # Non-release branch with client-version specified - if [ "${{ inputs.client-version }}" = "latest" ]; then - echo "Installing latest llama-stack-client-python from main branch" - uv pip install git+https://github.com/llamastack/llama-stack-client-python.git@main - elif [ "${{ inputs.client-version }}" = "published" ]; then - echo "Installing published llama-stack-client-python from PyPI" - uv pip install llama-stack-client - else - echo "Invalid client-version: ${{ inputs.client-version }}" - exit 1 - fi + echo "::error::Invalid client-version: ${{ inputs.client-version }}" + exit 1 fi diff --git a/.github/actions/setup-runner/action.yml b/.github/actions/setup-runner/action.yml index b039e7fa8..52a3c4643 100644 --- a/.github/actions/setup-runner/action.yml +++ b/.github/actions/setup-runner/action.yml @@ -18,13 +18,17 @@ runs: python-version: ${{ inputs.python-version }} version: 0.7.6 - - name: Install llama-stack-client + - name: Configure client installation + id: client-config uses: ./.github/actions/install-llama-stack-client with: client-version: ${{ inputs.client-version }} - name: Install dependencies shell: bash + env: + UV_INDEX_URL: ${{ steps.client-config.outputs.uv-index-url }} + UV_EXTRA_INDEX_URL: ${{ steps.client-config.outputs.uv-extra-index-url }} run: | echo "Updating project dependencies via uv sync" uv sync --all-groups @@ -32,5 +36,11 @@ runs: echo "Installing ad-hoc dependencies" uv pip install faiss-cpu + # Install specific client version after sync if needed + if [ "${{ steps.client-config.outputs.install-after-sync }}" = "true" ]; then + echo "Installing llama-stack-client from: ${{ steps.client-config.outputs.install-source }}" + uv pip install ${{ steps.client-config.outputs.install-source }} + fi + echo "Installed llama packages" uv pip list | grep llama diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 5ec6a0459..6d9f358d2 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -130,11 +130,22 @@ jobs: exit 1 fi - - name: Install llama-stack-client + - name: Configure client installation + id: client-config uses: ./.github/actions/install-llama-stack-client - name: Sync dev + type_checking dependencies - run: uv sync --group dev --group type_checking + env: + UV_INDEX_URL: ${{ steps.client-config.outputs.uv-index-url }} + UV_EXTRA_INDEX_URL: ${{ steps.client-config.outputs.uv-extra-index-url }} + run: | + uv sync --group dev --group type_checking + + # Install specific client version after sync if needed + if [ "${{ steps.client-config.outputs.install-after-sync }}" = "true" ]; then + echo "Installing llama-stack-client from: ${{ steps.client-config.outputs.install-source }}" + uv pip install ${{ steps.client-config.outputs.install-source }} + fi - name: Run mypy (full type_checking) run: |