From 313c3b84f38984b2eb9027016029ee0f1eddece9 Mon Sep 17 00:00:00 2001 From: Fodesu <75713465+Fodesu@users.noreply.github.com> Date: Fri, 20 Feb 2026 22:40:37 +0800 Subject: [PATCH] chore(husky): large file pre-commit check support (#75) * chore: add large file check in husky * refactor(husky): modularize pre-commit hooks * chore(lint): add vitepress generate cache dir to eslint ignores config * fix(container): propagate host timezone to all containers Replace TZ env var with /etc/localtime bind-mount in docker-compose and inject timezone spec opts into containerd bot containers. * ci(docker): add docker-publish workflow and clean up release.yml Add dedicated docker-publish.yml with full CI/CD pipeline: - Build & push server/agent/web/mcp images on tag, main push, and PR - Publish to both Docker Hub and GHCR - Semver tag strategy (latest, version, major.minor, major, sha) - GHA build cache, SLSA provenance, and SBOM - PR builds validate without pushing Remove superseded dockerhub job from release.yml. * ci: add migration validation workflow Run migrate up -> down -> up against a temporary PostgreSQL service container on every PR and push to main, verifying all migrations apply, rollback, and re-apply correctly. * ci(docker): only push on tag, skip latest for prereleases - Remove push-to-main trigger; only tag push publishes images - Prerelease tags (e.g. v0.1.0-beta.2) publish their version tag only, without updating latest or short semver tags * ci: optimize workflow performance - PR docker builds use single arch (amd64 only), tag push uses dual - Add paths-ignore to skip CI on docs-only changes - Add concurrency groups to cancel stale runs on re-push - Build Go binary once instead of 3x go run in migrate job * ci: only run migrate job when db/migrations changes * fix: change memory message role from system to user caused by the imcompatibility of anthropic messages api * chore(husky): rm web build --------- Co-authored-by: BBQ Co-authored-by: Acbox --- .husky/check-large-files | 29 +++++++++++++++++++++++++++++ .husky/check-pnpm | 6 ++++++ .husky/pre-commit | 9 +++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 .husky/check-large-files create mode 100755 .husky/check-pnpm diff --git a/.husky/check-large-files b/.husky/check-large-files new file mode 100755 index 00000000..2c526eef --- /dev/null +++ b/.husky/check-large-files @@ -0,0 +1,29 @@ +#!/usr/bin/env sh +# Check for large files before commit + +MAX_SIZE=1048576 # 1MB in bytes + +files=$(git diff --cached --name-only --diff-filter=ACMR) +has_large_file=false + +echo "Checking for large files..." + +for file in $files; do + if [ -f "$file" ]; then + size=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null) + if [ "$size" -gt "$MAX_SIZE" ]; then + size_mb=$(echo "scale=2; $size / 1048576" | bc 2>/dev/null || echo "$((size / 1048576))") + echo " File '$file' is too large (${size_mb}MB). Maximum allowed is $((MAX_SIZE / 1048576))MB." + has_large_file=true + fi + fi +done + +if [ "$has_large_file" = true ]; then + echo "" + echo "Error: Large files detected. Commit rejected." + echo " If this is intentional, use: git commit --no-verify" + exit 1 +fi + +echo "File size check passed" diff --git a/.husky/check-pnpm b/.husky/check-pnpm new file mode 100755 index 00000000..122b43a5 --- /dev/null +++ b/.husky/check-pnpm @@ -0,0 +1,6 @@ +#!/usr/bin/env sh + +export PATH="$HOME/.local/share/mise/shims:$HOME/.local/bin:$HOME/.npm-global/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" + +echo "Check lint..." +pnpm lint:fix || true \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit index 529c2f6d..9d33a145 100644 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,5 +1,10 @@ #!/usr/bin/env sh -export PATH="$HOME/.local/share/mise/shims:$HOME/.local/bin:$HOME/.npm-global/bin:/opt/homebrew/bin:/usr/local/bin:$PATH" -pnpm lint:fix || true +# Get script directory +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" + +sh "$SCRIPT_DIR/check-large-files" || exit 1 + +echo "" +sh "$SCRIPT_DIR/check-pnpm" || exit 1