docs: update balance and fix cache bug (#1634) #87
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Pre-commit | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| workflow_dispatch: # Allow manual triggering | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| pre-commit: | |
| if: github.repository == 'vllm-project/semantic-router' | |
| runs-on: ubuntu-latest | |
| name: Run pre-commit hooks check file lint | |
| steps: | |
| - name: Check out the repo | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch full history for pre-commit | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.11" | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.24" | |
| - name: Set up Node | |
| uses: actions/setup-node@v5 | |
| with: | |
| node-version: 20 | |
| - name: Set up Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| toolchain: 1.90 | |
| components: rustfmt, clippy | |
| - name: Install system dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y \ | |
| make \ | |
| build-essential \ | |
| pkg-config \ | |
| shellcheck | |
| - name: Set up golangci-lint | |
| uses: golangci/golangci-lint-action@v7 | |
| with: | |
| version: v2.5.0 | |
| install-mode: binary | |
| args: --help | |
| - name: Cache Rust dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/bin/ | |
| ~/.cargo/registry/index/ | |
| ~/.cargo/registry/cache/ | |
| ~/.cargo/git/db/ | |
| candle-binding/target/ | |
| key: ${{ runner.os }}-cargo-precommit-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo-precommit- | |
| - name: Cache Go dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/go/pkg/mod | |
| key: ${{ runner.os }}-go-precommit-${{ hashFiles('**/go.sum') }} | |
| restore-keys: | | |
| ${{ runner.os }}-go-precommit- | |
| - name: Cache Node dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.npm | |
| key: ${{ runner.os }}-node-precommit-${{ hashFiles('website/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node-precommit- | |
| - name: Cache pre-commit environments | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/.cache/pre-commit | |
| key: ${{ runner.os }}-pre-commit-${{ hashFiles('.pre-commit-config.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-precommit- | |
| - name: Run agent CI lint on changed files | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| export AGENT_BASE_REF="origin/${{ github.base_ref }}" | |
| else | |
| export AGENT_BASE_REF="HEAD^" | |
| fi | |
| make agent-ci-lint | |
| - name: Diagnose gofmt state before pre-commit | |
| run: | | |
| echo "=== Go version ===" | |
| go version | |
| echo "=== gofmt version ===" | |
| gofmt -h 2>&1 | head -3 || true | |
| echo "=== Files needing gofmt (gofmt -l) ===" | |
| NEEDS_FMT=$(gofmt -l $(find . -name "*.go" -not -path "./.git/*" -not -path "./.venv/*") 2>/dev/null) | |
| if [ -n "$NEEDS_FMT" ]; then | |
| echo "Files that need formatting:" | |
| echo "$NEEDS_FMT" | |
| echo "" | |
| echo "=== Diffs ===" | |
| for f in $NEEDS_FMT; do | |
| echo "--- $f ---" | |
| gofmt -d "$f" || true | |
| done | |
| else | |
| echo "All Go files are properly formatted" | |
| fi | |
| echo "=== git status (any working tree changes) ===" | |
| git status --short || true | |
| - name: Run pre-commit check | |
| run: make precommit-check | |
| env: | |
| CI: true | |
| - name: Show pre-commit results | |
| if: failure() | |
| run: | | |
| echo "::error::Pre-commit hooks failed. Please fix the issues and commit again." | |
| echo "" | |
| echo "=== Files with gofmt issues (gofmt -l) ===" | |
| gofmt -l $(find . -name "*.go" -not -path "./.git/*") || true | |
| echo "" | |
| echo "=== gofmt diff for all modified Go files ===" | |
| gofmt -d $(find . -name "*.go" -not -path "./.git/*") || true | |
| echo "" | |
| echo "=== Working tree changes after pre-commit run ===" | |
| git diff --name-only || true | |
| echo "" | |
| echo "=== Full git diff ===" | |
| git diff || true | |
| echo "" | |
| echo "To reproduce the changed-file CI lint locally:" | |
| echo " make agent-ci-lint CHANGED_FILES=\"path/one,path/two\"" | |
| echo "" | |
| echo "To run full pre-commit locally:" | |
| echo " make precommit-install" | |
| echo " make precommit-check" |