|
22 | 22 | require "bundler/setup" |
23 | 23 | require "html-proofer" |
24 | 24 |
|
| 25 | +# --------------------------------------------------------- |
| 26 | +# External (remote) link checking is opt-in. |
| 27 | +# |
| 28 | +# Remote URL checks are slow and frequently fail in CI due to |
| 29 | +# rate limiting and transient network errors on third-party |
| 30 | +# sites. By default we skip them so normal CI runs stay fast |
| 31 | +# and reliable. Set CHECK_EXTERNAL_LINKS=true to enable the |
| 32 | +# full remote link check (used by the scheduled weekly run). |
| 33 | +# --------------------------------------------------------- |
| 34 | +check_external = %w[1 true yes].include?( |
| 35 | + ENV.fetch("CHECK_EXTERNAL_LINKS", "").strip.downcase |
| 36 | +) |
| 37 | + |
| 38 | +if check_external |
| 39 | + puts "==> Running HTMLProofer WITH external link checks" |
| 40 | +else |
| 41 | + puts "==> Running HTMLProofer WITHOUT external link checks " \ |
| 42 | + "(set CHECK_EXTERNAL_LINKS=true to enable)" |
| 43 | +end |
| 44 | + |
25 | 45 | # --------------------------------------------------------- |
26 | 46 | # URLs & patterns to ignore during link checking. |
27 | 47 | # Some websites block automated requests, cause false |
@@ -63,6 +83,7 @@ HTMLProofer::Runner.new( |
63 | 83 | ["_site"], # Directory containing the generated site |
64 | 84 | parallel: { in_threads: 4 }, # Speed up checks using 4 threads |
65 | 85 | type: :directory, |
| 86 | + disable_external: !check_external, # Skip remote URL checks unless opted in |
66 | 87 | ignore_urls: url_ignores, # Skip known-problematic URLs |
67 | 88 | check_html: true, # Validate HTML structure |
68 | 89 | check_opengraph: true, # Check for OpenGraph tags |
|
0 commit comments