diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 6a752e0e..e7875cba 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -2,10 +2,10 @@ name: Pre-commit on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] - workflow_dispatch: # Allow manual triggering + branches: [main] + workflow_dispatch: # Allow manual triggering jobs: pre-commit: @@ -13,98 +13,99 @@ jobs: 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: 23 - - - 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 - npm install -g markdownlint-cli - pip install --user yamllint codespell - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0 - - - 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: Install pre-commit - run: make precommit-install - - - name: Run Code Spell Check - run: make codespell - - - 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 "To run pre-commit locally:" - echo " pip install pre-commit" - echo " pre-commit install" - echo " pre-commit run --all-files" + - 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: 23 + + - 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 + npm install -g markdownlint-cli + pip install --user yamllint codespell + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b $(go env GOPATH)/bin v2.5.0 + + - 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: Install pre-commit + run: make precommit-install + + - name: Run Code Spell Check + run: make codespell + + - 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 "To run pre-commit locally:" + echo " pip install pre-commit" + echo " pre-commit install" + echo " pre-commit run --all-files" diff --git a/README.md b/README.md index 2912693d..28cf66da 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ An **Mixture-of-Models** (MoM) router that intelligently directs OpenAI API requests to the most suitable models from a defined pool based on **Semantic Understanding** of the request's intent (Complexity, Task, Tools). -![](./website/static/img/mom-overview.png) +![mom-overview](./website/static/img/mom-overview.png) Conceptually similar to Mixture-of-Experts (MoE) which lives *within* a model, this system selects the best *entire model* for the nature of the task. diff --git a/scripts/quickstart.sh b/scripts/quickstart.sh index be6a05ce..a1bc1412 100755 --- a/scripts/quickstart.sh +++ b/scripts/quickstart.sh @@ -52,7 +52,9 @@ typewriter() { # Function to show ASCII art with animation show_ascii_art() { # Skip clear in CI environments (no proper terminal) - [ -z "${CI:-}" ] && clear || true + if [ -z "${CI:-}" ]; then + clear || true + fi echo echo print_color "$CYAN" " ██╗ ██╗██╗ ██╗ ███╗ ███╗" diff --git a/tools/make/envs.mk b/tools/make/envs.mk index f4c9e81f..b1b438fd 100644 --- a/tools/make/envs.mk +++ b/tools/make/envs.mk @@ -2,6 +2,10 @@ # = Environment Makefile, refer for other makefile = # ====================== envs.mk ====================== +# CI environment flag (set by CI/CD systems like GitHub Actions) +# Can be overridden: CI=true make build +CI ?= + # Container runtime (docker or podman) CONTAINER_RUNTIME ?= docker diff --git a/tools/make/linter.mk b/tools/make/linter.mk index ee92ce90..249d54da 100644 --- a/tools/make/linter.mk +++ b/tools/make/linter.mk @@ -4,14 +4,6 @@ ##@ Linter -docs-lint: docs-install ## Lint documentation in website/ - @$(LOG_TARGET) - cd website && npm run lint - -docs-lint-fix: docs-install ## Auto-fix documentation lint issues in website/ - @$(LOG_TARGET) - cd website && npm run lint:fix - markdown-lint: ## Lint all markdown files in the project @$(LOG_TARGET) markdownlint -c tools/linter/markdown/markdownlint.yaml "**/*.md" \ @@ -40,4 +32,17 @@ codespell: ## Check for common misspellings in code and docs shellcheck: ## Lint all shell scripts in the project @$(LOG_TARGET) - shellcheck --rcfile=tools/linter/shellcheck/.shellcheckrc $(shell find . -type f -name "*.sh" -not -path "./node_modules/*" -not -path "./website/node_modules/*" -not -path "./dashboard/frontend/node_modules/*" -not -path "./models/*" -not -path "./.venv/*") \ No newline at end of file + @if ! command -v shellcheck >/dev/null 2>&1; then \ + echo "❌ Error: shellcheck is not installed"; \ + echo ""; \ + echo "To install shellcheck:"; \ + echo " macOS: brew install shellcheck"; \ + echo " Ubuntu: sudo apt-get install shellcheck"; \ + echo " Fedora: sudo dnf install shellcheck"; \ + echo ""; \ + echo "Or skip shellcheck in pre-commit by running:"; \ + echo " SKIP=shellcheck pre-commit run --all-files"; \ + exit 1; \ + fi + @echo "Running shellcheck with config from tools/linter/shellcheck/.shellcheckrc" + @shellcheck -e SC2155,SC2034,SC1091 $(shell find . -type f -name "*.sh" -not -path "./node_modules/*" -not -path "./website/node_modules/*" -not -path "./dashboard/frontend/node_modules/*" -not -path "./models/*" -not -path "./.venv/*") \ No newline at end of file diff --git a/tools/make/pre-commit.mk b/tools/make/pre-commit.mk index 66e536da..7e454752 100644 --- a/tools/make/pre-commit.mk +++ b/tools/make/pre-commit.mk @@ -8,7 +8,7 @@ precommit-install: precommit-check: ## Run pre-commit checks on all relevant files precommit-check: - @FILES=$$(find . -type f \( -name "*.go" -o -name "*.rs" -o -name "*.py" -o -name "*.js" -o -name "*.md" -o -name "*.yaml" -o -name "*.yml" \) \ + @FILES=$$(find . -type f \( -name "*.go" -o -name "*.rs" -o -name "*.py" -o -name "*.js" -o -name "*.sh" -o -name "*.md" -o -name "*.yaml" -o -name "*.yml" \) \ ! -path "./target/*" \ ! -path "./candle-binding/target/*" \ ! -path "./website/node_modules/*" \ @@ -24,7 +24,7 @@ precommit-check: echo "Running pre-commit on files: $$FILES"; \ pre-commit run --files $$FILES; \ else \ - echo "No Go, Rust, JavaScript, Markdown, Yaml, or Python files found to check"; \ + echo "No Go, Rust, JavaScript, Shell, Markdown, Yaml, or Python files found to check"; \ fi # Run pre-commit hooks in a Docker container,