docs(USAGE): hooks pre-commit/pre-push via run_agents_for_project.sh; fix hooks

This commit is contained in:
Debian 2025-08-28 11:58:27 +00:00
parent 25453b045e
commit 948b11793a
4 changed files with 34 additions and 32 deletions

View File

@ -75,26 +75,31 @@ git tag -a vYYYY.MM.P -m "release: vYYYY.MM.P (latest)"
git push && git push origin vYYYY.MM.P git push && git push origin vYYYY.MM.P
``` ```
### Hooks conseillés ### Hooks conseillés (agents centralisés via 4NK_template)
`.git/hooks/pre-commit`: `.git/hooks/pre-commit`:
```bash ```bash
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -euo pipefail
npx -y markdownlint-cli "**/*.md" --ignore "archive/**" PROJECT_DIR="$(git rev-parse --show-toplevel)"
AUTO_FIX=1 SCOPE=changed scripts/agents/run.sh TEMPLATE_DIR="$(cd "${PROJECT_DIR}/../4NK_template" && pwd)"
mkdir -p "${PROJECT_DIR}/tests/reports/agents"
"${TEMPLATE_DIR}/scripts/local/run_agents_for_project.sh" "${PROJECT_DIR}" "tests/reports/agents"
``` ```
`.git/hooks/pre-push`: `.git/hooks/pre-push`:
```bash ```bash
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -euo pipefail
AUTO_FIX=1 SCOPE=all scripts/agents/run.sh PROJECT_DIR="$(git rev-parse --show-toplevel)"
bash scripts/security/audit.sh || true TEMPLATE_DIR="$(cd "${PROJECT_DIR}/../4NK_template" && pwd)"
bash scripts/release/guard.sh || true mkdir -p "${PROJECT_DIR}/tests/reports/agents"
"${TEMPLATE_DIR}/scripts/local/run_agents_for_project.sh" "${PROJECT_DIR}" "tests/reports/agents"
if [ -f "${PROJECT_DIR}/scripts/security/audit.sh" ]; then (cd "${PROJECT_DIR}" && bash scripts/security/audit.sh) || true; fi
if [ -f "${PROJECT_DIR}/scripts/release/guard.sh" ]; then (cd "${PROJECT_DIR}" && bash scripts/release/guard.sh) || true; fi
``` ```
Ou installez-les automatiquement: Ou installez-les automatiquement (les hooks fournis appellent déjà le runner centralisé):
```bash ```bash
bash scripts/local/install_hooks.sh bash scripts/local/install_hooks.sh

View File

@ -12,7 +12,8 @@ install_hook() {
echo "Installed hook: $name" echo "Installed hook: $name"
} }
# Hooks qui délèguent aux agents via l'image Docker du template sur le projet courant
install_hook pre-commit "$REPO_ROOT/scripts/local/precommit.sh" install_hook pre-commit "$REPO_ROOT/scripts/local/precommit.sh"
install_hook pre-push "$REPO_ROOT/scripts/local/prepush.sh" install_hook pre-push "$REPO_ROOT/scripts/local/prepush.sh"
echo "Hooks installés." echo "Hooks installés (mode agents via 4NK_template)."

View File

@ -1,16 +1,11 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # Exécuter les agents depuis l'image Docker de 4NK_template sur le projet courant
cd "$ROOT_DIR/.." PROJECT_DIR="$(git rev-parse --show-toplevel)"
TEMPLATE_DIR="$(cd "${PROJECT_DIR}/../4NK_template" && pwd)"
# Exécuter les agents via le conteneur CI (Docker Compose) mkdir -p "${PROJECT_DIR}/tests/reports/agents"
if command -v docker >/dev/null 2>&1; then "${TEMPLATE_DIR}/scripts/local/run_agents_for_project.sh" "${PROJECT_DIR}" "tests/reports/agents"
docker compose -f docker-compose.ci.yml build
RUNNER_MODE="agents" docker compose -f docker-compose.ci.yml up --abort-on-container-exit
else
echo "Docker requis pour exécuter les agents via conteneur." >&2
exit 2
fi
echo "[pre-commit] OK (agents via Docker)" echo "[pre-commit] OK (agents via 4NK_template)"

View File

@ -1,20 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # Exécuter les agents depuis l'image Docker de 4NK_template sur le projet courant
cd "$ROOT_DIR/.." PROJECT_DIR="$(git rev-parse --show-toplevel)"
TEMPLATE_DIR="$(cd "${PROJECT_DIR}/../4NK_template" && pwd)"
# Agents complets mkdir -p "${PROJECT_DIR}/tests/reports/agents"
AUTO_FIX="${AUTO_FIX:-1}" SCOPE="${SCOPE:-all}" scripts/agents/run.sh "${TEMPLATE_DIR}/scripts/local/run_agents_for_project.sh" "${PROJECT_DIR}" "tests/reports/agents"
# Audit sécurité (best effort) # Audit sécurité (best effort) dans le contexte du projet
if [ -f scripts/security/audit.sh ]; then if [ -f "${PROJECT_DIR}/scripts/security/audit.sh" ]; then
bash scripts/security/audit.sh || true (cd "${PROJECT_DIR}" && bash scripts/security/audit.sh) || true
fi fi
# Release guard (dry-run logique) # Release guard (dry-run logique) dans le contexte du projet
if [ -f scripts/release/guard.sh ]; then if [ -f "${PROJECT_DIR}/scripts/release/guard.sh" ]; then
bash scripts/release/guard.sh || true (cd "${PROJECT_DIR}" && bash scripts/release/guard.sh) || true
fi fi
echo "[pre-push] OK" echo "[pre-push] OK (agents via 4NK_template)"