From b1dd06eef17851b106d1107ea9fcfd6ded4e08ae Mon Sep 17 00:00:00 2001 From: Kernc Date: Sun, 27 Nov 2022 06:14:39 +0100 Subject: [PATCH] BUG: Fix docs build broken link check bug --- .github/workflows/ci.yml | 2 +- doc/build.sh | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f6522d2b..574e2d0a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -53,4 +53,4 @@ jobs: run: time catchsegv python -m backtesting.test - if: matrix.test-type == 'docs' - run: time catchsegv doc/build.sh + run: time catchsegv bash doc/build.sh diff --git a/doc/build.sh b/doc/build.sh index 981e9ffa..b5defb82 100755 --- a/doc/build.sh +++ b/doc/build.sh @@ -71,6 +71,7 @@ echo echo 'Testing for broken links' echo pushd "$BUILDROOT" >/dev/null +tree . WEBSITE='https://kernc\.github\.io/backtesting\.py' grep -PR '(cat 1>&2) | python -c ' import sys from urllib.parse import urljoin @@ -90,9 +92,12 @@ for line in sys.stdin.readlines(): grep -v $'\t''$' | while read -r line; do while IFS=$'\t' read -r file url; do - url=$(python -c 'import html, sys; print(html.unescape(sys.argv[-1]))' "$url") - [ -f "$url" ] || - curl --silent --fail --retry 5 --retry-delay 5 --user-agent 'Mozilla/5.0 Firefox 61' "$url" >/dev/null 2>&1 || + target_file="$(python -c 'import html, sys; print(html.unescape(sys.argv[-1]))' "$url")" + echo "$target_file" + if [ -f "$target_file" ]; then continue; fi + + url="${url// /%20}" + curl --silent --fail --retry 5 --retry-delay 5 --user-agent 'Mozilla/5.0 Firefox 61' "$url" >/dev/null 2>&1 || die "broken link in $file: $url" done done