From 383bad7017e5c9d6a90f8086b87b084c26803171 Mon Sep 17 00:00:00 2001 From: Ashwin Bharambe Date: Thu, 30 Oct 2025 22:41:08 -0700 Subject: [PATCH] refactor: extract client install logic into reusable action Moved the release branch detection and client pre-install logic into a dedicated action to eliminate duplication between setup-runner and pre-commit workflows. --- .../install-client-for-release/action.yml | 34 +++++++++++++++++++ .github/actions/setup-runner/action.yml | 3 ++ .github/workflows/pre-commit.yml | 16 +++++++++ 3 files changed, 53 insertions(+) create mode 100644 .github/actions/install-client-for-release/action.yml diff --git a/.github/actions/install-client-for-release/action.yml b/.github/actions/install-client-for-release/action.yml new file mode 100644 index 000000000..aea4d6089 --- /dev/null +++ b/.github/actions/install-client-for-release/action.yml @@ -0,0 +1,34 @@ +name: Install Client for Release Branch +description: Pre-install llama-stack-client from git on release branches to satisfy RC dependencies before uv sync + +runs: + using: "composite" + steps: + - name: Install client from release branch if needed + 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 + + 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 diff --git a/.github/actions/setup-runner/action.yml b/.github/actions/setup-runner/action.yml index 905d6b73a..1ad6136dd 100644 --- a/.github/actions/setup-runner/action.yml +++ b/.github/actions/setup-runner/action.yml @@ -18,6 +18,9 @@ runs: python-version: ${{ inputs.python-version }} version: 0.7.6 + - name: Pre-install client for release branches + uses: ./.github/actions/install-client-for-release + - name: Install dependencies shell: bash run: | diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 38fb9e479..7fea208a2 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -111,3 +111,19 @@ jobs: echo "$unstaged_files" exit 1 fi + + - name: Pre-install client for release branches + uses: ./.github/actions/install-client-for-release + + - name: Sync dev + type_checking dependencies + run: uv sync --group dev --group type_checking + + - name: Run mypy (full type_checking) + run: | + set +e + uv run --group dev --group type_checking mypy + status=$? + if [ $status -ne 0 ]; then + echo "::error::Full mypy failed. Reproduce locally with 'uv run pre-commit run mypy-full --hook-stage manual --all-files'." + fi + exit $status