mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-11 19:56:03 +00:00
refactor: move UV index config into pre-commit hook
Make uv-lock pre-commit hook smart about release branches by wrapping it in a script that detects release branches and sets UV_EXTRA_INDEX_URL. This allows the same pre-commit config to work locally and in CI without special environment variable setup in workflows. Changes: - Add scripts/pre-commit-uv-lock.sh wrapper that detects release branches - Move uv-lock from astral-sh/uv-pre-commit to local hook using wrapper - Remove UV env var setup from pre-commit workflow (hook handles it) - Regenerate uv.lock with test.pypi as extra index (not primary)
This commit is contained in:
parent
8ebb9195a4
commit
83176acd88
4 changed files with 830 additions and 847 deletions
13
.github/workflows/pre-commit.yml
vendored
13
.github/workflows/pre-commit.yml
vendored
|
|
@ -49,19 +49,6 @@ jobs:
|
||||||
run: npm ci
|
run: npm ci
|
||||||
working-directory: llama_stack/ui
|
working-directory: llama_stack/ui
|
||||||
|
|
||||||
- name: Configure client installation
|
|
||||||
id: client-config-precommit
|
|
||||||
uses: ./.github/actions/install-llama-stack-client
|
|
||||||
|
|
||||||
- name: Export UV environment variables
|
|
||||||
run: |
|
|
||||||
if [ -n "${{ steps.client-config-precommit.outputs.uv-extra-index-url }}" ]; then
|
|
||||||
echo "UV_EXTRA_INDEX_URL=${{ steps.client-config-precommit.outputs.uv-extra-index-url }}" >> $GITHUB_ENV
|
|
||||||
echo "UV_INDEX_STRATEGY=unsafe-best-match" >> $GITHUB_ENV
|
|
||||||
echo "Setting UV_EXTRA_INDEX_URL to ${{ steps.client-config-precommit.outputs.uv-extra-index-url }}"
|
|
||||||
echo "Setting UV_INDEX_STRATEGY to unsafe-best-match"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Run pre-commit
|
- name: Run pre-commit
|
||||||
id: precommit
|
id: precommit
|
||||||
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
|
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
|
||||||
|
|
|
||||||
|
|
@ -52,10 +52,6 @@ repos:
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
- black==24.3.0
|
- black==24.3.0
|
||||||
|
|
||||||
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
||||||
rev: 0.7.20
|
|
||||||
hooks:
|
|
||||||
- id: uv-lock
|
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v1.16.1
|
rev: v1.16.1
|
||||||
|
|
@ -78,6 +74,15 @@ repos:
|
||||||
|
|
||||||
- repo: local
|
- repo: local
|
||||||
hooks:
|
hooks:
|
||||||
|
- id: uv-lock
|
||||||
|
name: uv-lock
|
||||||
|
additional_dependencies:
|
||||||
|
- uv==0.7.20
|
||||||
|
entry: ./scripts/pre-commit-uv-lock.sh
|
||||||
|
language: python
|
||||||
|
pass_filenames: false
|
||||||
|
require_serial: true
|
||||||
|
files: ^(pyproject\.toml|uv\.lock)$
|
||||||
- id: distro-codegen
|
- id: distro-codegen
|
||||||
name: Distribution Template Codegen
|
name: Distribution Template Codegen
|
||||||
additional_dependencies:
|
additional_dependencies:
|
||||||
|
|
|
||||||
22
scripts/pre-commit-uv-lock.sh
Executable file
22
scripts/pre-commit-uv-lock.sh
Executable file
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# This source code is licensed under the terms described in the LICENSE file in
|
||||||
|
# the root directory of this source tree.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
# Detect current branch
|
||||||
|
BRANCH=$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")
|
||||||
|
|
||||||
|
# On release branches, use test.pypi as extra index for RC versions
|
||||||
|
if [[ "$BRANCH" =~ ^release-[0-9]+\.[0-9]+\.x$ ]]; then
|
||||||
|
echo "Detected release branch: $BRANCH"
|
||||||
|
echo "Setting UV_EXTRA_INDEX_URL=https://test.pypi.org/simple/"
|
||||||
|
export UV_EXTRA_INDEX_URL="https://test.pypi.org/simple/"
|
||||||
|
export UV_INDEX_STRATEGY="unsafe-best-match"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Run uv lock
|
||||||
|
exec uv lock "$@"
|
||||||
Loading…
Add table
Add a link
Reference in a new issue