feat: enforce lint checks as gate for commits and CI (#54)
All checks were successful
Deploy Feature Branch to Test / PHP Syntax Check (push) Successful in 34s
Deploy Feature Branch to Test / CSS Lint (stylelint) (push) Successful in 1m12s
Deploy Feature Branch to Test / HTML Lint (htmlhint) (push) Successful in 1m10s
Lint / PHP Syntax Check (push) Successful in 32s
Lint / CSS Lint (stylelint) (push) Successful in 1m14s
Lint / HTML Lint (htmlhint) (push) Successful in 1m9s
Lint / PHP Syntax Check (pull_request) Successful in 32s
Lint / CSS Lint (stylelint) (pull_request) Successful in 1m11s
Lint / HTML Lint (htmlhint) (pull_request) Successful in 1m9s
Deploy Feature Branch to Test / Deploy to Test Environment (push) Successful in 24s

- Add PHP syntax check to lint-staged via scripts/lint-php.sh
- Add lint:php script to package.json
- Update lint script to include PHP checks
- Create scripts/safe-commit.sh for AI agent use
- Update deploy-test.yml: lint jobs as gate before deploy
- Add branch protection for main requiring status checks
- Update AGENTS.md with pre-commit hook rules for agents

Also addresses #53: CI requires lint checks before merge

Co-authored-by: Claw <claw@openclaw.local>
This commit is contained in:
Claw
2026-05-22 07:25:57 +00:00
parent 6b605bb961
commit fb646eba85
5 changed files with 157 additions and 8 deletions

37
scripts/safe-commit.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env bash
# safe-commit.sh Commit with pre-commit hooks guaranteed to run
# Usage: ./scripts/safe-commit.sh "commit message"
#
# This script ensures lint checks always execute, even when committing
# from non-interactive contexts (CI, AI agents, etc.).
set -euo pipefail
if [ -z "${1:-}" ]; then
echo "❌ Usage: ./scripts/safe-commit.sh \"commit message\""
exit 1
fi
MSG="$1"
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$REPO_ROOT"
# Ensure hooks directory exists and is configured
if [ -d ".husky" ]; then
git config core.hooksPath .husky
fi
# Run lint-staged manually as a safety net (in case hook is skipped)
if command -v npx &>/dev/null && [ -f "node_modules/.bin/lint-staged" ]; then
echo "🔍 Running pre-commit lint checks..."
npx lint-staged || {
echo ""
echo "❌ Lint checks failed. Commit aborted."
echo " Fix the errors above and try again."
exit 1
}
echo "✅ All lint checks passed."
fi
# Commit with hooks enabled (no --no-verify)
git commit -m "$MSG"