Commit bc5f31c8 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Fix markdownlint when there are no md files detected

Add an extra clause to the lint-doc.sh script and check if the list of
markdown files is empty when a merge results pipeline is run. If it is,
skip the markdownlint check altogether.
parent a28219b2
...@@ -66,8 +66,11 @@ then ...@@ -66,8 +66,11 @@ then
else else
MERGE_BASE=$(git merge-base ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA} ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}) MERGE_BASE=$(git merge-base ${CI_MERGE_REQUEST_TARGET_BRANCH_SHA} ${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA})
MD_DOC_PATH=$(git diff --name-only "${MERGE_BASE}..${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}" 'doc/*.md') MD_DOC_PATH=$(git diff --name-only "${MERGE_BASE}..${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA}" 'doc/*.md')
echo -e "Merged results pipeline detected. Testing only the following files:\n${MD_DOC_PATH}" if [ -n "${MD_DOC_PATH}" ]
fi then
echo -e "Merged results pipeline detected. Testing only the following files:\n${MD_DOC_PATH}"
fi
fi
function run_locally_or_in_docker() { function run_locally_or_in_docker() {
local cmd=$1 local cmd=$1
...@@ -98,7 +101,12 @@ function run_locally_or_in_docker() { ...@@ -98,7 +101,12 @@ function run_locally_or_in_docker() {
echo '=> Linting markdown style...' echo '=> Linting markdown style...'
echo echo
run_locally_or_in_docker 'markdownlint' "--config .markdownlint.json ${MD_DOC_PATH}" if [ -z "${MD_DOC_PATH}" ]
then
echo "Merged results pipeline detected, but no markdown files found. Skipping."
else
run_locally_or_in_docker 'markdownlint' "--config .markdownlint.json ${MD_DOC_PATH}"
fi
echo '=> Linting prose...' echo '=> Linting prose...'
run_locally_or_in_docker 'vale' "--minAlertLevel error --output=JSON ${MD_DOC_PATH}" "ruby scripts/vale.rb" run_locally_or_in_docker 'vale' "--minAlertLevel error --output=JSON ${MD_DOC_PATH}" "ruby scripts/vale.rb"
......
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