Commit 0c3ae43c authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'docs-lint-script-update' into 'master'

Let docs-lint tests all run to completion before failing

See merge request gitlab-org/gitlab!27097
parents d425c1f5 ac9ffbd9
...@@ -2,36 +2,41 @@ ...@@ -2,36 +2,41 @@
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
echo "=> Linting documents at path $(pwd) as $(whoami)..." echo "=> Linting documents at path $(pwd) as $(whoami)..."
echo
ERRORCODE=0
# Use long options (e.g. --header instead of -H) for curl examples in documentation. # Use long options (e.g. --header instead of -H) for curl examples in documentation.
echo '=> Checking for cURL short options...' echo '=> Checking for cURL short options...'
echo
grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/ >/dev/null 2>&1 grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/ >/dev/null 2>&1
if [ $? -eq 0 ] if [ $? -eq 0 ]
then then
echo '✖ ERROR: Short options for curl should not be used in documentation! echo '✖ ERROR: Short options for curl should not be used in documentation!
Use long options (e.g., --header instead of -H):' >&2 Use long options (e.g., --header instead of -H):' >&2
grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/ grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/
exit 1 ((ERRORCODE++))
fi fi
# Ensure that the CHANGELOG.md does not contain duplicate versions # Ensure that the CHANGELOG.md does not contain duplicate versions
DUPLICATE_CHANGELOG_VERSIONS=$(grep --extended-regexp '^## .+' CHANGELOG.md | sed -E 's| \(.+\)||' | sort -r | uniq -d) DUPLICATE_CHANGELOG_VERSIONS=$(grep --extended-regexp '^## .+' CHANGELOG.md | sed -E 's| \(.+\)||' | sort -r | uniq -d)
echo '=> Checking for CHANGELOG.md duplicate entries...' echo '=> Checking for CHANGELOG.md duplicate entries...'
echo
if [ "${DUPLICATE_CHANGELOG_VERSIONS}" != "" ] if [ "${DUPLICATE_CHANGELOG_VERSIONS}" != "" ]
then then
echo '✖ ERROR: Duplicate versions in CHANGELOG.md:' >&2 echo '✖ ERROR: Duplicate versions in CHANGELOG.md:' >&2
echo "${DUPLICATE_CHANGELOG_VERSIONS}" >&2 echo "${DUPLICATE_CHANGELOG_VERSIONS}" >&2
exit 1 ((ERRORCODE++))
fi fi
# Make sure no files in doc/ are executable # Make sure no files in doc/ are executable
EXEC_PERM_COUNT=$(find doc/ -type f -perm 755 | wc -l) EXEC_PERM_COUNT=$(find doc/ -type f -perm 755 | wc -l)
echo "=> Checking $(pwd)/doc for executable permissions..." echo "=> Checking $(pwd)/doc for executable permissions..."
echo
if [ "${EXEC_PERM_COUNT}" -ne 0 ] if [ "${EXEC_PERM_COUNT}" -ne 0 ]
then then
echo '✖ ERROR: Executable permissions should not be used in documentation! Use `chmod 644` to the files in question:' >&2 echo '✖ ERROR: Executable permissions should not be used in documentation! Use `chmod 644` to the files in question:' >&2
find doc/ -type f -perm 755 find doc/ -type f -perm 755
exit 1 ((ERRORCODE++))
fi fi
# Do not use 'README.md', instead use 'index.md' # Do not use 'README.md', instead use 'index.md'
...@@ -39,13 +44,14 @@ fi ...@@ -39,13 +44,14 @@ fi
NUMBER_READMES=46 NUMBER_READMES=46
FIND_READMES=$(find doc/ -name "README.md" | wc -l) FIND_READMES=$(find doc/ -name "README.md" | wc -l)
echo '=> Checking for new README.md files...' echo '=> Checking for new README.md files...'
echo
if [ ${FIND_READMES} -ne $NUMBER_READMES ] if [ ${FIND_READMES} -ne $NUMBER_READMES ]
then then
echo echo
echo ' ✖ ERROR: New README.md file(s) detected, prefer index.md over README.md.' >&2 echo ' ✖ ERROR: New README.md file(s) detected, prefer index.md over README.md.' >&2
echo ' https://docs.gitlab.com/ee/development/documentation/styleguide.html#work-with-directories-and-files' echo ' https://docs.gitlab.com/ee/development/documentation/styleguide.html#work-with-directories-and-files'
echo echo
exit 1 ((ERRORCODE++))
fi fi
MD_DOC_PATH=${MD_DOC_PATH:-doc} MD_DOC_PATH=${MD_DOC_PATH:-doc}
...@@ -64,7 +70,7 @@ function run_locally_or_in_docker() { ...@@ -64,7 +70,7 @@ function run_locally_or_in_docker() {
echo echo
echo " ✖ ERROR: '${cmd}' not found. Install '${cmd}' or Docker to proceed." >&2 echo " ✖ ERROR: '${cmd}' not found. Install '${cmd}' or Docker to proceed." >&2
echo echo
exit 1 ((ERRORCODE++))
fi fi
if [ $? -ne 0 ] if [ $? -ne 0 ]
...@@ -72,15 +78,22 @@ function run_locally_or_in_docker() { ...@@ -72,15 +78,22 @@ function run_locally_or_in_docker() {
echo echo
echo " ✖ ERROR: '${cmd}' failed with errors." >&2 echo " ✖ ERROR: '${cmd}' failed with errors." >&2
echo echo
exit 1 ((ERRORCODE++))
fi fi
} }
echo '=> Linting markdown style...' echo '=> Linting markdown style...'
echo
run_locally_or_in_docker 'markdownlint' "--config .markdownlint.json ${MD_DOC_PATH}" run_locally_or_in_docker 'markdownlint' "--config .markdownlint.json ${MD_DOC_PATH}"
echo '=> Linting prose...' echo '=> Linting prose...'
run_locally_or_in_docker 'vale' "--minAlertLevel error ${MD_DOC_PATH}" run_locally_or_in_docker 'vale' "--minAlertLevel error ${MD_DOC_PATH}"
echo "✔ Linting passed" if [ $ERRORCODE -ne 0 ]
exit 0 then
echo "✖ ${ERRORCODE} lint test(s) failed. Review the log carefully to see full listing."
exit 1
else
echo "✔ Linting passed"
exit 0
fi
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment