chore: add pre-push preflight + setup-hooks
Four-block pre-push gate matching the HellionChat pattern: - Block A (verify-version-consistency.sh): csproj <Version> vs repo.json AssemblyVersion / TestingAssemblyVersion / DownloadLink* tag presence. Tolerant of repo.json being absent so v0.1.0 (which has no public release manifest yet) does not fail at push time; the missing-file path turns into the full cross-check once repo.json lands. - Block B: dotnet build Anvil.sln -p:Platform=x64 -c Release. Platform pin is forge-wide (Forgeimizer v0.1.0 lesson: solution build defaults drift to AnyCPU otherwise). - Block C: dotnet csharpier check ./Anvil. Catches the accumulated formatter drift that hit HellionChat v1.5.6 (12 files) when only build was checked per task. - Block D: markdownlint-cli2 over the repo's *.md files (excludes node_modules, bin, obj, .claude, CLAUDE.md). Plus setup-hooks.sh as the one-shot installer that points core.hooksPath at .githooks/ and chmods the scripts. README.md: MD040 fix for the custom-repo URL fence (added text language tag).
This commit is contained in:
Executable
+3
@@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# .githooks/pre-push — invokes preflight.sh (Blocks A/B/C/D).
|
||||||
|
exec scripts/preflight.sh
|
||||||
@@ -47,7 +47,7 @@ attribution.
|
|||||||
|
|
||||||
The custom Dalamud repository URL for Anvil is:
|
The custom Dalamud repository URL for Anvil is:
|
||||||
|
|
||||||
```
|
```text
|
||||||
https://gitea.hellion-forge.cloud/JonKazama-Hellion/Anvil/raw/branch/main/repo.json
|
https://gitea.hellion-forge.cloud/JonKazama-Hellion/Anvil/raw/branch/main/repo.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Executable
+31
@@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# preflight.sh — pre-push gate for the Anvil plugin repository.
|
||||||
|
#
|
||||||
|
# Block A — version consistency between Anvil.csproj <Version> and the
|
||||||
|
# public repo.json manifest (when it exists).
|
||||||
|
# Block B — dotnet build -p:Platform=x64 on the solution to catch
|
||||||
|
# compile-time API drift.
|
||||||
|
# Block C — dotnet csharpier check against Anvil/ for C# format drift
|
||||||
|
# (per feedback_hellion_chat_format_check_per_task: accumulated
|
||||||
|
# formatter drift in HellionChat v1.5.6 hit 12 files at push
|
||||||
|
# time when only build was checked per task).
|
||||||
|
# Block D — markdownlint-cli2 against the repo's *.md files.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
echo "==> preflight: Block A — version consistency"
|
||||||
|
./scripts/verify-version-consistency.sh
|
||||||
|
|
||||||
|
echo "==> preflight: Block B — plugin compile health"
|
||||||
|
dotnet build Anvil.sln -p:Platform=x64 --configuration Release --nologo --verbosity quiet
|
||||||
|
|
||||||
|
echo "==> preflight: Block C — csharpier reflow check"
|
||||||
|
dotnet csharpier check ./Anvil
|
||||||
|
|
||||||
|
echo "==> preflight: Block D — markdownlint"
|
||||||
|
# npx --yes avoids a global install; first run caches into ~/.npm/_npx/.
|
||||||
|
npx --yes markdownlint-cli2 "**/*.md" "#node_modules" "#bin" "#obj" "#.claude" "#CLAUDE.md"
|
||||||
|
|
||||||
|
echo "==> preflight: ALL GREEN"
|
||||||
Executable
+13
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# setup-hooks.sh — wire the local .githooks/ directory into core.hooksPath.
|
||||||
|
# Run once after cloning the repo. Idempotent; safe to re-run on every pull.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
cd "$ROOT"
|
||||||
|
|
||||||
|
git config core.hooksPath .githooks
|
||||||
|
chmod +x .githooks/pre-push
|
||||||
|
chmod +x scripts/*.sh
|
||||||
|
|
||||||
|
echo "setup-hooks: core.hooksPath -> .githooks (pre-push wired)"
|
||||||
Executable
+47
@@ -0,0 +1,47 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# verify-version-consistency.sh — Block A of preflight.
|
||||||
|
#
|
||||||
|
# v0.1.0 ships before the first repo.json release manifest exists, so this
|
||||||
|
# script is tolerant when the file is missing - the csproj <Version> is
|
||||||
|
# the single source of truth at the bootstrap stage. Once repo.json
|
||||||
|
# lands (probably v0.1.1 or v0.2.0), the missing-file path turns into a
|
||||||
|
# full csproj <-> repo.json AssemblyVersion + TestingAssemblyVersion +
|
||||||
|
# DownloadLink* tag check, matching the HellionChat preflight.
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
|
||||||
|
CSPROJ="$ROOT/Anvil/Anvil.csproj"
|
||||||
|
REPO_JSON="$ROOT/repo.json"
|
||||||
|
|
||||||
|
fail() { echo "verify-version-consistency: FAIL — $1" >&2; exit 1; }
|
||||||
|
ok() { echo "verify-version-consistency: OK — $1"; }
|
||||||
|
|
||||||
|
CSPROJ_VER="$(grep -oE '<Version>[^<]+</Version>' "$CSPROJ" | head -1 | sed -E 's/<[^>]+>//g')"
|
||||||
|
[ -n "$CSPROJ_VER" ] || fail "$CSPROJ has no <Version> element"
|
||||||
|
|
||||||
|
if [ ! -f "$REPO_JSON" ]; then
|
||||||
|
ok "csproj=$CSPROJ_VER (repo.json absent - bootstrap stage, skipping cross-check)"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
EXPECTED_4DIGIT="${CSPROJ_VER}.0"
|
||||||
|
|
||||||
|
REPO_VER="$(jq -r '.[0].AssemblyVersion' "$REPO_JSON")"
|
||||||
|
[ "$REPO_VER" = "$EXPECTED_4DIGIT" ] \
|
||||||
|
|| fail "csproj=$CSPROJ_VER expects repo.json AssemblyVersion=$EXPECTED_4DIGIT but got $REPO_VER. Fix: align in $REPO_JSON."
|
||||||
|
|
||||||
|
TEST_VER="$(jq -r '.[0].TestingAssemblyVersion' "$REPO_JSON")"
|
||||||
|
[ "$TEST_VER" = "$EXPECTED_4DIGIT" ] \
|
||||||
|
|| fail "TestingAssemblyVersion=$TEST_VER must match $EXPECTED_4DIGIT. Fix: align in $REPO_JSON."
|
||||||
|
|
||||||
|
TAG="v$CSPROJ_VER"
|
||||||
|
for KEY in DownloadLinkInstall DownloadLinkUpdate DownloadLinkTesting; do
|
||||||
|
URL="$(jq -r ".[0].$KEY" "$REPO_JSON")"
|
||||||
|
case "$URL" in
|
||||||
|
*"/$TAG/"*) ;;
|
||||||
|
*) fail "$KEY=$URL does not contain tag $TAG. Fix: update $REPO_JSON $KEY to releases/download/$TAG/latest.zip." ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
ok "csproj=$CSPROJ_VER, repo.json=$EXPECTED_4DIGIT, tag $TAG present in DownloadLinks"
|
||||||
Reference in New Issue
Block a user