diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100755 index 00000000..59c2f95d --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +# Pre-commit hook: Fast formatting check before creating commits. +set -e + +echo "==> Running cargo fmt --all --check..." +cargo fmt --all --check diff --git a/.githooks/pre-push b/.githooks/pre-push new file mode 100755 index 00000000..4e978906 --- /dev/null +++ b/.githooks/pre-push @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +# Pre-push hook: Comprehensive validation before pushing to remote. +set -e + +echo "==> Checking headless gateway (AGENTS.md rule)..." +cargo check -p gateway --no-default-features + +echo "==> Running Clippy on workspace..." +cargo clippy --workspace --exclude workshop --exclude workshop-server --all-targets --all-features -- -D warnings + +if command -v cargo-deny >/dev/null 2>&1; then + echo "==> Running cargo deny check..." + cargo deny check +fi + +echo "==> Pre-push checks passed successfully." diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d394e9e6..d65027ce 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,12 +16,23 @@ concurrency: # to anonymous, which is what the cache is there to make rare. env: HF_TOKEN: ${{ secrets.HF_TOKEN }} + RUSTUP_TOOLCHAIN: stable jobs: - check: + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: Format + run: cargo fmt --all --check + + clippy: runs-on: ubuntu-latest - # RUSTUP_TOOLCHAIN outranks the repo's rust-toolchain.toml (pinned to the - # MSRV for local builds); this job means to test stable. env: RUSTUP_TOOLCHAIN: stable steps: @@ -29,7 +40,7 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: - components: rustfmt, clippy + components: clippy - name: Cache cargo uses: Swatinem/rust-cache@v2 @@ -40,35 +51,52 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies - working-directory: crates/workshop-server/ui - run: npm ci - - - name: Install config UI dependencies - working-directory: crates/gateway-config-ui/ui - run: npm ci - - - name: Format - run: cargo fmt --all --check + run: | + npm ci --prefix crates/workshop-server/ui + npm ci --prefix crates/gateway-config-ui/ui - # The desktop packages stay in their platform jobs because Linux needs - # Tauri system libraries. All gateway and STT features are pure Rust - # now that whisper.cpp is loaded from a managed runtime artifact. - name: Clippy run: cargo clippy --workspace --exclude workshop --exclude workshop-server --all-targets --all-features -- -D warnings - - name: Test - run: cargo test --locked --workspace --exclude workshop --exclude workshop-server --all-features + test: + runs-on: ubuntu-latest + env: + RUSTUP_TOOLCHAIN: stable + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + + - name: Install cargo-nextest + uses: taiki-e/install-action@nextest + + - name: Cache cargo + uses: Swatinem/rust-cache@v2 + + - name: Cache the embedding model + uses: ./.github/actions/hf-model-cache + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json + + - name: Install UI dependencies + run: | + npm ci --prefix crates/workshop-server/ui + npm ci --prefix crates/gateway-config-ui/ui + + - name: Test (concurrent via nextest) + run: cargo nextest run --locked --workspace --exclude workshop --exclude workshop-server --all-features - name: Doctests run: cargo test --workspace --exclude workshop --exclude workshop-server --all-features --doc - - name: Docs - env: - RUSTDOCFLAGS: -D warnings - run: cargo doc --workspace --no-deps --all-features --exclude workshop --exclude workshop-server - - name: Check headless gateway run: cargo check -p gateway --no-default-features @@ -83,6 +111,36 @@ jobs: exit 1 fi + docs: + runs-on: ubuntu-latest + env: + RUSTUP_TOOLCHAIN: stable + RUSTDOCFLAGS: -D warnings + steps: + - uses: actions/checkout@v4 + + - uses: dtolnay/rust-toolchain@stable + + - name: Cache cargo + uses: Swatinem/rust-cache@v2 + + - name: Cache the embedding model + uses: ./.github/actions/hf-model-cache + + - uses: actions/setup-node@v4 + with: + node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json + + - name: Install UI dependencies + run: | + npm ci --prefix crates/workshop-server/ui + npm ci --prefix crates/gateway-config-ui/ui + + - name: Docs + run: cargo doc --workspace --no-deps --all-features --exclude workshop --exclude workshop-server + check-workshop: runs-on: windows-latest env: @@ -94,6 +152,9 @@ jobs: with: components: clippy + - name: Install cargo-nextest + uses: taiki-e/install-action@nextest + - name: Cache cargo uses: Swatinem/rust-cache@v2 @@ -103,16 +164,19 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies - working-directory: crates/workshop-server/ui - run: npm ci + run: | + npm ci --prefix crates/workshop-server/ui + npm ci --prefix crates/gateway-config-ui/ui - name: Clippy (workshop) run: cargo clippy -p workshop -p workshop-server --all-targets -- -D warnings - - name: Test (workshop) - run: cargo test --locked -p workshop -p workshop-server + - name: Test (workshop, concurrent via nextest) + run: cargo nextest run --locked -p workshop -p workshop-server - name: Clean tree shell: bash @@ -146,15 +210,18 @@ jobs: - name: Install Tauri system packages run: | sudo apt-get update - sudo apt-get install -y libwebkit2gtk-4.1-dev libssl-dev librsvg2-dev + sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev libssl-dev librsvg2-dev - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies - working-directory: crates/workshop-server/ui - run: npm ci + run: | + npm ci --prefix crates/workshop-server/ui + npm ci --prefix crates/gateway-config-ui/ui - name: Build (workshop, Linux) run: cargo build --locked -p workshop @@ -179,6 +246,8 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies working-directory: crates/workshop-server/ui @@ -220,8 +289,9 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@1.89.0 - with: - components: rustfmt + + - name: Install cargo-nextest + uses: taiki-e/install-action@nextest - name: Cache cargo uses: Swatinem/rust-cache@v2 @@ -232,31 +302,25 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies - working-directory: crates/workshop-server/ui - run: npm ci - - - name: Install config UI dependencies - working-directory: crates/gateway-config-ui/ui - run: npm ci - - - name: Build and test on MSRV run: | - cargo build --locked --workspace --exclude workshop --exclude workshop-server --all-features - cargo test --locked --workspace --exclude workshop --exclude workshop-server --all-features + npm ci --prefix crates/workshop-server/ui + npm ci --prefix crates/gateway-config-ui/ui + + - name: Test on MSRV + run: cargo nextest run --locked --workspace --exclude workshop --exclude workshop-server --all-features supply-chain: runs-on: ubuntu-latest - env: - RUSTUP_TOOLCHAIN: stable steps: - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - - name: Install cargo-deny and cargo-audit - run: cargo install cargo-deny cargo-audit --locked + - uses: taiki-e/install-action@v2 + with: + tool: cargo-deny, cargo-audit - name: cargo deny run: cargo deny check diff --git a/.github/workflows/dist-ci/build-setup.yml b/.github/workflows/dist-ci/build-setup.yml index 2a5b8d56..356b7f0c 100644 --- a/.github/workflows/dist-ci/build-setup.yml +++ b/.github/workflows/dist-ci/build-setup.yml @@ -8,6 +8,8 @@ uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies run: npm ci --prefix crates/workshop-server/ui - name: Install config UI dependencies diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 98b68b32..0b48d917 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -66,6 +66,8 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies run: | npm ci --prefix crates/workshop-server/ui @@ -97,6 +99,8 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies run: | npm ci --prefix crates/workshop-server/ui @@ -157,6 +161,8 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies working-directory: crates/workshop-server/ui diff --git a/.github/workflows/release-workshop.yml b/.github/workflows/release-workshop.yml index e66b2918..5d97e760 100644 --- a/.github/workflows/release-workshop.yml +++ b/.github/workflows/release-workshop.yml @@ -66,6 +66,8 @@ jobs: - uses: actions/setup-node@v4 with: node-version: 22 + cache: npm + cache-dependency-path: crates/*/ui/package-lock.json - name: Install UI dependencies working-directory: crates/workshop-server/ui @@ -88,7 +90,7 @@ jobs: # xdg-utils: the AppImage bundler shells out to xdg-open, which the # ARM runner images do not preinstall (the x64 image does). # https://github.com/tauri-apps/tauri-action/issues/1319 - sudo apt-get install -y libwebkit2gtk-4.1-dev libssl-dev librsvg2-dev xdg-utils + sudo apt-get install -y --no-install-recommends libwebkit2gtk-4.1-dev libssl-dev librsvg2-dev xdg-utils # SIGNING (Windows): import the Authenticode certificate here once an # EV/OV cert exists; tauri-action picks it up from the machine store. diff --git a/.gitignore b/.gitignore index eae913f6..5d0630db 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ # The gateway sidecar staged for bundle.externalBin by CI before # `tauri build` (crates/workshop/tauri.conf.json); a build artifact. /crates/workshop/binaries/ +/plan-dist-manifest.json diff --git a/README.md b/README.md index a24e0c00..0022539e 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,12 @@ Rust 1.89 or later. Build, format, and test before you open a PR. CI runs `cargo fmt --check`, `clippy -D warnings`, and `cargo test --workspace`. +To enable automatic local pre-commit and pre-push validation hooks: + +```bash +git config core.hooksPath .githooks +``` + ![Creator](images/promptforge-portrait.png) ## License