ba4be087d5
Create PR to main with cherry-pick from release / cherry-pick (push) Failing after 0s
CICD NeMo / pre-flight (push) Failing after 0s
CICD NeMo / configure (push) Has been skipped
Build, validate, and release Neural Modules / pre-flight (push) Failing after 1s
CICD NeMo / code-linting (push) Has been skipped
Build, validate, and release Neural Modules / release (push) Has been skipped
Build, validate, and release Neural Modules / release-summary (push) Has been cancelled
CICD NeMo / cicd-test-container-build (push) Has been cancelled
CICD NeMo / cicd-import-tests (push) Has been cancelled
CICD NeMo / L0_Setup_Test_Data_And_Models (push) Has been cancelled
CICD NeMo / cicd-main-unit-tests (push) Has been cancelled
CICD NeMo / cicd-main-speech (push) Has been cancelled
CICD NeMo / Nemo_CICD_Test (push) Has been cancelled
CICD NeMo / Coverage (e2e) (push) Has been cancelled
CICD NeMo / Coverage (unit-test) (push) Has been cancelled
CodeQL / Analyze (python) (push) Has been cancelled
CICD NeMo / cicd-wait-in-queue (push) Has been cancelled
52 lines
1.7 KiB
Bash
Executable File
52 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
DOCS_DIR=$(dirname "${BASH_SOURCE[0]}")
|
|
FALSE_POSITIVES_JSON="${DOCS_DIR}/false_positives.json"
|
|
NEEDS_REVIEW_JSON="${DOCS_DIR}/links_needing_review.json"
|
|
LINKCHECK_JSON="${DOCS_DIR}/build/linkcheck/output.json"
|
|
|
|
function check_environment {
|
|
local err=0
|
|
if ! [ -x "$(command -v jq)" ]; then
|
|
>&2 echo "jq is required but is not found."
|
|
((err++))
|
|
fi
|
|
if [ ! -f "${FALSE_POSITIVES_JSON}" ]; then
|
|
>&2 echo "A JSON file with false positives is required: ${FALSE_POSITIVES_JSON}"
|
|
((err++))
|
|
fi
|
|
if [ ! -f "${LINKCHECK_JSON}" ]; then
|
|
>&2 echo "Did not find linkcheck output JSON file: ${LINKCHECK_JSON}."
|
|
>&2 echo "Run Sphinx with the linkcheck arg: make -C docs clean linkcheck"
|
|
((err++))
|
|
fi
|
|
if [ "${err}" -gt 0 ]; then
|
|
exit 2
|
|
fi
|
|
}
|
|
|
|
function check_links {
|
|
local err=0
|
|
broken=$(jq -s 'map(select(.status=="broken"))' "$LINKCHECK_JSON")
|
|
count=$(echo "${broken}" | jq 'length')
|
|
for i in $(seq 0 $(($count - 1)))
|
|
do
|
|
entry=$(echo "${broken}" | jq ".[${i}]")
|
|
link=$(echo "${entry}" | jq -r '.uri')
|
|
[ -n "${DEBUG}" ] && {
|
|
echo >&2 "Checking for false positive: ${link}"
|
|
}
|
|
local false_positive_resp; false_positive_resp=$(jq --arg check "${link}" -s 'any(.uri == $check)' < "${FALSE_POSITIVES_JSON}")
|
|
local needs_review_resp; needs_review_resp=$(jq --arg check "${link}" -s 'any(.uri == $check)' < "${NEEDS_REVIEW_JSON}")
|
|
# "false" indicates that the URL did not match any of the URIs in the false positive file.
|
|
if [[ "false" = "${false_positive_resp}" && "false" = "${needs_review_resp}" ]]; then
|
|
((err++))
|
|
echo "${entry}"
|
|
fi
|
|
done
|
|
exit "${err}"
|
|
}
|
|
|
|
check_environment
|
|
check_links
|