debian-mirror-gitlab/scripts/lint-doc.sh

66 lines
2.2 KiB
Bash
Raw Normal View History

2016-09-13 17:45:13 +05:30
#!/usr/bin/env bash
cd "$(dirname "$0")/.."
# Use long options (e.g. --header instead of -H) for curl examples in documentation.
2018-05-09 12:01:36 +05:30
echo '=> Checking for cURL short options...'
2018-03-17 18:26:18 +05:30
grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/ >/dev/null 2>&1
2018-11-20 20:47:30 +05:30
if [ $? -eq 0 ]
2016-09-13 17:45:13 +05:30
then
2018-03-17 18:26:18 +05:30
echo '✖ ERROR: Short options for curl should not be used in documentation!
Use long options (e.g., --header instead of -H):' >&2
grep --extended-regexp --recursive --color=auto 'curl (.+ )?-[^- ].*' doc/
2016-09-13 17:45:13 +05:30
exit 1
fi
2016-11-03 12:29:30 +05:30
# 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)
2018-05-09 12:01:36 +05:30
echo '=> Checking for CHANGELOG.md duplicate entries...'
2016-11-03 12:29:30 +05:30
if [ "${DUPLICATE_CHANGELOG_VERSIONS}" != "" ]
then
echo '✖ ERROR: Duplicate versions in CHANGELOG.md:' >&2
echo "${DUPLICATE_CHANGELOG_VERSIONS}" >&2
exit 1
fi
2018-03-17 18:26:18 +05:30
# Make sure no files in doc/ are executable
EXEC_PERM_COUNT=$(find doc/ app/ -type f -perm 755 | wc -l)
2018-05-09 12:01:36 +05:30
echo '=> Checking for executable permissions...'
2018-03-17 18:26:18 +05:30
if [ "${EXEC_PERM_COUNT}" -ne 0 ]
then
echo '✖ ERROR: Executable permissions should not be used in documentation! Use `chmod 644` to the files in question:' >&2
find doc/ app/ -type f -perm 755
exit 1
fi
2018-05-09 12:01:36 +05:30
# Do not use 'README.md', instead use 'index.md'
# Number of 'README.md's as of 2018-03-26
2019-07-31 22:56:46 +05:30
NUMBER_READMES_CE=46
2018-05-09 12:01:36 +05:30
NUMBER_READMES_EE=46
FIND_READMES=$(find doc/ -name "README.md" | wc -l)
echo '=> Checking for new README.md files...'
if [ "${CI_PROJECT_NAME}" == 'gitlab-ce' ]
then
if [ ${FIND_READMES} -ne ${NUMBER_READMES_CE} ]
then
echo
echo ' ✖ ERROR: New README.md file(s) detected, prefer index.md over README.md.' >&2
echo ' https://docs.gitlab.com/ee/development/writing_documentation.html#location-and-naming-documents'
echo
exit 1
fi
elif [ "${CI_PROJECT_NAME}" == 'gitlab-ee' ]
then
if [ ${FIND_READMES} -ne $NUMBER_READMES_EE ]
then
echo
echo ' ✖ ERROR: New README.md file(s) detected, prefer index.md over README.md.' >&2
echo ' https://docs.gitlab.com/ee/development/writing_documentation.html#location-and-naming-documents'
echo
exit 1
fi
fi
2016-09-13 17:45:13 +05:30
echo "✔ Linting passed"
exit 0