fix: restore correct paths for main branch in pre-commit workflow

Restored original pre-commit.yml with correct src/llama_stack paths and
npm cache path, then applied only the UV env var changes needed for mypy.

Also removed UV_INDEX_URL (only use UV_EXTRA_INDEX_URL).
This commit is contained in:
Ashwin Bharambe 2025-10-31 11:51:44 -07:00
parent e28f3a9411
commit 5c76f20e16

View file

@ -43,25 +43,43 @@ jobs:
with: with:
node-version: '20' node-version: '20'
cache: 'npm' cache: 'npm'
cache-dependency-path: 'llama_stack/ui/' cache-dependency-path: 'src/llama_stack/ui/'
- name: Set up uv
uses: astral-sh/setup-uv@2ddd2b9cb38ad8efd50337e8ab201519a34c9f24 # v7.1.1
- name: Install npm dependencies - name: Install npm dependencies
run: npm ci run: npm ci
working-directory: llama_stack/ui working-directory: src/llama_stack/ui
- name: Install pre-commit
run: python -m pip install pre-commit
- name: Cache pre-commit
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/.cache/pre-commit
key: pre-commit-3|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
- name: Run pre-commit - name: Run pre-commit
id: precommit id: precommit
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1 run: |
continue-on-error: true set +e
pre-commit run --show-diff-on-failure --color=always --all-files 2>&1 | tee /tmp/precommit.log
status=${PIPESTATUS[0]}
echo "status=$status" >> $GITHUB_OUTPUT
exit 0
env: env:
SKIP: no-commit-to-branch SKIP: no-commit-to-branch,mypy
RUFF_OUTPUT_FORMAT: github RUFF_OUTPUT_FORMAT: github
- name: Check pre-commit results - name: Check pre-commit results
if: steps.precommit.outcome == 'failure' if: steps.precommit.outputs.status != '0'
run: | run: |
echo "::error::Pre-commit hooks failed. Please run 'pre-commit run --all-files' locally and commit the fixes." echo "::error::Pre-commit hooks failed. Please run 'pre-commit run --all-files' locally and commit the fixes."
echo "::warning::Some pre-commit hooks failed. Check the output above for details." echo ""
echo "Failed hooks output:"
cat /tmp/precommit.log
exit 1 exit 1
- name: Debug - name: Debug
@ -112,56 +130,37 @@ jobs:
exit 1 exit 1
fi fi
- name: Install uv for mypy
uses: astral-sh/setup-uv@6b9c6063abd6010835644d4c2e1bef4cf5cd0fca # v6.0.1
with:
python-version: "3.12"
version: 0.7.6
- name: Configure client installation - name: Configure client installation
id: client-config id: client-config
uses: ./.github/actions/install-llama-stack-client uses: ./.github/actions/install-llama-stack-client
- name: Sync dev dependencies for mypy - name: Sync dev + type_checking dependencies
env: env:
UV_EXTRA_INDEX_URL: ${{ steps.client-config.outputs.uv-extra-index-url }} UV_EXTRA_INDEX_URL: ${{ steps.client-config.outputs.uv-extra-index-url }}
UV_INDEX_STRATEGY: ${{ steps.client-config.outputs.uv-extra-index-url && 'unsafe-best-match' || '' }}
run: | run: |
# Check if type_checking group exists, otherwise just use dev if [ -n "$UV_EXTRA_INDEX_URL" ]; then
if grep -q "type.checking" pyproject.toml; then export UV_INDEX_STRATEGY="unsafe-best-match"
echo "Found type_checking group, syncing with both groups"
uv sync --group dev --group type_checking
MYPY_CMD="uv run --group dev --group type_checking mypy"
else
echo "No type_checking group found, syncing with dev only"
uv sync --group dev
MYPY_CMD="uv run --group dev mypy"
fi fi
uv sync --group dev --group type_checking
# Install specific client version after sync if needed # Install specific client version after sync if needed
if [ "${{ steps.client-config.outputs.install-after-sync }}" = "true" ]; then if [ "${{ steps.client-config.outputs.install-after-sync }}" = "true" ]; then
echo "Installing llama-stack-client from: ${{ steps.client-config.outputs.install-source }}" echo "Installing llama-stack-client from: ${{ steps.client-config.outputs.install-source }}"
uv pip install ${{ steps.client-config.outputs.install-source }} uv pip install ${{ steps.client-config.outputs.install-source }}
fi fi
echo "MYPY_CMD=$MYPY_CMD" >> $GITHUB_ENV - name: Run mypy (full type_checking)
- name: Run mypy (full type checking)
env: env:
UV_EXTRA_INDEX_URL: ${{ steps.client-config.outputs.uv-extra-index-url }} UV_EXTRA_INDEX_URL: ${{ steps.client-config.outputs.uv-extra-index-url }}
UV_INDEX_STRATEGY: ${{ steps.client-config.outputs.uv-extra-index-url && 'unsafe-best-match' || '' }}
run: | run: |
set +e if [ -n "$UV_EXTRA_INDEX_URL" ]; then
output=$($MYPY_CMD 2>&1) export UV_INDEX_STRATEGY="unsafe-best-match"
status=$?
# If mypy isn't available (common on older release branches), skip gracefully
if echo "$output" | grep -q "Failed to spawn.*mypy"; then
echo "::warning::mypy not available, skipping type checking (expected on release-0.3.x)"
exit 0
fi fi
echo "$output" set +e
uv run --group dev --group type_checking mypy
status=$?
if [ $status -ne 0 ]; then 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'." echo "::error::Full mypy failed. Reproduce locally with 'uv run pre-commit run mypy-full --hook-stage manual --all-files'."
fi fi