107 lines
2.6 KiB
Bash
Executable File
107 lines
2.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Lance en local les mêmes vérifications que le CI (.gitea/workflows/).
|
|
# À exécuter avant de pousser : scripts/check.sh
|
|
#
|
|
# Un outil manquant n'est pas bloquant : le check correspondant est ignoré
|
|
# avec un avertissement (le CI, lui, exécute tout). Le script retourne un
|
|
# code non nul si une vérification échoue.
|
|
|
|
set -u
|
|
cd "$(dirname "$0")/.."
|
|
|
|
fail=0
|
|
warn=0
|
|
|
|
step() { printf '\n\033[1m== %s ==\033[0m\n' "$1"; }
|
|
|
|
# need <commande> <paquet> : vérifie la présence d'un outil
|
|
need() {
|
|
if ! command -v "$1" >/dev/null 2>&1; then
|
|
echo "⚠️ '$1' non installé — check ignoré (paquet : $2)"
|
|
warn=1
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
step "PHP lint (*.php, *.php.sample)"
|
|
if need php php-cli; then
|
|
php_fail=0
|
|
while IFS= read -r f; do
|
|
if ! php -l "$f" > /dev/null; then
|
|
echo "❌ $f"
|
|
php_fail=1
|
|
fi
|
|
done < <(find . -path ./.git -prune -o \( -name '*.php' -o -name '*.php.sample' \) -print)
|
|
if [ "$php_fail" -eq 0 ]; then
|
|
echo "✅ PHP OK"
|
|
else
|
|
fail=1
|
|
fi
|
|
fi
|
|
|
|
step "JS lint (sw.js, js/*.js)"
|
|
if need node nodejs; then
|
|
js_fail=0
|
|
for f in sw.js js/*.js; do
|
|
node --check "$f" || js_fail=1
|
|
done
|
|
if [ "$js_fail" -eq 0 ]; then
|
|
echo "✅ JS OK"
|
|
else
|
|
fail=1
|
|
fi
|
|
fi
|
|
|
|
step "AsciiDoc (README.adoc, DEPLOY.adoc)"
|
|
if need asciidoctor asciidoctor; then
|
|
adoc_fail=0
|
|
for f in README.adoc DEPLOY.adoc; do
|
|
[ -f "$f" ] || continue
|
|
asciidoctor -o "/tmp/check-$$.html" "$f" || adoc_fail=1
|
|
done
|
|
rm -f "/tmp/check-$$.html"
|
|
if [ "$adoc_fail" -eq 0 ]; then
|
|
echo "✅ AsciiDoc OK"
|
|
else
|
|
fail=1
|
|
fi
|
|
fi
|
|
|
|
step "JSON (site.webmanifest.sample)"
|
|
if need python3 python3; then
|
|
if python3 -m json.tool site.webmanifest.sample > /dev/null; then
|
|
echo "✅ JSON OK"
|
|
else
|
|
fail=1
|
|
fi
|
|
fi
|
|
|
|
step "XML (sitemap.xml.sample, browserconfig.xml)"
|
|
if need xmllint libxml2-utils; then
|
|
if xmllint --noout sitemap.xml.sample browserconfig.xml; then
|
|
echo "✅ XML OK"
|
|
else
|
|
fail=1
|
|
fi
|
|
fi
|
|
|
|
step "Shellcheck (scripts shell)"
|
|
if need shellcheck shellcheck; then
|
|
if shellcheck docs/generate-readme-pdf.sh scripts/check.sh; then
|
|
echo "✅ Shellcheck OK"
|
|
else
|
|
fail=1
|
|
fi
|
|
fi
|
|
|
|
echo
|
|
if [ "$fail" -ne 0 ]; then
|
|
echo "❌ Des vérifications ont échoué — corrigez avant de pousser."
|
|
exit 1
|
|
fi
|
|
if [ "$warn" -ne 0 ]; then
|
|
echo "⚠️ Checks disponibles OK, mais certains outils manquent (le CI exécutera tout)."
|
|
else
|
|
echo "✅ Tous les checks passent."
|
|
fi
|