PiRogueToolSuite / piroguetoolsuite.github.io

Source of the project website
https://pts-project.org/
MIT License
22 stars 14 forks source link

Add link checker pre-commit hook. #225

Closed arky closed 4 days ago

arky commented 1 month ago

Add a git pre-commit link checker. Unfortunately hugo doesn't have tests to check for broken links.

The current broken links on v2 branch are as follows:

$ linkrot http://localhost:1313
"https://firefox-source-docs.mozilla.org/security/nss/legacy/key_log_format/index.html": bad status: 404 Not Found
 - refs: http://localhost:1313/docs/recipes/how-to-intercept-and-decrypt-tls-traffic/, http://localhost:1313/guides/g8/, http://localhost:1313/guides/g8
"https://github.com/skylot/jadx": page missing fragments
- ids: download
 - refs: http://localhost:1313/guides/g3, http://localhost:1313/guides/g3/
"https://github.com/PiRogueToolSuite/colander": page missing fragments
- ids: production-environment
 - refs: http://localhost:1313/blog/monthly-report-n23-2023-12/
"https://pts-project.org/docs/pirogue/upgrade-a-pirogue/": bad status: 404 Not Found
 - refs: http://localhost:1313/blog/monthly-report-n7-2022-08/
"http://pirogue.local:3000": Get "http://pirogue.local:3000": dial tcp: lookup pirogue.local: no such host
 - refs: http://localhost:1313/guides/g1, http://localhost:1313/guides/g2/, http://localhost:1313/docs/pirogue/dashboard/, http://localhost:1313/guides/g1/, http://localhost:1313/guides/g2
"https://pts-project.org/docs/pirogue/configure-a-pirogue/": bad status: 404 Not Found
 - refs: http://localhost:1313/blog/monthly-report-n7-2022-08/
"https://pts-project.org/docs/pirogue/build-a-pirogue/": bad status: 404 Not Found
 - refs: http://localhost:1313/blog/monthly-report-n14-2023-03/
"https://pts-project.org/docs/pirogue/operate-a-pirogue/": bad status: 404 Not Found
 - refs: http://localhost:1313/blog/monthly-report-n7-2022-08/
U039b commented 1 month ago

Good catch! :grimacing:

U039b commented 1 month ago

Maybe we can add a pre-commit hook based on linkrot and a check in the CI interrupting the build if a broken link is detected.

arky commented 1 month ago

@U039b I found htmltest better than linkrot.

U039b commented 3 weeks ago

Stupid and simple pre-commit hook:

#!/bin/sh
exec 1>&2
if [ ! -f bin/htmltest ]; then
    echo "htmltest binary not found. Check its documentation https://github.com/wjdp/htmltest"
    exit 1
fi
rm -rf public/
npm run build
if ! ./bin/htmltest; then
    echo "Some links are broken"
    exit 1
fi
exit 0
arky commented 3 weeks ago

@U039b Very cool!

I have cleaned up the links that was making htmltest results noisy in this PR https://github.com/PiRogueToolSuite/piroguetoolsuite.github.io/pull/233

arky commented 4 days ago

@U039b Do you still want to add a pre-hook since we already have a good github linkrot checks?

U039b commented 4 days ago

I added this pre-commit hook on my side but it's not necessary to enforce it. So, we can close this issue.