diff options
| author | Simen A. W. Olsen <hello@simenandre.no> | 2026-05-29 00:06:48 +0200 |
|---|---|---|
| committer | Simen A. W. Olsen <hello@simenandre.no> | 2026-05-29 00:06:48 +0200 |
| commit | 0806fecb47f5a2a26e73ca8b6e28c08f9945ef75 (patch) | |
| tree | 824a12cbcba1b0c2ad704e7bd64e25fa2389f34b /validate.sh | |
| parent | 330a0c896970d99320529a47f186c831a6ecc4a0 (diff) | |
| download | ziglang-docs-epub-0806fecb47f5a2a26e73ca8b6e28c08f9945ef75.tar.gz ziglang-docs-epub-0806fecb47f5a2a26e73ca8b6e28c08f9945ef75.zip | |
fix problems after testing with epubcheck
Diffstat (limited to 'validate.sh')
| -rwxr-xr-x | validate.sh | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/validate.sh b/validate.sh new file mode 100755 index 0000000..f932f11 --- /dev/null +++ b/validate.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# Validate every generated EPUB with epubcheck (the official EPUB validator). +# Exits non-zero if any EPUB has errors, so it can gate CI. +# +# Requires epubcheck on PATH (e.g. `brew install epubcheck`). + +set -uo pipefail + +if ! command -v epubcheck >/dev/null 2>&1; then + echo "error: epubcheck not found. Install it (e.g. 'brew install epubcheck')." >&2 + exit 127 +fi + +shopt -s nullglob +epubs=(epubs/*.epub) +if [ ${#epubs[@]} -eq 0 ]; then + echo "error: no EPUBs in epubs/. Run 'zig build run' first." >&2 + exit 1 +fi + +fail=0 +for f in "${epubs[@]}"; do + if epubcheck "$f" >/dev/null 2>&1; then + echo "PASS $f" + else + echo "FAIL $f" + epubcheck "$f" 2>&1 | grep -E '^(ERROR|FATAL|WARNING)' | sed 's/^/ /' + fail=1 + fi +done + +exit $fail |
